Skip to content

Commit

Permalink
[8.x] Adds a few PHP 8.1 related changes (laravel#38404)
Browse files Browse the repository at this point in the history
* Add ReturnTypeWillChange to SessionHandlerInterface usages

* Bump commonmark

* Fix getIterator

* Use Symfony 5.4 components

* Dev mockery

* Mimic PHP 8.0

* Try removing symfony components

* Mockery

* Fix type errors in db tests (laravel#38696)

* Fix type errors in db tests

* Apply fixes from StyleCI

Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>

* Additional DB test fixes (laravel#38699)

* More DB fixes (laravel#38700)

* PHP 8.1 prefer-lowest builds

* Remove skipping PHP 8.1 builds

* Bump PHPUnit

* Revert "PHP 8.1 prefer-lowest builds"

This reverts commit d5b01d2.

* [8.x] Adds PHP 8.1 support to serializable closures (laravel#38801)

* Makes serializable closures work with PHP 8.1

* Apply fixes from StyleCI

* Fixes PHP 7.3 tests

* Refactors

* Updates deprecated warning

Co-authored-by: Dries Vints <dries@vints.io>

* Fixes restoring properties

* Update QueueServiceProvider.php

Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>
Co-authored-by: Dries Vints <dries@vints.io>
Co-authored-by: Taylor Otwell <taylor@laravel.com>

* Fix default value

* Fix mb_strlen value

* Adds `continue-on-error` for PHP 8.1

* [8.x] Add explicit `@return` annotations in `{@inheritdoc}` from vendors and add some missing `#[\ReturnTypeWillChange]` (laravel#38819)

* Add explicit `@return` to `{@inheritdoc}` PHPDoc

* Use `return null;` when the return type is `null`

* Skips PHP 8.1 failing tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Update SerializableClosure.php

Co-authored-by: Graham Campbell <GrahamCampbell@users.noreply.github.com>
Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>
Co-authored-by: Nuno Maduro <enunomaduro@gmail.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
Co-authored-by: Wouter J <wouterj@users.noreply.github.com>
  • Loading branch information
6 people authored and victorvilella committed Oct 12, 2021
1 parent 5d4007e commit f90eb2e
Show file tree
Hide file tree
Showing 81 changed files with 572 additions and 116 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
stability: [prefer-lowest, prefer-stable]
include:
- php: '8.1'
flags: "--ignore-platform-req=php"
stability: prefer-stable

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
Expand All @@ -57,6 +56,10 @@ jobs:
tools: composer:v2
coverage: none

- name: Mimic PHP 8.0
run: composer config platform.php 8.0.999
if: matrix.php > 8

- name: Set Minimum Guzzle Version
uses: nick-invision/retry@v1
with:
Expand All @@ -70,7 +73,7 @@ jobs:
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress ${{ matrix.flags }}
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Execute tests
continue-on-error: ${{ matrix.php > 8 }}
Expand All @@ -93,7 +96,6 @@ jobs:
stability: [prefer-lowest, prefer-stable]
include:
- php: '8.1'
flags: "--ignore-platform-req=php"
stability: prefer-stable

name: PHP ${{ matrix.php }} - ${{ matrix.stability }} - Windows
Expand All @@ -115,6 +117,10 @@ jobs:
tools: composer:v2
coverage: none

- name: Mimic PHP 8.0
run: composer config platform.php 8.0.999
if: matrix.php > 8

- name: Set Minimum Guzzle Version
uses: nick-invision/retry@v1
with:
Expand All @@ -128,8 +134,7 @@ jobs:
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress ${{ matrix.flags }}
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Execute tests
continue-on-error: ${{ matrix.php > 8 }}
run: vendor/bin/phpunit --verbose
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"doctrine/inflector": "^1.4|^2.0",
"dragonmantank/cron-expression": "^3.0.2",
"egulias/email-validator": "^2.1.10",
"league/commonmark": "^1.3|^2.0",
"laravel/serializable-closure": "^1.0",
"league/commonmark": "^1.3|^2.0.2",
"league/flysystem": "^1.1",
"monolog/monolog": "^2.0",
"nesbot/carbon": "^2.31",
Expand Down Expand Up @@ -79,14 +80,14 @@
},
"require-dev": {
"aws/aws-sdk-php": "^3.189.0",
"doctrine/dbal": "^2.6|^3.0",
"doctrine/dbal": "^2.13.3|^3.1.2",
"filp/whoops": "^2.8",
"guzzlehttp/guzzle": "^6.5.5|^7.0.1",
"league/flysystem-cached-adapter": "^1.0",
"mockery/mockery": "^1.4.2",
"mockery/mockery": "^1.4.4",
"orchestra/testbench-core": "^6.23",
"pda/pheanstalk": "^4.0",
"phpunit/phpunit": "^8.5.8|^9.3.3",
"phpunit/phpunit": "^8.5.19|^9.5.8",
"predis/predis": "^1.1.2",
"symfony/cache": "^5.1.4"
},
Expand Down Expand Up @@ -131,18 +132,18 @@
"ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).",
"aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.189.0).",
"brianium/paratest": "Required to run tests in parallel (^6.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6|^3.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.2).",
"filp/whoops": "Required for friendly error pages in development (^2.8).",
"fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).",
"guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^6.5.5|^7.0.1).",
"laravel/tinker": "Required to use the tinker console command (^2.0).",
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).",
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).",
"mockery/mockery": "Required to use mocking (^1.4.2).",
"mockery/mockery": "Required to use mocking (^1.4.4).",
"nyholm/psr7": "Required to use PSR-7 bridging features (^1.2).",
"pda/pheanstalk": "Required to use the beanstalk queue driver (^4.0).",
"phpunit/phpunit": "Required to use assertions and run tests (^8.5.8|^9.3.3).",
"phpunit/phpunit": "Required to use assertions and run tests (^8.5.19|^9.5.8).",
"predis/predis": "Required to use the predis connector (^1.1.2).",
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0).",
Expand Down
7 changes: 2 additions & 5 deletions src/Illuminate/Bus/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Contracts\Queue\Factory as QueueFactory;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Queue\CallQueuedClosure;
use Illuminate\Queue\SerializableClosure;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use JsonSerializable;
Expand Down Expand Up @@ -420,17 +419,15 @@ public function delete()
/**
* Invoke a batch callback handler.
*
* @param \Illuminate\Queue\SerializableClosure|callable $handler
* @param callable $handler
* @param \Illuminate\Bus\Batch $batch
* @param \Throwable|null $e
* @return void
*/
protected function invokeHandlerCallback($handler, Batch $batch, Throwable $e = null)
{
try {
return $handler instanceof SerializableClosure
? $handler->__invoke($batch, $e)
: call_user_func($handler, $batch, $e);
return $handler($batch, $e);
} catch (Throwable $e) {
if (function_exists('report')) {
report($e);
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Bus/PendingBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Bus\Events\BatchDispatched;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Queue\SerializableClosure;
use Illuminate\Queue\SerializableClosureFactory;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Throwable;
Expand Down Expand Up @@ -78,7 +78,7 @@ public function add($jobs)
public function then($callback)
{
$this->options['then'][] = $callback instanceof Closure
? new SerializableClosure($callback)
? SerializableClosureFactory::make($callback)
: $callback;

return $this;
Expand All @@ -103,7 +103,7 @@ public function thenCallbacks()
public function catch($callback)
{
$this->options['catch'][] = $callback instanceof Closure
? new SerializableClosure($callback)
? SerializableClosureFactory::make($callback)
: $callback;

return $this;
Expand All @@ -128,7 +128,7 @@ public function catchCallbacks()
public function finally($callback)
{
$this->options['finally'][] = $callback instanceof Closure
? new SerializableClosure($callback)
? SerializableClosureFactory::make($callback)
: $callback;

return $this;
Expand Down
3 changes: 1 addition & 2 deletions src/Illuminate/Bus/Queueable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Closure;
use Illuminate\Queue\CallQueuedClosure;
use Illuminate\Queue\SerializableClosure;
use Illuminate\Support\Arr;
use RuntimeException;

Expand Down Expand Up @@ -245,7 +244,7 @@ public function dispatchNextJobInChain()
public function invokeChainCatchCallbacks($e)
{
collect($this->chainCatchCallbacks)->each(function ($callback) use ($e) {
$callback instanceof SerializableClosure ? $callback->__invoke($e) : call_user_func($callback, $e);
$callback($e);
});
}
}
12 changes: 12 additions & 0 deletions src/Illuminate/Cache/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public function many(array $keys)

/**
* {@inheritdoc}
*
* @return iterable
*/
public function getMultiple($keys, $default = null)
{
Expand Down Expand Up @@ -219,6 +221,8 @@ public function put($key, $value, $ttl = null)

/**
* {@inheritdoc}
*
* @return bool
*/
public function set($key, $value, $ttl = null)
{
Expand Down Expand Up @@ -276,6 +280,8 @@ protected function putManyForever(array $values)

/**
* {@inheritdoc}
*
* @return bool
*/
public function setMultiple($values, $ttl = null)
{
Expand Down Expand Up @@ -439,6 +445,8 @@ public function forget($key)

/**
* {@inheritdoc}
*
* @return bool
*/
public function delete($key)
{
Expand All @@ -447,6 +455,8 @@ public function delete($key)

/**
* {@inheritdoc}
*
* @return bool
*/
public function deleteMultiple($keys)
{
Expand All @@ -463,6 +473,8 @@ public function deleteMultiple($keys)

/**
* {@inheritdoc}
*
* @return bool
*/
public function clear()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Illuminate/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public function __construct(Container $laravel, Dispatcher $events, $version)

/**
* {@inheritdoc}
*
* @return int
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ protected function resolveCommand($command)

/**
* {@inheritdoc}
*
* @return bool
*/
public function isHidden()
{
Expand All @@ -171,6 +173,8 @@ public function isHidden()

/**
* {@inheritdoc}
*
* @return static
*/
public function setHidden(bool $hidden)
{
Expand Down
8 changes: 6 additions & 2 deletions src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ public function bound($abstract)
}

/**
* {@inheritdoc}
* {@inheritdoc}
*
* @return bool
*/
public function has($id)
{
Expand Down Expand Up @@ -693,7 +695,9 @@ public function make($abstract, array $parameters = [])
}

/**
* {@inheritdoc}
* {@inheritdoc}
*
* @return mixed
*/
public function get($id)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Container/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function getParameterClassName($parameter)
$type = $parameter->getType();

if (! $type instanceof ReflectionNamedType || $type->isBuiltin()) {
return;
return null;
}

$name = $type->getName();
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Database/DBAL/TimestampType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class TimestampType extends Type
{
/**
* {@inheritdoc}
*
* @return string
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
Expand Down Expand Up @@ -97,6 +99,8 @@ protected function getSQLitePlatformSQLDeclaration(array $fieldDeclaration)

/**
* {@inheritdoc}
*
* @return string
*/
public function getName()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Illuminate/Database/PDO/SqlServerDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

class SqlServerDriver extends AbstractSQLServerDriver
{
/**
* @return \Doctrine\DBAL\Driver\Connection
*/
public function connect(array $params)
{
return new SqlServerConnection(
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
},
"suggest": {
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6|^3.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.2).",
"fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).",
"illuminate/console": "Required to use the database commands (^8.0).",
"illuminate/events": "Required to use the observers with Eloquent (^8.0).",
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Encryption/Encrypter.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function decrypt($payload, $unserialize = true)
// we will then unserialize it and return it out to the caller. If we are
// unable to decrypt this value we will throw out an exception message.
$decrypted = \openssl_decrypt(
$payload['value'], strtolower($this->cipher), $this->key, 0, $iv, $tag
$payload['value'], strtolower($this->cipher), $this->key, 0, $iv, $tag ?? ''
);

if ($decrypted === false) {
Expand Down
24 changes: 23 additions & 1 deletion src/Illuminate/Encryption/EncryptionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use Opis\Closure\SerializableClosure;
use Laravel\SerializableClosure\SerializableClosure;
use Opis\Closure\SerializableClosure as OpisSerializableClosure;

class EncryptionServiceProvider extends ServiceProvider
{
Expand All @@ -17,6 +18,7 @@ public function register()
{
$this->registerEncrypter();
$this->registerOpisSecurityKey();
$this->registerSerializableClosureSecurityKey();
}

/**
Expand All @@ -37,8 +39,28 @@ protected function registerEncrypter()
* Configure Opis Closure signing for security.
*
* @return void
*
* @deprecated Will be removed in a future Laravel version.
*/
protected function registerOpisSecurityKey()
{
if (\PHP_VERSION_ID < 80100) {
$config = $this->app->make('config')->get('app');

if (! class_exists(OpisSerializableClosure::class) || empty($config['key'])) {
return;
}

OpisSerializableClosure::setSecretKey($this->parseKey($config));
}
}

/**
* Configure Serializable Closure signing for security.
*
* @return void
*/
protected function registerSerializableClosureSecurityKey()
{
$config = $this->app->make('config')->get('app');

Expand Down
Loading

0 comments on commit f90eb2e

Please sign in to comment.