jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/392195 )

Change subject: Update justinrainbow/json-schema from 5.2.1 to 5.2.6
......................................................................


Update justinrainbow/json-schema from 5.2.1 to 5.2.6

https://github.com/justinrainbow/json-schema/compare/5.2.1...5.2.6

Change-Id: Ib80fdb34dafd394aafc5a2dca29e9f2e21dce8a5
---
M composer.json
M composer.lock
M composer/installed.json
M justinrainbow/json-schema/.php_cs.dist
M justinrainbow/json-schema/composer.json
M justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.php
M justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php
M justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php
M justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php
M justinrainbow/json-schema/src/JsonSchema/Validator.php
10 files changed, 151 insertions(+), 99 deletions(-)

Approvals:
  Addshore: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/composer.json b/composer.json
index 991f7ff..d90bc77 100644
--- a/composer.json
+++ b/composer.json
@@ -76,7 +76,7 @@
                "jakub-onderka/php-console-color": "0.1",
                "jakub-onderka/php-console-highlighter": "0.3.2",
                "james-heinrich/getid3": "1.9.14",
-               "justinrainbow/json-schema": "5.2.1",
+               "justinrainbow/json-schema": "5.2.6",
                "liuggio/statsd-php-client": "1.0.18",
                "mediawiki/at-ease": "1.1.0",
                "monolog/monolog": "1.22.1",
diff --git a/composer.lock b/composer.lock
index 3694cd5..7a7e842 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at 
https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";,
         "This file is @generated automatically"
     ],
