Skip to content

Commit 246773e

Browse files
committed
cleanup
1 parent 89ec866 commit 246773e

File tree

8 files changed

+17
-11
lines changed

8 files changed

+17
-11
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: php
22
php:
33
- nightly
44
- hhvm
5+
- 7.1
56
- 7.0
67
- 5.6
78
- 5.5
@@ -29,6 +30,7 @@ script:
2930
- ./vendor/bin/phpunit -v --configuration phpunit.xml --coverage-clover build/logs/clover.xml
3031

3132
after_script:
32-
- php vendor/bin/coveralls -v
3333
- wget https://scrutinizer-ci.com/ocular.phar
3434
- php ocular.phar code-coverage:upload --format=php-clover build/logs/coverage.clover
35+
- if [[ $(phpenv version-name) =~ 7.0 ]] ; then php vendor/bin/coveralls -v; fi
36+
- if [[ $(phpenv version-name) =~ 7.0 ]] ; then ./vendor/bin/test-reporter; fi

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Swaggest JSON-schema implementation for PHP
22

33
[![Build Status](https://travis-ci.org/swaggest/php-json-schema.svg?branch=master)](https://travis-ci.org/swaggest/php-json-schema)
4-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/swaggest/php-json-schema/badges/quality-score.png?b=spec-compliance)](https://scrutinizer-ci.com/g/swaggest/php-json-schema/?branch=spec-compliance)
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/swaggest/php-json-schema/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/swaggest/php-json-schema/?branch=master)
55
[![Code Climate](https://codeclimate.com/github/swaggest/php-json-schema/badges/gpa.svg)](https://codeclimate.com/github/swaggest/php-json-schema)
66
[![Test Coverage](https://codeclimate.com/github/swaggest/php-json-schema/badges/coverage.svg)](https://codeclimate.com/github/swaggest/php-json-schema/coverage)
77

src/Helper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public static function resolveURI($parent, $current)
4545
if (false !== $pos = strpos($parent, '#')) {
4646
$result = substr($parent, 0, $pos) . $current;
4747
}
48-
} elseif ($current[0] === '/') {
4948
} else {
5049
if (false !== $pos = strrpos($parent, '/')) {
5150
$result = substr($parent, 0, $pos + 1) . $current;

src/MagicMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function &toArray()
5252
return $this->_arrayOfData;
5353
}
5454

55-
function jsonSerialize()
55+
public function jsonSerialize()
5656
{
5757
return (object)$this->_arrayOfData;
5858
}

src/Schema.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ private function process($data, $import = true, $path = '#')
141141
try {
142142
$this->not->process($data, $import, $path . '->not');
143143
} catch (InvalidValue $exception) {
144+
// Expected exception
144145
}
145146
if ($exception === false) {
146147
$this->fail(new LogicException('Failed due to logical constraint: not'), $path);
@@ -157,6 +158,7 @@ private function process($data, $import = true, $path = '#')
157158
break;
158159
}
159160
} catch (InvalidValue $exception) {
161+
// Expected exception
160162
}
161163
}
162164
if ($successes !== 1) {
@@ -174,6 +176,7 @@ private function process($data, $import = true, $path = '#')
174176
break;
175177
}
176178
} catch (InvalidValue $exception) {
179+
// Expected exception
177180
}
178181
}
179182
if (!$successes) {
@@ -269,6 +272,7 @@ private function process($data, $import = true, $path = '#')
269272
if ($result instanceof ClassStructure) {
270273
if ($result->__validateOnSet) {
271274
$result->__validateOnSet = false;
275+
/** @noinspection PhpUnusedLocalVariableInspection */
272276
$validateOnSetHandler = new ScopeExit(function()use($result){
273277
$result->__validateOnSet = true;
274278
});
@@ -352,7 +356,7 @@ private function process($data, $import = true, $path = '#')
352356
$pathItems = 'additionalItems';
353357
}
354358

355-
if ($items || $additionalItems !== null) {
359+
if ($items !== null || $additionalItems !== null) {
356360
$itemsLen = is_array($items) ? count($items) : 0;
357361
$index = 0;
358362
foreach ($data as &$value) {

src/SchemaLoader.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function readSchema($schemaData)
8282

8383
private $resolutionScope;
8484

85-
protected function readSchemaDeeper($schemaArray, Schema $parentSchema = null)
85+
protected function readSchemaDeeper($schemaArray)
8686
{
8787
$schema = new Schema();
8888
if (null === $this->rootSchema) {
@@ -97,6 +97,7 @@ protected function readSchemaDeeper($schemaArray, Schema $parentSchema = null)
9797
if (isset($schemaArray[self::ID])) {
9898
$parentScope = $this->resolutionScope;
9999
$this->resolutionScope = Helper::resolveURI($parentScope, $schemaArray[self::ID]);
100+
/** @noinspection PhpUnusedLocalVariableInspection */
100101
$defer = new ScopeExit(function () use ($parentScope) {
101102
$this->resolutionScope = $parentScope;
102103
});
@@ -270,7 +271,7 @@ private function resolveReference($referencePath)
270271
} else {
271272
$path = explode('/', trim($referencePath, '#/'));
272273
$branch = &$this->rootData;
273-
while ($path) {
274+
while (!empty($path)) {
274275
$folder = array_shift($path);
275276

276277
// unescaping special characters
@@ -309,7 +310,7 @@ private function resolveReference($referencePath)
309310
/**
310311
* @return static
311312
*/
312-
static function create()
313+
public static function create()
313314
{
314315
return new static;
315316
}

src/Structure/ClassStructure.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public static function schema()
3737
*/
3838
public static function import($data)
3939
{
40-
//static $schemas = array();
4140
return static::schema()->import($data);
4241
}
4342

@@ -54,7 +53,7 @@ public static function export($data)
5453
/**
5554
* @return static
5655
*/
57-
static function create()
56+
public static function create()
5857
{
5958
return new static;
6059
}

src/TODO.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
* avoid `(array)` cast in `SchemaLoader`, getaway from `const` fields?
44
* process string formats
55
* test against optional json-schema cases
6-
* all-errors at once mode (apart of throw Exception)
6+
* all-errors at once mode (apart of throw Exception)
7+
* add general purpose mixins

0 commit comments

Comments
 (0)