Skip to content

Commit 4c74da5

Browse files
authored
Merge pull request #670 from Seldaek/gh_actions
Switch to GH Actions
2 parents 4a1f07f + d11928e commit 4c74da5

13 files changed

+218
-55
lines changed

.github/workflows/code-cov.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Code Coverage"
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
env:
8+
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
9+
10+
jobs:
11+
tests:
12+
name: "Code Coverage"
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: "Checkout"
18+
uses: "actions/checkout@v2"
19+
20+
- name: "Install PHP"
21+
uses: "shivammathur/setup-php@v2"
22+
with:
23+
extensions: "intl, zip"
24+
ini-values: "memory_limit=-1, phar.readonly=0, error_reporting=E_ALL, display_errors=On"
25+
php-version: "7.4"
26+
tools: composer
27+
coverage: xdebug2
28+
29+
- name: "Update dependencies"
30+
run: "composer update ${{ env.COMPOSER_FLAGS }}"
31+
32+
- name: "Run coverage"
33+
run: "composer coverage"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
env:
8+
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
9+
10+
jobs:
11+
tests:
12+
name: "CI"
13+
14+
runs-on: ubuntu-latest
15+
continue-on-error: ${{ matrix.experimental }}
16+
17+
strategy:
18+
matrix:
19+
php-version:
20+
- "5.3"
21+
- "5.4"
22+
- "5.5"
23+
- "5.6"
24+
- "7.0"
25+
- "7.1"
26+
- "7.2"
27+
- "7.3"
28+
- "7.4"
29+
# - "8.0"
30+
dependencies: [highest]
31+
experimental: [false]
32+
include:
33+
- php-version: "5.3"
34+
dependencies: highest
35+
experimental: false
36+
- php-version: "5.3"
37+
dependencies: lowest
38+
experimental: false
39+
# - php-version: "8.0"
40+
# dependencies: highest
41+
# experimental: false
42+
# - php-version: "8.1"
43+
# dependencies: lowest-ignore
44+
# experimental: true
45+
# - php-version: "8.1"
46+
# dependencies: highest-ignore
47+
# experimental: true
48+
49+
steps:
50+
- name: "Checkout"
51+
uses: "actions/checkout@v2"
52+
53+
- name: "Install PHP"
54+
uses: "shivammathur/setup-php@v2"
55+
with:
56+
coverage: "none"
57+
extensions: "intl, zip"
58+
ini-values: "memory_limit=-1, phar.readonly=0, error_reporting=E_ALL, display_errors=On"
59+
php-version: "${{ matrix.php-version }}"
60+
tools: composer
61+
62+
- name: "Handle lowest dependencies update"
63+
if: "contains(matrix.dependencies, 'lowest')"
64+
run: "echo \"COMPOSER_UPDATE_FLAGS=$COMPOSER_UPDATE_FLAGS --prefer-lowest\" >> $GITHUB_ENV"
65+
66+
- name: "Handle ignore-platform-reqs dependencies update"
67+
if: "contains(matrix.dependencies, 'ignore')"
68+
run: "echo \"COMPOSER_FLAGS=$COMPOSER_FLAGS --ignore-platform-req=php\" >> $GITHUB_ENV"
69+
70+
- name: "Update dependencies"
71+
run: "composer update ${{ env.COMPOSER_UPDATE_FLAGS }} ${{ env.COMPOSER_FLAGS }}"
72+
73+
- name: "Validate composer.json"
74+
run: "composer validate"
75+
76+
- name: "Run tests"
77+
run: "composer test"
78+
79+

.github/workflows/phpstan.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "PHPStan"
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
env:
8+
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
9+
10+
jobs:
11+
tests:
12+
name: "PHPStan"
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: "Checkout"
18+
uses: "actions/checkout@v2"
19+
20+
- name: "Install PHP"
21+
uses: "shivammathur/setup-php@v2"
22+
with:
23+
coverage: "none"
24+
extensions: "intl, zip"
25+
ini-values: "memory_limit=-1"
26+
php-version: "7.4"
27+
28+
- name: "Update dependencies"
29+
run: "composer update ${{ env.COMPOSER_FLAGS }}"
30+
31+
- name: Run PHPStan
32+
run: |
33+
composer require --dev phpstan/phpstan:^0.12.93 marc-mabe/php-enum-phpstan ${{ env.COMPOSER_FLAGS }}
34+
vendor/bin/phpstan analyse

.github/workflows/style-check.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Style Check"
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
env:
8+
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
9+
10+
jobs:
11+
tests:
12+
name: "Style Check"
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: "Checkout"
18+
uses: "actions/checkout@v2"
19+
20+
- name: "Install PHP"
21+
uses: "shivammathur/setup-php@v2"
22+
with:
23+
coverage: "none"
24+
extensions: "intl, zip"
25+
ini-values: "memory_limit=-1, phar.readonly=0, error_reporting=E_ALL, display_errors=On"
26+
php-version: "7.4"
27+
tools: composer
28+
29+
- name: "Update dependencies"
30+
run: "composer update ${{ env.COMPOSER_FLAGS }}"
31+
32+
- name: "Run style-check"
33+
run: "composer style-check"

