Skip to content

Commit f0b8661

Browse files
committed
Merge pull request jsonrainbow#670 from Seldaek/gh_actions
Switch to GH Actions
1 parent 2ab6744 commit f0b8661

13 files changed

+217
-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
@@ -30,7 +30,7 @@
3030
"php": ">=5.3.3"
3131
},
3232
"require-dev": {
33-
"friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1",
33+
"friendsofphp/php-cs-fixer": "~2.2.20 || ~2.19.0",
3434
"json-schema/json-schema-test-suite": "1.2.0",
3535
"phpunit/phpunit": "^4.8.35"
3636
},

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
@@ -86,6 +86,7 @@ protected function checkArray(&$value, $schema = null, JsonPointer $path = null,
8686
protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
8787
$additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
8888
{
89+
/** @var ObjectConstraint $validator */
8990
$validator = $this->factory->createInstanceFor('object');
9091
$validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
9192

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

123125
$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
@@ -184,6 +184,7 @@ public function setConstraintClass($name, $class)
184184
* @throws InvalidArgumentException if is not possible create the constraint instance
185185
*
186186
* @return ConstraintInterface|ObjectConstraint
187+
* @phpstan-return ConstraintInterface&BaseConstraint
187188
*/
188189
public function createInstanceFor($constraintName)
189190
{
@@ -201,7 +202,8 @@ public function createInstanceFor($constraintName)
201202
/**
202203
* Get the error context
203204
*
204-
* @return string
205+
* @return int
206+
* @phpstan-return Validator::ERROR_DOCUMENT_VALIDATION|Validator::ERROR_SCHEMA_VALIDATION
205207
*/
206208
public function getErrorContext()
207209
{
@@ -211,7 +213,8 @@ public function getErrorContext()
211213
/**
212214
* Set the error context
213215
*
214-
* @param string $validationContext
216+
* @param int $errorContext
217+
* @phpstan-param Validator::ERROR_DOCUMENT_VALIDATION|Validator::ERROR_SCHEMA_VALIDATION $errorContext
215218
*/
216219
public function setErrorContext($errorContext)
217220
{

src/JsonSchema/Constraints/TypeConstraint.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ public function check(&$value = null, $schema = null, JsonPointer $path = null,
7070
* of $isValid to true, if at least one $type mateches the type of $value or the value
7171
* passed as $isValid is already true.
7272
*
73-
* @param mixed $value Value to validate
74-
* @param array $type TypeConstraints to check agains
75-
* @param array $validTypesWording An array of wordings of the valid types of the array $type
76-
* @param bool $isValid The current validation value
77-
* @param $path
73+
* @param mixed $value Value to validate
74+
* @param array $type TypeConstraints to check against
75+
* @param array $validTypesWording An array of wordings of the valid types of the array $type
76+
* @param bool $isValid The current validation value
77+
* @param ?JsonPointer $path
7878
*/
7979
protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
8080
{
@@ -217,7 +217,7 @@ protected function validateType(&$value, $type)
217217
/**
218218
* Converts a value to boolean. For example, "true" becomes true.
219219
*
220-
* @param $value The value to convert to boolean
220+
* @param mixed $value The value to convert to boolean
221221
*
222222
* @return bool|mixed
223223
*/

0 commit comments

Comments
 (0)