Skip to content

Commit b1cfce2

Browse files
authored
Merge pull request #27 from jakzal/2.0
Drop support for types defined in docblocks
2 parents 4160c0e + 938c86b commit b1cfce2

15 files changed

+28
-66
lines changed

.travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
language: php
22
matrix:
33
include:
4-
- php: 7.2
5-
env: EXECUTE_DEPLOYMENT=true
6-
- php: 7.3
4+
- php: 7.4
75
env: deps=low
86
- php: 7.4
7+
env: EXECUTE_DEPLOYMENT=true
98
fast_finish: true
109
before_install:
1110
- phpenv config-rm xdebug.ini || echo "XDebug not enabled"

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ package: tools/box
7171

7272
cd build/phar && \
7373
composer remove phpunit/phpunit --no-update && \
74-
composer config platform.php 7.2 && \
74+
composer config platform.php 7.4 && \
7575
composer update --no-dev -o -a
7676

7777
tools/box compile
@@ -93,16 +93,16 @@ tools/deptrac:
9393
curl -Ls http://get.sensiolabs.de/deptrac.phar -o tools/deptrac && chmod +x tools/deptrac
9494

9595
tools/infection: tools/infection.pubkey
96-
curl -Ls https://github.com/infection/infection/releases/download/0.15.0/infection.phar -o tools/infection && chmod +x tools/infection
96+
curl -Ls https://github.com/infection/infection/releases/download/0.15.1/infection.phar -o tools/infection && chmod +x tools/infection
9797

9898
tools/infection.pubkey:
99-
curl -Ls https://github.com/infection/infection/releases/download/0.15.0/infection.phar.pubkey -o tools/infection.pubkey
99+
curl -Ls https://github.com/infection/infection/releases/download/0.15.1/infection.phar.pubkey -o tools/infection.pubkey
100100

101101
tools/box:
102102
curl -Ls https://github.com/humbug/box/releases/download/3.8.4/box.phar -o tools/box && chmod +x tools/box
103103

104104
tests/phar/tools/phpunit:
105-
curl -Ls https://phar.phpunit.de/phpunit-8.phar -o tests/phar/tools/phpunit && chmod +x tests/phar/tools/phpunit
105+
curl -Ls https://phar.phpunit.de/phpunit-9.phar -o tests/phar/tools/phpunit && chmod +x tests/phar/tools/phpunit
106106

107107
tests/phar/tools/phpunit.d/zalas-phpunit-injector-extension.phar: build/zalas-phpunit-injector-extension.phar
108108
cp build/zalas-phpunit-injector-extension.phar tests/phar/tools/phpunit.d/zalas-phpunit-injector-extension.phar

README.md

-9
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,10 @@ class ServiceInjectorTest extends TestCase implements ServiceContainerTestCase
7373
*/
7474
private LoggerInterface $logger;
7575

76-
/**
77-
* @var LoggerInterface
78-
* @inject
79-
*/
80-
private $anotherLogger;
81-
82-
8376
public function testThatServicesAreInjected()
8477
{
8578
$this->assertInstanceOf(SerializerInterface::class, $this->serializer, 'The service is injectd by its type');
8679
$this->assertInstanceOf(LoggerInterface::class, $this->logger, 'The service is injected by its id');
87-
$this->assertInstanceOf(LoggerInterface::class, $this->anotherLogger, 'The service is injected by its @var type');
8880
}
8981