.php_cs.dist renamed to .php-cs-fixer.dist.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
'phpdoc_no_package' => false,
2121
'phpdoc_order' => true,
2222
'phpdoc_summary' => false,
23-
'pre_increment' => false,
2423
'increment_style' => false,
2524
'simplified_null_return' => false,
26-
'trailing_comma_in_multiline_array' => false,
25+
'single_line_throw' => false,
26+
'trailing_comma_in_multiline' => false,
2727
'yoda_style' => false,
2828
'phpdoc_types_order' => array('null_adjustment' => 'none', 'sort_algorithm' => 'none'),
2929
'no_superfluous_phpdoc_tags' => false,

.travis.yml

-43
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JSON Schema for PHP
22

3-
[![Build Status](https://travis-ci.org/justinrainbow/json-schema.svg?branch=master)](https://travis-ci.org/justinrainbow/json-schema)
3+
[![Build Status](https://github.com/justinrainbow/json-schema/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/justinrainbow/json-schema/actions)
44
[![Latest Stable Version](https://poser.pugx.org/justinrainbow/json-schema/v/stable.png)](https://packagist.org/packages/justinrainbow/json-schema)
55
[![Total Downloads](https://poser.pugx.org/justinrainbow/json-schema/downloads.png)](https://packagist.org/packages/justinrainbow/json-schema)
66

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"icecave/parity": "1.0.0"
3333
},
3434
"require-dev": {
35-
"friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1",
35+
"friendsofphp/php-cs-fixer": "~2.2.20 || ~2.19.0",
3636
"json-schema/json-schema-test-suite": "1.2.0",
3737
"phpunit/phpunit": "^4.8.35"
3838
},

phpstan-baseline.neon

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^PHPDoc tag @throws with type JsonSchema\\\\Exception\\\\ExceptionInterface is not subtype of Throwable$#"
5+
count: 1
6+
path: src/JsonSchema/Constraints/ConstraintInterface.php
7+
8+
-
9+
message: "#^Access to an undefined property object\\:\\:\\$properties\\.$#"
10+
count: 3
11+
path: src/JsonSchema/SchemaStorage.php
12+

phpstan.neon

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
parameters:
2+
level: 2
3+
paths:
4+
- ./src/
5+
ignoreErrors: []
6+
7+
includes:
8+
- phpstan-baseline.neon
9+
- vendor/marc-mabe/php-enum-phpstan/extension.neon

src/JsonSchema/Constraints/Constraint.php

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ protected function checkArray(&$value, $schema = null, JsonPointer $path = null,
8787
protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
8888
$additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
8989
{
90+
/** @var ObjectConstraint $validator */
9091
$validator = $this->factory->createInstanceFor('object');
9192
$validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
9293

@@ -119,6 +120,7 @@ protected function checkType(&$value, $schema = null, JsonPointer $path = null,
119120
*/
120121
protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
121122
{
123+
/** @var UndefinedConstraint $validator */
122124
$validator = $this->factory->createInstanceFor('undefined');
123125

124126
$validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);

src/JsonSchema/Constraints/Factory.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public function setConstraintClass($name, $class)
185185
* @throws InvalidArgumentException if is not possible create the constraint instance
186186
*
187187
* @return ConstraintInterface|ObjectConstraint
188+
* @phpstan-return ConstraintInterface&BaseConstraint
188189
*/
189190
public function createInstanceFor($constraintName)
190191
{
@@ -202,7 +203,8 @@ public function createInstanceFor($constraintName)
202203
/**
203204
* Get the error context
204205
*
205-
* @return string
206+
* @return int
207+
* @phpstan-return Validator::ERROR_DOCUMENT_VALIDATION|Validator::ERROR_SCHEMA_VALIDATION
206208
*/
207209
public function getErrorContext()
208210
{
@@ -212,7 +214,8 @@ public function getErrorContext()
212214
/**
213215
* Set the error context
214216
*
215-
* @param string $validationContext
217+
* @param int $errorContext
218+
* @phpstan-param Validator::ERROR_DOCUMENT_VALIDATION|Validator::ERROR_SCHEMA_VALIDATION $errorContext
216219
*/
217220
public function setErrorContext($errorContext)
218221
{

src/JsonSchema/Constraints/TypeConstraint.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ public function check(&$value = null, $schema = null, JsonPointer $path = null,
8181
* of $isValid to true, if at least one $type mateches the type of $value or the value
8282
* passed as $isValid is already true.
8383
*
84-
* @param mixed $value Value to validate
85-
* @param array $type TypeConstraints to check against
86-
* @param array $validTypesWording An array of wordings of the valid types of the array $type
87-
* @param bool $isValid The current validation value
88-
* @param $path
84+
* @param mixed $value Value to validate
85+
* @param array $type TypeConstraints to check against
86+
* @param array $validTypesWording An array of wordings of the valid types of the array $type
87+
* @param bool $isValid The current validation value
88+
* @param ?JsonPointer $path
89+
* @param bool $coerce
8990
*/
9091
protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path, $coerce = false)
9192
{
@@ -239,7 +240,7 @@ protected function validateType(&$value, $type, $coerce = false)
239240
/**
240241
* Converts a value to boolean. For example, "true" becomes true.
241242
*
242-
* @param $value The value to convert to boolean
243+
* @param mixed $value The value to convert to boolean
243244
*
244245
* @return bool|mixed
245246
*/

0 commit comments

Comments
 (0)