Skip to content

Commit c329ebd

Browse files
committed
Add basic phpstan level 1 config/ci
1 parent 6f9052e commit c329ebd

File tree

4 files changed

+59
-17
lines changed

4 files changed

+59
-17
lines changed

.github/workflows/phpstan.yml

Lines changed: 34 additions & 0 deletions
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

phpstan.neon

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

src/JsonSchema/Constraints/BaseConstraint.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,21 @@ public static function jsonPatternToPhpRegex($pattern)
165165
{
166166
return '~' . str_replace('~', '\\~', $pattern) . '~u';
167167
}
168+
169+
/**
170+
* @param JsonPointer $pointer
171+
*
172+
* @return string property path
173+
*/
174+
protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
175+
{
176+
$result = array_map(
177+
function ($path) {
178+
return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
179+
},
180+
$pointer->getPropertyPaths()
181+
);
182+
183+
return trim(implode('', $result), '.');
184+
}
168185
}

src/JsonSchema/Constraints/Constraint.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,4 @@ protected function getTypeCheck()
215215
{
216216
return $this->factory->getTypeCheck();
217217
}
218-
219-
/**
220-
* @param JsonPointer $pointer
221-
*
222-
* @return string property path
223-
*/
224-
protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
225-
{
226-
$result = array_map(
227-
function ($path) {
228-
return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
229-
},
230-
$pointer->getPropertyPaths()
231-
);
232-
233-
return trim(implode('', $result), '.');
234-
}
235218
}

0 commit comments

Comments
 (0)