Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP8 support #83

Merged
merged 1 commit into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/node_modules

/.php_cs.cache

php-cs-fixer.phar
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ matrix:
- php: '7.4'
env: YAML=^5.0
- php: nightly
env: YAML=~4.3.0
env: YAML=~4.4.0
# windows tests
# https://travis-ci.community/t/where-to-contribute-php-support-for-windows/304
- os: windows
Expand Down Expand Up @@ -57,6 +57,6 @@ script:
- make lint
- make stan
- make test
- if [[ $TRAVIS_PHP_VERSION = "7.3" || $TRAVIS_PHP_VERSION = "nightly" ]]; then true; else make check-style; fi
- make check-style
- make coverage

6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ endif

all:

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

fix-style:
vendor/bin/indent --tabs composer.json
Expand Down Expand Up @@ -42,6 +42,8 @@ schemas/openapi-v3.0.json: vendor/oai/openapi-specification/schemas/v3.0/schema.
schemas/openapi-v3.0.yaml: vendor/oai/openapi-specification/schemas/v3.0/schema.yaml
cp $< $@

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

# find spec classes that are not mentioned in tests with @covers yet
coverage: .php-openapi-covA .php-openapi-covB
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
},
"require-dev": {
"cebe/indent": "*",
"friendsofphp/php-cs-fixer": "~2.16.1",
"phpunit/phpunit": "^6.5",
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5 || ^9.4",

"oai/openapi-specification": "3.0.2",
"mermade/openapi3-examples": "1.0.0",
Expand Down
8 changes: 7 additions & 1 deletion tests/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ public function testSymfonyYamlBugHunt()
$openapi = \cebe\openapi\Reader::readFromYamlFile($openApiFile);

$inlineYamlExample = $openapi->paths['/']->get->responses['200']->content['application/json']->example;
$this->assertInternalType('array', $inlineYamlExample);

if (method_exists($this, 'assertIsArray')) {
$this->assertIsArray($inlineYamlExample);
} else {
$this->assertInternalType('array', $inlineYamlExample);
}

$expectedArray = json_decode(<<<JSON
{
"total": 2,
Expand Down
8 changes: 7 additions & 1 deletion tests/spec/MediaTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ public function testRead()
$this->assertTrue($result);

$this->assertInstanceOf(Reference::class, $mediaType->schema);
$this->assertInternalType('array', $mediaType->examples);

if (method_exists($this, 'assertIsArray')) {
$this->assertIsArray($mediaType->examples);
} else {
$this->assertInternalType('array', $mediaType->examples);
}

$this->assertCount(3, $mediaType->examples);
$this->assertArrayHasKey('cat', $mediaType->examples);
$this->assertArrayHasKey('dog', $mediaType->examples);
Expand Down
7 changes: 6 additions & 1 deletion tests/spec/OpenApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ public function testReadPetStore()


// servers
$this->assertInternalType('array', $openapi->servers);
if (method_exists($this, 'assertIsArray')) {
$this->assertIsArray($openapi->servers);
} else {
$this->assertInternalType('array', $openapi->servers);
}

$this->assertCount(1, $openapi->servers);
foreach ($openapi->servers as $server) {
$this->assertInstanceOf(\cebe\openapi\spec\Server::class, $server);
Expand Down