Skip to content

Commit d536e7e

Browse files
Merge pull request #1446 from meyerbaptiste/merge_2.0
Merge branch '2.0'
2 parents e8cdef1 + d0f8335 commit d536e7e

File tree

143 files changed

+891
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+891
-622
lines changed

.php_cs.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ return PhpCsFixer\Config::create()
4343
'throw',
4444
'use',
4545
],
46-
'no_unreachable_default_argument_value' => true,
4746
'no_useless_else' => true,
4847
'no_useless_return' => true,
4948
'ordered_imports' => true,

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ matrix:
1515
include:
1616
- php: '7.0'
1717
- php: '7.1'
18+
- php: '7.2'
1819
env: coverage=1 lint=1
19-
- php: '7.1'
20+
- php: '7.2'
2021
env: deps='low'
21-
- php: '7.1'
22+
- php: '7.2'
2223
env: SYMFONY_DEPRECATIONS_HELPER=0
2324
allow_failures:
2425
env: SYMFONY_DEPRECATIONS_HELPER=0
@@ -31,11 +32,11 @@ before_install:
3132
- if [[ $coverage = 1 ]]; then mkdir -p build/logs build/cov; fi
3233
- if [[ $coverage = 1 ]]; then wget https://phar.phpunit.de/phpcov.phar; fi
3334
- if [[ $coverage = 1 ]]; then wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; fi
34-
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.4.0/php-cs-fixer.phar; fi
35+
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.7.1/php-cs-fixer.phar; fi
3536
- if [[ $lint = 1 ]]; then composer global require --dev 'phpstan/phpstan:^0.8'; fi
3637