-    "content-hash": "cba071edb8024cd7762bf3941e215a80",
+    "content-hash": "27b864cad3750d7557cd5dae84899c82",
     "packages": [
         {
             "name": "composer/semver",
@@ -863,16 +863,16 @@
         },
         {
             "name": "justinrainbow/json-schema",
-            "version": "5.2.1",
+            "version": "5.2.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/justinrainbow/json-schema.git";,
-                "reference": "429be236f296ca249d61c65649cdf2652f4a5e80"
+                "reference": "d283e11b6e14c6f4664cf080415c4341293e5bbd"
             },
             "dist": {
                 "type": "zip",
-                "url": 
"https://api.github.com/repos/justinrainbow/json-schema/zipball/429be236f296ca249d61c65649cdf2652f4a5e80";,
-                "reference": "429be236f296ca249d61c65649cdf2652f4a5e80",
+                "url": 
"https://api.github.com/repos/justinrainbow/json-schema/zipball/d283e11b6e14c6f4664cf080415c4341293e5bbd";,
+                "reference": "d283e11b6e14c6f4664cf080415c4341293e5bbd",
                 "shasum": ""
             },
             "require": {
@@ -881,7 +881,6 @@
             "require-dev": {
                 "friendsofphp/php-cs-fixer": "^2.1",
                 "json-schema/json-schema-test-suite": "1.2.0",
-                "phpdocumentor/phpdocumentor": "^2.7",
                 "phpunit/phpunit": "^4.8.22"
             },
             "bin": [
@@ -926,7 +925,7 @@
                 "json",
                 "schema"
             ],
-            "time": "2017-05-16T21:06:09+00:00"
+            "time": "2017-10-21T13:15:38+00:00"
         },
         {
             "name": "liuggio/statsd-php-client",
diff --git a/composer/installed.json b/composer/installed.json
index 5b8ec72..10d56f4 100644
--- a/composer/installed.json
+++ b/composer/installed.json
@@ -2050,75 +2050,6 @@
         "description": "Composer plugin to merge multiple composer.json files"
     },
     {
-        "name": "justinrainbow/json-schema",
-        "version": "5.2.1",
-        "version_normalized": "5.2.1.0",
-        "source": {
-            "type": "git",
-            "url": "https://github.com/justinrainbow/json-schema.git";,
-            "reference": "429be236f296ca249d61c65649cdf2652f4a5e80"
-        },
-        "dist": {
-            "type": "zip",
-            "url": 
"https://api.github.com/repos/justinrainbow/json-schema/zipball/429be236f296ca249d61c65649cdf2652f4a5e80";,
-            "reference": "429be236f296ca249d61c65649cdf2652f4a5e80",
-            "shasum": ""
-        },
-        "require": {
-            "php": ">=5.3.3"
-        },
-        "require-dev": {
-            "friendsofphp/php-cs-fixer": "^2.1",
-            "json-schema/json-schema-test-suite": "1.2.0",
-            "phpdocumentor/phpdocumentor": "^2.7",
-            "phpunit/phpunit": "^4.8.22"
-        },
-        "time": "2017-05-16T21:06:09+00:00",
-        "bin": [
-            "bin/validate-json"
-        ],
-        "type": "library",
-        "extra": {
-            "branch-alias": {
-                "dev-master": "5.0.x-dev"
-            }
-        },
-        "installation-source": "dist",
-        "autoload": {
-            "psr-4": {
-                "JsonSchema\\": "src/JsonSchema/"
-            }
-        },
-        "notification-url": "https://packagist.org/downloads/";,
-        "license": [
-            "MIT"
-        ],
-        "authors": [
-            {
-                "name": "Bruno Prieto Reis",
-                "email": "[email protected]"
-            },
-            {
-                "name": "Justin Rainbow",
-                "email": "[email protected]"
-            },
-            {
-                "name": "Igor Wiedler",
-                "email": "[email protected]"
-            },
-            {
-                "name": "Robert Schönthal",
-                "email": "[email protected]"
-            }
-        ],
-        "description": "A library to validate a json schema.",
-        "homepage": "https://github.com/justinrainbow/json-schema";,
-        "keywords": [
-            "json",
-            "schema"
-        ]
-    },
-    {
         "name": "wikimedia/relpath",
         "version": "2.0.0",
         "version_normalized": "2.0.0.0",
@@ -3835,5 +3766,73 @@
             "debug",
             "dump"
         ]
+    },
+    {
+        "name": "justinrainbow/json-schema",
+        "version": "5.2.6",
+        "version_normalized": "5.2.6.0",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/justinrainbow/json-schema.git";,
+            "reference": "d283e11b6e14c6f4664cf080415c4341293e5bbd"
+        },
+        "dist": {
+            "type": "zip",
+            "url": 
"https://api.github.com/repos/justinrainbow/json-schema/zipball/d283e11b6e14c6f4664cf080415c4341293e5bbd";,
+            "reference": "d283e11b6e14c6f4664cf080415c4341293e5bbd",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.3"
+        },
+        "require-dev": {
+            "friendsofphp/php-cs-fixer": "^2.1",
+            "json-schema/json-schema-test-suite": "1.2.0",
+            "phpunit/phpunit": "^4.8.22"
+        },
+        "time": "2017-10-21T13:15:38+00:00",
+        "bin": [
+            "bin/validate-json"
+        ],
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "5.0.x-dev"
+            }
+        },
+        "installation-source": "dist",
+        "autoload": {
+            "psr-4": {
+                "JsonSchema\\": "src/JsonSchema/"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/";,
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Bruno Prieto Reis",
+                "email": "[email protected]"
+            },
+            {
+                "name": "Justin Rainbow",
+                "email": "[email protected]"
+            },
+            {
+                "name": "Igor Wiedler",
+                "email": "[email protected]"
+            },
+            {
+                "name": "Robert Schönthal",
+                "email": "[email protected]"
+            }
+        ],
+        "description": "A library to validate a json schema.",
+        "homepage": "https://github.com/justinrainbow/json-schema";,
+        "keywords": [
+            "json",
+            "schema"
+        ]
     }
 ]
diff --git a/justinrainbow/json-schema/.php_cs.dist 
b/justinrainbow/json-schema/.php_cs.dist
index 9b7f040..6b7d9b9 100644
--- a/justinrainbow/json-schema/.php_cs.dist
+++ b/justinrainbow/json-schema/.php_cs.dist
@@ -11,6 +11,7 @@
         '@PSR2' => true,
         '@Symfony' => true,
         // additionally
