Skip to content

Commit

Permalink
Require PHP 7.4 to support PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Apr 9, 2022
1 parent d1996d9 commit 05aacc9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
php: [ '7.3', '7.4', '8.0', '8.1' ]
php: [ '7.4', '8.0', '8.1' ]
dependency-version: [ '' ]
include:
- php: '7.3'
- php: '7.4'
dependency-version: '--prefer-lowest'
steps:
- name: Checkout
Expand All @@ -28,7 +28,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v1
tools: composer:v2
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@v2
Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@
"phpstan": "phpstan analyse -l 5 -c phpstan.neon src"
},
"require": {
"php": ">=7.3.0",
"php": ">=7.4.0",
"psr/container": "^1.0",
"php-di/invoker": "^2.0",
"php-di/phpdoc-reader": "^2.0.1",
"opis/closure": "^3.5.5",
"laravel/serializable-closure": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5|^9.0",
"phpunit/phpunit": "^9.5",
"mnapoli/phpunit-easymock": "^1.2",
"doctrine/annotations": "~1.2",
"ocramius/proxy-manager": "^2.2",
"doctrine/annotations": "~1.10",
"ocramius/proxy-manager": "^2.11.2",
"friendsofphp/php-cs-fixer": "^2.4",
"phpstan/phpstan": "^0.12"
},
Expand Down
10 changes: 2 additions & 8 deletions src/Compiler/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use InvalidArgumentException;
use Laravel\SerializableClosure\SerializableClosure;
use Laravel\SerializableClosure\Support\ReflectionClosure;
use Opis\Closure\SerializableClosure as OpisSerializableClosure;
use function rename;
use function sprintf;
use function tempnam;
Expand Down Expand Up @@ -403,13 +402,8 @@ private function isCompilable($value)
*/
private function compileClosure(\Closure $closure) : string
{
if (\PHP_VERSION_ID < 70400) {
$wrapper = new OpisSerializableClosure($closure);
$reflector = $wrapper->getReflector();
} else {
$wrapper = new SerializableClosure($closure);
$reflector = new ReflectionClosure($closure);
}
$wrapper = new SerializableClosure($closure);
$reflector = new ReflectionClosure($closure);

if ($reflector->getUseVariables()) {
throw new InvalidDefinition('Cannot compile closures which import variables using the `use` keyword');
Expand Down
14 changes: 7 additions & 7 deletions tests/IntegrationTest/ContainerDebugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,28 @@ public function testEntriesDefinitions()
});

// Default definitions
$this->assertRegExp('/^Object \(\n {4}class = DI\\\Container\n/', $container->debugEntry('DI\Container'));
$this->assertRegExp(
$this->assertMatchesRegularExpression('/^Object \(\n {4}class = DI\\\Container\n/', $container->debugEntry('DI\Container'));
$this->assertMatchesRegularExpression(
'/^Object \(\n {4}class = #NOT INSTANTIABLE# DI\\\FactoryInterface\n/',
$container->debugEntry('DI\FactoryInterface')
);
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/^Object \(\n {4}class = #NOT INSTANTIABLE# Invoker\\\InvokerInterface\n/',
$container->debugEntry('Invoker\InvokerInterface')
);
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/^Object \(\n {4}class = #NOT INSTANTIABLE# Psr\\\Container\\\ContainerInterface\n/',
$container->debugEntry('Psr\Container\ContainerInterface')
);

// Container definitions
$this->assertRegExp('/^Object \(\n {4}class = DI\\\Container\n/', $container->debugEntry('create'));
$this->assertRegExp('/^Object \(\n {4}class = DI\\\Container\n/', $container->debugEntry('autowire'));
$this->assertMatchesRegularExpression('/^Object \(\n {4}class = DI\\\Container\n/', $container->debugEntry('create'));
$this->assertMatchesRegularExpression('/^Object \(\n {4}class = DI\\\Container\n/', $container->debugEntry('autowire'));
$this->assertEquals('Factory', $container->debugEntry('factory'));
$this->assertEquals('Factory', $container->debugEntry('callback'));
$this->assertEquals('Decorate(decorator)', $container->debugEntry('decorator'));
$this->assertEquals('get(value)', $container->debugEntry('alias'));
$this->assertRegExp('/^Environment variable \(\n {4}variable = foo\n/', $container->debugEntry('environment'));
$this->assertMatchesRegularExpression('/^Environment variable \(\n {4}variable = foo\n/', $container->debugEntry('environment'));
$this->assertEquals("[\n 0 => 'foo',\n 1 => 'bar',\n]", $container->debugEntry('array'));
$this->assertEquals('foo', $container->debugEntry('string'));
$this->assertEquals('Value (1.5)', $container->debugEntry('float'));
Expand Down
5 changes: 1 addition & 4 deletions tests/IntegrationTest/Definitions/FactoryDefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public function test_closure_with_static_variables_are_supported(ContainerBuilde

public function test_multiple_closures_on_the_same_line_cannot_be_compiled()
{
$this->markTestSkipped('Opis/closure doesn\'t throw on multiple closures on the same line');
$this->markTestSkipped('laravel/serializable-closure doesn\'t throw on multiple closures on the same line');

$this->expectException(InvalidDefinition::class);
$this->expectExceptionMessage('Cannot compile closures when two closures are defined on the same line');
Expand All @@ -614,9 +614,6 @@ public function test_optional_parameters_can_be_omitted(ContainerBuilder $builde
self::assertEquals('foo', $container->get('factory'));
}

/**
* @requires PHP 7.4
*/
public function test_fn_closures_compilation_is_supported()
{
$builder = (new ContainerBuilder)->enableCompilation(self::COMPILATION_DIR, self::generateCompiledClassName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ public function testUnguessableProperty()
(new AnnotationBasedAutowiring)->autowire(AnnotationFixture4::class);
}

/**
* Typed properties support requires PHP 7.4
* @requires PHP 7.4
*/
public function testTypedProperty()
{
$definition = (new AnnotationBasedAutowiring)->autowire(AnnotationFixtureTypedProperties::class);
Expand All @@ -79,10 +75,6 @@ public function testTypedProperty()
$this->assertHasPropertyInjection($definition, 'typedAndNamed', 'name');
}

/**
* Typed properties support requires PHP 7.4
* @requires PHP 7.4
*/
public function testScalarTypedPropertiesFail()
{
$this->expectException(\DI\Definition\Exception\InvalidAnnotation::class);
Expand Down

0 comments on commit 05aacc9

Please sign in to comment.