3738
install:
38-
- if [[ $coverage = 1 ]]; then composer require --dev --no-update 'phpunit/php-code-coverage:^4.0.1'; fi
39+
- if [[ $coverage = 1 ]]; then composer require --dev --no-update 'phpunit/php-code-coverage:^5.2.2'; fi
3940
- if [[ ! $deps ]]; then composer update --prefer-dist --no-progress --no-suggest --ansi; fi
4041
- if [[ $deps = 'low' ]]; then composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi; fi
4142

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ It natively supports popular open formats including [JSON for Linked Data (JSON-
99
Build a working and fully-featured CRUD API in minutes. Leverage the awesome features of the tool to develop complex and
1010
high performance API-first projects. Extend or override everything you want.
1111

12-
[![JSON-LD enabled](http://json-ld.org/images/json-ld-button-88.png)](http://json-ld.org)
13-
[![Join the chat at https://gitter.im/api-platform/api-platform](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/api-platform/api-platform?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1412
[![Build Status](https://travis-ci.org/api-platform/core.svg?branch=master)](https://travis-ci.org/api-platform/core)
1513
[![Build status](https://ci.appveyor.com/api/projects/status/grwuyprts3wdqx5l?svg=true)](https://ci.appveyor.com/project/dunglas/dunglasapibundle)
1614
[![Coverage Status](https://coveralls.io/repos/github/api-platform/core/badge.svg)](https://coveralls.io/github/api-platform/core)

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
"friendsofsymfony/user-bundle": "^2.0",
3939
"guzzlehttp/guzzle": "^6.0",
4040
"nelmio/api-doc-bundle": "^2.11.2",
41-
"php-mock/php-mock-phpunit": "^1.1",
41+
"php-mock/php-mock-phpunit": "^2.0",
4242
"phpdocumentor/reflection-docblock": "^3.0",
43-
"phpdocumentor/type-resolver": "^0.2",
44-
"phpunit/phpunit": "^5.6.8",
43+
"phpdocumentor/type-resolver": "^0.2.1",
44+
"phpunit/phpunit": "^6.1",
4545
"psr/log": "^1.0",
4646
"sensio/framework-extra-bundle": "^3.0.11 || ^4.0",
4747
"symfony/asset": "^3.3 || ^4.0",

features/bootstrap/CoverageContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @author Kévin Dunglas <[email protected]>
2525
* @copyright Adapted from https://gist.github.com/eliecharra/9c8b3ba57998b50e14a6
2626
*/
27-
class CoverageContext implements Context
27+
final class CoverageContext implements Context
2828
{
2929
/**
3030
* @var CodeCoverage

features/bootstrap/FeatureContext.php

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,21 @@
4343
use Behat\Behat\Context\SnippetAcceptingContext;
4444
use Behatch\HttpCall\Request;
4545
use Doctrine\Common\Persistence\ManagerRegistry;
46-
use Doctrine\Common\Persistence\ObjectManager;
46+
use Doctrine\ORM\EntityManagerInterface;
4747
use Doctrine\ORM\Tools\SchemaTool;
4848

4949
/**
5050
* Defines application features from the specific context.
5151
*/
52-
class FeatureContext implements Context, SnippetAcceptingContext
52+
final class FeatureContext implements Context, SnippetAcceptingContext
5353
{
54-
private $doctrine;
55-
5654
/**
57-
* @var ObjectManager
55+
* @var EntityManagerInterface
5856
*/
5957
private $manager;
60-
61-
/**
62-
* @var SchemaTool
63-
*/
58+
private $doctrine;
6459
private $schemaTool;
65-
66-
/**
67-
* @var array
68-
*/
6960
private $classes;
70-
71-
/**
72-
* @var Request
73-
*/
7461
private $request;
7562

7663
/**
@@ -119,7 +106,7 @@ public function dropDatabase()
119106
/**
120107
* @Given there is :nb dummy objects
121108
*/
122-
public function thereIsDummyObjects($nb)
109+
public function thereIsDummyObjects(int $nb)
123110
{
124111
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];
125112

@@ -139,7 +126,7 @@ public function thereIsDummyObjects($nb)
139126
/**
140127
* @Given there are :nb foo objects with fake names
141128
*/
142-
public function thereAreFooObjectsWithFakeNames($nb)
129+
public function thereAreFooObjectsWithFakeNames(int $nb)
143130
{
144131
$names = ['Hawsepipe', 'Sthenelus', 'Ephesian', 'Separativeness', 'Balbo'];
145132
$bars = ['Lorem', 'Dolor', 'Dolor', 'Sit', 'Amet'];
@@ -158,7 +145,7 @@ public function thereAreFooObjectsWithFakeNames($nb)
158145
/**
159146
* @Given there is :nb dummy group objects
160147
*/
161-
public function thereIsDummyGroupObjects($nb)
148+
public function thereIsDummyGroupObjects(int $nb)
162149
{
163150
for ($i = 1; $i <= $nb; ++$i) {
164151
$dummyGroup = new DummyGroup();
@@ -176,7 +163,7 @@ public function thereIsDummyGroupObjects($nb)
176163
/**
177164
* @Given there is :nb dummy property objects
178165
*/
179-
public function thereIsDummyPropertyObjects($nb)
166+
public function thereIsDummyPropertyObjects(int $nb)
180167
{
181168
for ($i = 1; $i <= $nb; ++$i) {
182169
$dummyProperty = new DummyProperty();
@@ -198,7 +185,7 @@ public function thereIsDummyPropertyObjects($nb)
198185
/**
199186
* @Given there are :nb embedded dummy objects
200187
*/
201-
public function thereIsEmbeddedDummyObjects($nb)
188+
public function thereIsEmbeddedDummyObjects(int $nb)
202189
{
203190
for ($i = 1; $i <= $nb; ++$i) {
204191
$dummy = new EmbeddedDummy();
@@ -217,7 +204,7 @@ public function thereIsEmbeddedDummyObjects($nb)
217204
/**
218205
* @Given there is :nb dummy objects with relatedDummy
219206
*/
220-
public function thereIsDummyObjectsWithRelatedDummy($nb)
207+
public function thereIsDummyObjectsWithRelatedDummy(int $nb)
221208
{
222209
for ($i = 1; $i <= $nb; ++$i) {
223210
$relatedDummy = new RelatedDummy();
@@ -238,7 +225,7 @@ public function thereIsDummyObjectsWithRelatedDummy($nb)
238225
/**
239226
* @Given there is :nb dummy objects with embeddedDummy
240227
*/
241-
public function thereIsDummyObjectsWithEmbeddedDummy($nb)
228+
public function thereIsDummyObjectsWithEmbeddedDummy(int $nb)
242229
{
243230
for ($i = 1; $i <= $nb; ++$i) {
244231
$embeddableDummy = new EmbeddableDummy();
@@ -257,7 +244,7 @@ public function thereIsDummyObjectsWithEmbeddedDummy($nb)
257244
/**
258245
* @Given there is :nb dummy objects having each :nbrelated relatedDummies
259246
*/
260-
public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated)
247+
public function thereIsDummyObjectsWithRelatedDummies(int $nb, int $nbrelated)
261248
{
262249
for ($i = 1; $i <= $nb; ++$i) {
263250
$dummy = new Dummy();
@@ -267,11 +254,12 @@ public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated)
267254
for ($j = 1; $j <= $nbrelated; ++$j) {
268255
$relatedDummy = new RelatedDummy();
269256
$relatedDummy->setName('RelatedDummy'.$j.$i);
257+
270258
$this->manager->persist($relatedDummy);
259+
271260
$dummy->addRelatedDummy($relatedDummy);
272261
}
273262

274-
$this->manager->persist($relatedDummy);
275263
$this->manager->persist($dummy);
276264
}
277265

@@ -281,7 +269,7 @@ public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated)
281269
/**
282270
* @Given there is :nb dummy objects with dummyDate
283271
*/
284-
public function thereIsDummyObjectsWithDummyDate($nb)
272+
public function thereIsDummyObjectsWithDummyDate(int $nb)
285273
{
286274
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];
287275

@@ -307,7 +295,7 @@ public function thereIsDummyObjectsWithDummyDate($nb)
307295
/**
308296
* @Given there is :nb dummy objects with dummyDate and dummyBoolean :bool
309297
*/
310-
public function thereIsDummyObjectsWithDummyDateAndDummyBoolean($nb, $bool)
298+
public function thereIsDummyObjectsWithDummyDateAndDummyBoolean(int $nb, string $bool)
311299
{
312300
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];
313301

@@ -343,7 +331,7 @@ public function thereIsDummyObjectsWithDummyDateAndDummyBoolean($nb, $bool)
343331
/**
344332
* @Given there is :nb dummy objects with dummyDate and relatedDummy
345333
*/
346-
public function thereIsDummyObjectsWithDummyDateAndRelatedDummy($nb)
334+
public function thereIsDummyObjectsWithDummyDateAndRelatedDummy(int $nb)
347335
{
348336
for ($i = 1; $i <= $nb; ++$i) {
349337
$date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC'));
@@ -397,7 +385,7 @@ public function thereIsDummyObjectsWithDummyDateAndEmbeddedDummy($nb)
397385
/**
398386
* @Given there is :nb dummy objects with dummyPrice
399387
*/
400-
public function thereIsDummyObjectsWithDummyPrice($nb)
388+
public function thereIsDummyObjectsWithDummyPrice(int $nb)
401389
{
402390
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];
403391
$prices = ['9.99', '12.99', '15.99', '19.99'];
@@ -418,7 +406,7 @@ public function thereIsDummyObjectsWithDummyPrice($nb)
418406
/**
419407
* @Given there is :nb dummy objects with dummyBoolean :bool
420408
*/
421-
public function thereIsDummyObjectsWithDummyBoolean($nb, $bool)
409+
public function thereIsDummyObjectsWithDummyBoolean(int $nb, string $bool)
422410
{
423411
if (in_array($bool, ['true', '1', 1], true)) {
424412
$bool = true;
@@ -446,7 +434,7 @@ public function thereIsDummyObjectsWithDummyBoolean($nb, $bool)
446434
/**
447435
* @Given there is :nb embedded dummy objects with embeddedDummy.dummyBoolean :bool
448436
*/
449-
public function thereIsDummyObjectsWithEmbeddedDummyBoolean($nb, $bool)
437+
public function thereIsDummyObjectsWithEmbeddedDummyBoolean(int $nb, string $bool)
450438
{
451439
if (in_array($bool, ['true', '1', 1], true)) {
452440
$bool = true;
@@ -473,7 +461,7 @@ public function thereIsDummyObjectsWithEmbeddedDummyBoolean($nb, $bool)
473461
/**
474462
* @Given there is :nb embedded dummy objects with relatedDummy.embeddedDummy.dummyBoolean :bool
475463
*/
476-
public function thereIsDummyObjectsWithRelationEmbeddedDummyBoolean($nb, $bool)
464+
public function thereIsDummyObjectsWithRelationEmbeddedDummyBoolean(int $nb, string $bool)
477465
{
478466
if (in_array($bool, ['true', '1', 1], true)) {
479467
$bool = true;
@@ -593,7 +581,7 @@ public function thereIsAFooEntityWithRelatedBars()
593581
/**
594582
* @Given there is a RelatedDummy with :nb friends
595583
*/
596-
public function thereIsARelatedDummyWithFriends($nb)
584+
public function thereIsARelatedDummyWithFriends(int $nb)
597585
{
598586
$relatedDummy = new RelatedDummy();
599587
$relatedDummy->setName('RelatedDummy with friends');
@@ -622,7 +610,7 @@ public function thereIsARelatedDummyWithFriends($nb)
622610
}
623611

624612
/**
625-
* @Given there is an answer ":answer" to the question ":question"
613+
* @Given there is an answer :answer to the question :question
626614
*/
627615
public function thereIsAnAnswerToTheQuestion(string $a, string $q)
628616
{
@@ -643,7 +631,7 @@ public function thereIsAnAnswerToTheQuestion(string $a, string $q)
643631
/**
644632
* @Given there are :nb nodes in a container :uuid
645633
*/
646-
public function thereAreNodesInAContainer($nb, $uuid)
634+
public function thereAreNodesInAContainer(int $nb, string $uuid)
647635
{
648636
$container = new Container();
649637
$container->setId($uuid);
@@ -662,10 +650,9 @@ public function thereAreNodesInAContainer($nb, $uuid)
662650
/**
663651
* @Then the password :password for user :user should be hashed
664652
*/
665-
public function thePasswordForUserShouldBeHashed($password, $user)
653+
public function thePasswordForUserShouldBeHashed(string $password, string $user)
666654
{
667-
$repository = $this->doctrine->getRepository(User::class);
668-
$user = $repository->find($user);
655+
$user = $this->doctrine->getRepository(User::class)->find($user);
669656

670657
if (!password_verify($password, $user->getPassword())) {
671658
throw new \Exception('User password mismatch');

features/bootstrap/HttpCacheContext.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
declare(strict_types=1);
1313

1414
use Behat\Symfony2Extension\Context\KernelAwareContext;
15+
use PHPUnit\Framework\ExpectationFailedException;
1516
use Symfony\Component\HttpKernel\KernelInterface;
1617

1718
/**
1819
* @author Kévin Dunglas <[email protected]>
1920
*/
20-
class HttpCacheContext implements KernelAwareContext
21+
final class HttpCacheContext implements KernelAwareContext
2122
{
2223
/**
2324
* @var KernelInterface
@@ -30,7 +31,7 @@ public function setKernel(KernelInterface $kernel)
3031
}
3132

3233
/**
33-
* @Then ":iris" IRIs should be purged
34+
* @Then :iris IRIs should be purged
3435
*/
3536
public function irisShouldBePurged(string $iris)
3637
{
@@ -40,9 +41,7 @@ public function irisShouldBePurged(string $iris)
4041
$purger->clear();
4142

4243
if ($iris !== $purgedIris) {
43-
throw new \PHPUnit_Framework_ExpectationFailedException(
44-
sprintf('IRIs "%s" does not match expected "%s".', $purgedIris, $iris)
45-
);
44+
throw new ExpectationFailedException(sprintf('IRIs "%s" does not match expected "%s".', $purgedIris, $iris));
4645
}
4746
}
4847
}

0 commit comments

Comments
 (0)