+        'align_multiline_comment' => array('comment_type' => 'phpdocs_like'),
         'array_syntax' => array('syntax' => 'long'),
         'binary_operator_spaces' => false,
         'concat_space' => array('spacing' => 'one'),
@@ -24,6 +25,7 @@
         'pre_increment' => false,
         'trailing_comma_in_multiline_array' => false,
         'simplified_null_return' => false,
+        'yoda_style' => null,
     ))
     ->setFinder($finder)
 ;
diff --git a/justinrainbow/json-schema/composer.json 
b/justinrainbow/json-schema/composer.json
index 3e26b0f..009c148 100644
--- a/justinrainbow/json-schema/composer.json
+++ b/justinrainbow/json-schema/composer.json
@@ -40,9 +40,8 @@
     },
     "require-dev": {
         "json-schema/JSON-Schema-Test-Suite": "1.2.0",
-        "phpunit/phpunit": "^4.8.22",
         "friendsofphp/php-cs-fixer": "^2.1",
-        "phpdocumentor/phpdocumentor": "^2.7"
+        "phpunit/phpunit": "^4.8.22"
     },
     "autoload": {
         "psr-4": { "JsonSchema\\": "src/JsonSchema/" }
diff --git 
a/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.php 
b/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.php
index 3c594b3..49841a4 100644
--- 
a/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.php
+++ 
b/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.php
@@ -85,8 +85,8 @@
 
                     $validator->check($v, $schema->items, $k_path, $i);
                 }
-                unset($v); // remove dangling reference to prevent any future 
bugs
-                           // caused by accidentally using $v elsewhere
+                unset($v); /* remove dangling reference to prevent any future 
bugs
+                            * caused by accidentally using $v elsewhere */
                 $this->addErrors($typeValidator->getErrors());
                 $this->addErrors($validator->getErrors());
             } else {
@@ -109,8 +109,8 @@
                         $this->errors = $initErrors;
                     }
                 }
-                unset($v); // remove dangling reference to prevent any future 
bugs
-                           // caused by accidentally using $v elsewhere
+                unset($v); /* remove dangling reference to prevent any future 
bugs
+                            * caused by accidentally using $v elsewhere */
             }
         } else {
             // Defined item type definitions
@@ -132,8 +132,8 @@
                     }
                 }
             }
-            unset($v); // remove dangling reference to prevent any future bugs
-                       // caused by accidentally using $v elsewhere
+            unset($v); /* remove dangling reference to prevent any future bugs
+                        * caused by accidentally using $v elsewhere */
 
             // Treat when we have more schema definitions than values, not for 
empty arrays
             if (count($value) > 0) {
diff --git 
a/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php 
b/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php
index a86afca..c0606ff 100644
--- 
a/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php
+++ 
b/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php
@@ -142,7 +142,13 @@
             } elseif (isset($schema->required) && 
!is_array($schema->required)) {
                 // Draft 3 - Required attribute - e.g. "foo": {"type": 
"string", "required": true}
                 if ($schema->required && $value instanceof self) {
-                    $this->addError($path, 'Is missing and it is required', 
'required');
+                    $propertyPaths = $path->getPropertyPaths();
+                    $propertyName = end($propertyPaths);
+                    $this->addError(
+                        $path,
+                        'The property ' . $propertyName . ' is required',
+                        'required'
+                    );
                 }
             }
         }
diff --git a/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php 
b/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php
index 9a1caeb..31da668 100644
--- a/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php
+++ b/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php
@@ -5,13 +5,12 @@
 use JsonSchema\Constraints\BaseConstraint;
 use JsonSchema\Entity\JsonPointer;
 use JsonSchema\Exception\UnresolvableJsonPointerException;
-use JsonSchema\Iterator\ObjectIterator;
 use JsonSchema\Uri\UriResolver;
 use JsonSchema\Uri\UriRetriever;
 
 class SchemaStorage implements SchemaStorageInterface
 {
-    const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema';
+    const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
 
     protected $uriRetriever;
     protected $uriResolver;
@@ -69,17 +68,45 @@
             }
         }
 
