Skip to content

Commit 696bfd0

Browse files
committed
PHP8 support
1 parent 34f6e20 commit 696bfd0

File tree

7 files changed

+29
-9
lines changed

7 files changed

+29
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/node_modules
55

66
/.php_cs.cache
7+
8+
php-cs-fixer.phar

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ matrix:
2424
- php: '7.4'
2525
env: YAML=^5.0
2626
- php: nightly
27-
env: YAML=~4.3.0
27+
env: YAML=~4.4.0
2828
# windows tests
2929
# https://travis-ci.community/t/where-to-contribute-php-support-for-windows/304
3030
- os: windows
@@ -57,6 +57,6 @@ script:
5757
- make lint
5858
- make stan
5959
- make test
60-
- if [[ $TRAVIS_PHP_VERSION = "7.3" || $TRAVIS_PHP_VERSION = "nightly" ]]; then true; else make check-style; fi
60+
- make check-style
6161
- make coverage
6262

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ endif
88

99
all:
1010

11-
check-style:
12-
vendor/bin/php-cs-fixer fix src/ --diff --dry-run
11+
check-style: php-cs-fixer.phar
12+
PHP_CS_FIXER_IGNORE_ENV=1 ./php-cs-fixer.phar fix src/ --diff --dry-run
1313

1414
fix-style:
1515
vendor/bin/indent --tabs composer.json
@@ -42,6 +42,8 @@ schemas/openapi-v3.0.json: vendor/oai/openapi-specification/schemas/v3.0/schema.
4242
schemas/openapi-v3.0.yaml: vendor/oai/openapi-specification/schemas/v3.0/schema.yaml
4343
cp $< $@
4444

45+
php-cs-fixer.phar:
46+
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.7/php-cs-fixer.phar && chmod +x php-cs-fixer.phar
4547

4648
# find spec classes that are not mentioned in tests with @covers yet
4749
coverage: .php-openapi-covA .php-openapi-covB

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
},
2626
"require-dev": {
2727
"cebe/indent": "*",
28-
"friendsofphp/php-cs-fixer": "~2.16.1",
29-
"phpunit/phpunit": "^6.5",
28+
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5 || ^9.4",
3029

3130
"oai/openapi-specification": "3.0.2",
3231
"mermade/openapi3-examples": "1.0.0",

tests/ReaderTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,13 @@ public function testSymfonyYamlBugHunt()
112112
$openapi = \cebe\openapi\Reader::readFromYamlFile($openApiFile);
113113

114114
$inlineYamlExample = $openapi->paths['/']->get->responses['200']->content['application/json']->example;
115-
$this->assertInternalType('array', $inlineYamlExample);
115+
116+
if (method_exists($this, 'assertIsArray')) {
117+
$this->assertIsArray($inlineYamlExample);
118+
} else {
119+
$this->assertInternalType('array', $inlineYamlExample);
120+
}
121+
116122
$expectedArray = json_decode(<<<JSON
117123
{
118124
"total": 2,

tests/spec/MediaTypeTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ public function testRead()
4646
$this->assertTrue($result);
4747

4848
$this->assertInstanceOf(Reference::class, $mediaType->schema);
49-
$this->assertInternalType('array', $mediaType->examples);
49+
50+
if (method_exists($this, 'assertIsArray')) {
51+
$this->assertIsArray($mediaType->examples);
52+
} else {
53+
$this->assertInternalType('array', $mediaType->examples);
54+
}
55+
5056
$this->assertCount(3, $mediaType->examples);
5157
$this->assertArrayHasKey('cat', $mediaType->examples);
5258
$this->assertArrayHasKey('dog', $mediaType->examples);

tests/spec/OpenApiTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ public function testReadPetStore()
5252

5353

5454
// servers
55-
$this->assertInternalType('array', $openapi->servers);
55+
if (method_exists($this, 'assertIsArray')) {
56+
$this->assertIsArray($openapi->servers);
57+
} else {
58+
$this->assertInternalType('array', $openapi->servers);
59+
}
60+
5661
$this->assertCount(1, $openapi->servers);
5762
foreach ($openapi->servers as $server) {
5863
$this->assertInstanceOf(\cebe\openapi\spec\Server::class, $server);

0 commit comments

Comments
 (0)