9082
public function createServiceContainer(): ContainerInterface
@@ -95,7 +87,6 @@ class ServiceInjectorTest extends TestCase implements ServiceContainerTestCase
9587
```
9688

9789
The service is found by its type, or an id if it's given in the `@inject` tag.
98-
In legacy PHP versions the `@var` annotation can be used.
9990

10091
The `createServiceContainer` method would be usually provided by a base test case or a trait.
10192
In case of Symfony, such a trait is provided by this package (see the next section).

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
"description": "Injects services from a PSR-11 dependency injection container to PHPUnit test cases",
44
"type": "library",
55
"require": {
6-
"php": "^7.2,<8.0",
7-
"phpunit/phpunit": "^8.0",
6+
"php": "^7.4,<8.0",
7+
"phpunit/phpunit": "^9.0",
88
"psr/container": "^1.0",
9-
"zalas/injector": "^1.3"
9+
"zalas/injector": "^2.0"
1010
},
1111
"require-dev": {
1212
"symfony/config": "^3.4 || ^4.4 || ^5.0",
1313
"symfony/dependency-injection": "^3.4 || ^4.4 || ^5.0",
1414
"symfony/http-kernel": "^3.4 || ^4.4 || ^5.0",
1515
"zalas/phpunit-globals": "^2.0",
1616
"symfony/framework-bundle": "^3.4 || ^4.4 || ^5.0",
17-
"zalas/phpunit-doubles": "^1.2",
17+
"zalas/phpunit-doubles": "^1.4",
1818
"phpspec/prophecy": "^1.9"
1919
},
2020
"autoload": {
@@ -36,7 +36,7 @@
3636
],
3737
"extra": {
3838
"branch-alias": {
39-
"dev-master": "1.x-dev"
39+
"dev-master": "2.x-dev"
4040
}
4141
}
4242
}

manifest.xml.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<phar xmlns="https://phar.io/xml/manifest/1.0">
33
<contains name="zalas/phpunit-injector" version="@@version@@" type="extension">
4-
<extension for="phpunit/phpunit" compatible="^8.0"/>
4+
<extension for="phpunit/phpunit" compatible="^9.0"/>
55
</contains>
66

77
<copyright>
@@ -10,6 +10,6 @@
1010
</copyright>
1111

1212
<requires>
13-
<php version="^7.2"/>
13+
<php version="^7.4"/>
1414
</requires>
1515
</phar>

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.0/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.0/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
55
beStrictAboutOutputDuringTests="true"
66
beStrictAboutTodoAnnotatedTests="true"

src/Symfony/Compiler/Discovery/ClassFinder.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55

66
class ClassFinder
77
{
8-
/**
9-
* @var string
10-
*/
11-
private $path;
8+
private string $path;
129

1310
public function __construct(string $path = 'tests')
1411
{

src/Symfony/Compiler/Discovery/PropertyDiscovery.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@
1212

1313
class PropertyDiscovery
1414
{
15-
/**
16-
* @var ClassFinder
17-
*/
18-
private $classFinder;
15+
private ClassFinder $classFinder;
1916

20-
/**
21-
* @var ExtractorFactory
22-
*/
23-
private $extractorFactory;
17+
private ExtractorFactory $extractorFactory;
2418

2519
public function __construct(?ClassFinder $classFinder = null, ?ExtractorFactory $extractorFactory = null)
2620
{

src/Symfony/Compiler/ExposeServicesForTestsPass.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
*/
1818
class ExposeServicesForTestsPass implements CompilerPassInterface
1919
{
20-
/**
21-
* @var PropertyDiscovery
22-
*/
23-
private $propertyDiscovery;
20+
private PropertyDiscovery $propertyDiscovery;
2421

2522
public function __construct(?PropertyDiscovery $propertyDiscovery = null)
2623
{

src/Symfony/TestCase/SymfonyKernel.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
*/
1313
trait SymfonyKernel
1414
{
15-
/**
16-
* @var KernelInterface|null
17-
*/
18-
protected static $kernel;
15+
protected static ?KernelInterface $kernel = null;
1916

2017
protected static function bootKernel(array $options = []): KernelInterface
2118
{

src/TestListener/TestCaseContainerFactory.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99

1010
final class TestCaseContainerFactory implements ContainerFactory
1111
{
12-
/**
13-
* @var ServiceContainerTestCase
14-
*/
15-
private $testCase;
12+
private ServiceContainerTestCase $testCase;
1613

1714
public function __construct(ServiceContainerTestCase $testCase)
1815
{

tests/Symfony/TestCase/SymfonyContainerTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ class SymfonyContainerTest extends TestCase implements ServiceContainerTestCase
1515
use SymfonyContainer;
1616

1717
/**
18-
* @var Service1
1918
* @inject
2019
*/
21-
private $service1;
20+
private Service1 $service1;
2221

2322
/**
24-
* @var Service2
2523
* @inject foo.service2
2624
*/
27-
private $service2;
25+
private Service2 $service2;
2826

2927
/**
3028
* @env KERNEL_CLASS=Zalas\Injector\PHPUnit\Tests\Symfony\TestCase\Fixtures\NoFrameworkBundle\TestKernel

tests/TestListener/Fixtures/Services.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
class Services
77
{
88
/**
9-
* @var Service1
109
* @inject
1110
*/
12-
private $service1;
11+
private Service1 $service1;
1312

1413
/**
15-
* @var Service2
1614
* @inject foo.service2
1715
*/
18-
private $service2;
16+
private Service2 $service2;
1917

2018
public function getService1(): ?Service1
2119
{

tests/TestListener/ServiceInjectorListenerTest.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,16 @@
1616
class ServiceInjectorListenerTest extends TestCase implements ServiceContainerTestCase
1717
{
1818
/**
19-
* @var Service1
2019
* @inject
2120
*/
22-
private $service1;
21+
private Service1 $service1;
2322

2423
/**
25-
* @var Service2
2624
* @inject foo.service2
2725
*/
28-
private $service2;
26+
private Service2 $service2;
2927

30-
/**
31-
* @var Service2
32-
*/
33-
private $service2NotInjected;
28+
private ?Service2 $service2NotInjected = null;
3429

3530
public function test_it_is_a_phpunit_listener()
3631
{

tests/phar/tests/PharTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
class PharTest extends TestCase implements ServiceContainerTestCase
1010
{
1111
/**
12-
* @var stdClass
1312
* @inject foo.service
1413
*/
15-
private $service;
14+
private stdClass $service;
1615

1716
public function test_it_injects_services_into_test_cases()
1817
{

0 commit comments

Comments
 (0)