-        $objectIterator = new ObjectIterator($schema);
-        foreach ($objectIterator as $toResolveSchema) {
-            if (property_exists($toResolveSchema, '$ref') && 
is_string($toResolveSchema->{'$ref'})) {
-                $jsonPointer = new 
JsonPointer($this->uriResolver->resolve($toResolveSchema->{'$ref'}, $id));
-                $toResolveSchema->{'$ref'} = (string) $jsonPointer;
-            }
-        }
+        // resolve references
+        $this->expandRefs($schema, $id);
+
         $this->schemas[$id] = $schema;
     }
 
     /**
+     * Recursively resolve all references against the provided base
+     *
+     * @param mixed  $schema
+     * @param string $base
+     */
+    private function expandRefs(&$schema, $base = null)
+    {
+        if (!is_object($schema)) {
+            if (is_array($schema)) {
+                foreach ($schema as &$member) {
+                    $this->expandRefs($member, $base);
+                }
+            }
+
+            return;
+        }
+
+        if (property_exists($schema, 'id') && is_string($schema->id) && $base 
!= $schema->id) {
+            $base = $this->uriResolver->resolve($schema->id, $base);
+        }
+
+        if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
+            $refPointer = new 
JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
+            $schema->{'$ref'} = (string) $refPointer;
+        }
+
+        foreach ($schema as &$member) {
+            $this->expandRefs($member, $base);
+        }
+    }
+
+    /**
      * {@inheritdoc}
      */
     public function getSchema($id)
diff --git a/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php 
b/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php
index 7d6e793..8ab6650 100644
--- a/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php
+++ b/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php
@@ -61,8 +61,8 @@
              . $components['authority']
              . $components['path'];
 
-        if (array_key_exists('query', $components)) {
-            $uri .= $components['query'];
+        if (array_key_exists('query', $components) && 
strlen($components['query'])) {
+            $uri .= '?' . $components['query'];
         }
         if (array_key_exists('fragment', $components)) {
             $uri .= '#' . $components['fragment'];
@@ -76,6 +76,21 @@
      */
     public function resolve($uri, $baseUri = null)
     {
+        // treat non-uri base as local file path
+        if (
+            !is_null($baseUri) &&
+            !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
+            !preg_match('|^[^/]+://|u', $baseUri)
+        ) {
+            if (is_file($baseUri)) {
+                $baseUri = 'file://' . realpath($baseUri);
+            } elseif (is_dir($baseUri)) {
+                $baseUri = 'file://' . realpath($baseUri) . '/';
+            } else {
+                $baseUri = 'file://' . getcwd() . '/' . $baseUri;
+            }
+        }
+
         if ($uri == '') {
             return $baseUri;
         }
diff --git a/justinrainbow/json-schema/src/JsonSchema/Validator.php 
b/justinrainbow/json-schema/src/JsonSchema/Validator.php
index 7b6a807..0e3b470 100644
--- a/justinrainbow/json-schema/src/JsonSchema/Validator.php
+++ b/justinrainbow/json-schema/src/JsonSchema/Validator.php
@@ -54,12 +54,17 @@
         }
 
         // add provided schema to SchemaStorage with internal URI to allow 
internal $ref resolution
-        
$this->factory->getSchemaStorage()->addSchema(SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI,
 $schema);
+        if (is_object($schema) && property_exists($schema, 'id')) {
+            $schemaURI = $schema->id;
+        } else {
+            $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
+        }
+        $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
 
         $validator = $this->factory->createInstanceFor('schema');
         $validator->check(
             $value,
-            
$this->factory->getSchemaStorage()->getSchema(SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI)
+            $this->factory->getSchemaStorage()->getSchema($schemaURI)
         );
 
         $this->factory->setConfig($initialCheckMode);

-- 
To view, visit https://gerrit.wikimedia.org/r/392195
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib80fdb34dafd394aafc5a2dca29e9f2e21dce8a5
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/vendor
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to