@@ -9,6 +9,9 @@ discard block  | 
                                                    ||
| 9 | 9 | |
| 10 | 10 | abstract class BaseValidator extends SchemaValidator  | 
                                                        
| 11 | 11 |  { | 
                                                        
| 12 | + /**  | 
                                                        |
| 13 | + * @param string $basePath  | 
                                                        |
| 14 | + */  | 
                                                        |
| 12 | 15 | public function __construct($descriptor, $basePath = null)  | 
                                                        
| 13 | 16 |      { | 
                                                        
| 14 | 17 | $this->basePath = $basePath;  | 
                                                        
@@ -122,6 +125,9 @@ discard block  | 
                                                    ||
| 122 | 125 | $this->validateSchemaUrl($this->getValidationSchemaUrl());  | 
                                                        
| 123 | 126 | }  | 
                                                        
| 124 | 127 | |
| 128 | + /**  | 
                                                        |
| 129 | + * @param string $url  | 
                                                        |
| 130 | + */  | 
                                                        |
| 125 | 131 | protected function validateSchemaUrl($url)  | 
                                                        
| 126 | 132 |      { | 
                                                        
| 127 | 133 | $validator = new \JsonSchema\Validator();  | 
                                                        
@@ -141,7 +147,7 @@ discard block  | 
                                                    ||
| 141 | 147 | * Add an error to the validator object - errors are aggregated and returned by validate function.  | 
                                                        
| 142 | 148 | *  | 
                                                        
| 143 | 149 | * @param int $code  | 
                                                        
| 144 | - * @param null|mixed $extraDetails  | 
                                                        |
| 150 | + * @param string $extraDetails  | 
                                                        |
| 145 | 151 | */  | 
                                                        
| 146 | 152 | protected function addError($code, $extraDetails = null)  | 
                                                        
| 147 | 153 |      { | 
                                                        
@@ -2,7 +2,6 @@  | 
                                                    ||
| 2 | 2 | |
| 3 | 3 | namespace frictionlessdata\datapackage\Validators;  | 
                                                        
| 4 | 4 | |
| 5 | -use frictionlessdata\datapackage\Registry;  | 
                                                        |
| 6 | 5 | use frictionlessdata\datapackage\Utils;  | 
                                                        
| 7 | 6 | use frictionlessdata\tableschema\SchemaValidator;  | 
                                                        
| 8 | 7 | use frictionlessdata\tableschema\SchemaValidationError;  | 
                                                        
@@ -70,6 +70,9 @@  | 
                                                    ||
| 70 | 70 | return ResourceValidator::validate($resourceDescriptor, $this->basePath);  | 
                                                        
| 71 | 71 | }  | 
                                                        
| 72 | 72 | |
| 73 | + /**  | 
                                                        |
| 74 | + * @param string $profile  | 
                                                        |
| 75 | + */  | 
                                                        |
| 73 | 76 | protected function getJsonSchemaFileFromRegistry($profile)  | 
                                                        
| 74 | 77 |      { | 
                                                        
| 75 | 78 |          if ($filename = Registry::getJsonSchemaFile($profile)) { | 
                                                        
@@ -229,6 +229,8 @@ discard block  | 
                                                    ||
| 229 | 229 | /**  | 
                                                        
| 230 | 230 | * allows extending classes to add custom sources  | 
                                                        
| 231 | 231 | * used by unit tests to add a mock http source.  | 
                                                        
| 232 | + * @param string $source  | 
                                                        |
| 233 | + * @return string  | 
                                                        |
| 232 | 234 | */  | 
                                                        
| 233 | 235 | protected static function normalizeHttpSource($source)  | 
                                                        
| 234 | 236 |      { | 
                                                        
@@ -238,6 +240,7 @@ discard block  | 
                                                    ||
| 238 | 240 | /**  | 
                                                        
| 239 | 241 | * allows extending classes to add custom sources  | 
                                                        
| 240 | 242 | * used by unit tests to add a mock http source.  | 
                                                        
| 243 | + * @param string $source  | 
                                                        |
| 241 | 244 | */  | 
                                                        
| 242 | 245 | protected static function isHttpSource($source)  | 
                                                        
| 243 | 246 |      { | 
                                                        
@@ -251,7 +254,7 @@ discard block  | 
                                                    ||
| 251 | 254 | * - normalized basePath.  | 
                                                        
| 252 | 255 | *  | 
                                                        
| 253 | 256 | * @param $source  | 
                                                        
| 254 | - * @param $basePath  | 
                                                        |
| 257 | + * @param null|string $basePath  | 
                                                        |
| 255 | 258 | *  | 
                                                        
| 256 | 259 | * @return object  | 
                                                        
| 257 | 260 | *  | 
                                                        
@@ -326,16 +329,25 @@ discard block  | 
                                                    ||
| 326 | 329 | return (object) ['descriptor' => $descriptor, 'basePath' => $basePath];  | 
                                                        
| 327 | 330 | }  | 
                                                        
| 328 | 331 | |
| 332 | + /**  | 
                                                        |
| 333 | + * @param string $source  | 
                                                        |
| 334 | + */  | 
                                                        |
| 329 | 335 | protected static function isHttpZipSource($source)  | 
                                                        
| 330 | 336 |      { | 
                                                        
| 331 | 337 | return strtolower(substr($source, -4)) == '.zip';  | 
                                                        
| 332 | 338 | }  | 
                                                        
| 333 | 339 | |
| 340 | + /**  | 
                                                        |
| 341 | + * @param string $source  | 
                                                        |
| 342 | + */  | 
                                                        |
| 334 | 343 | protected static function isFileZipSource($source)  | 
                                                        
| 335 | 344 |      { | 
                                                        
| 336 | 345 | return strtolower(substr($source, -4)) == '.zip';  | 
                                                        
| 337 | 346 | }  | 
                                                        
| 338 | 347 | |
| 348 | + /**  | 
                                                        |
| 349 | + * @param string $source  | 
                                                        |
| 350 | + */  | 
                                                        |
| 339 | 351 | protected static function loadHttpZipSource($source)  | 
                                                        
| 340 | 352 |      { | 
                                                        
| 341 | 353 | $tempfile = tempnam(sys_get_temp_dir(), 'datapackage-php');  | 
                                                        
@@ -347,6 +359,9 @@ discard block  | 
                                                    ||
| 347 | 359 | return self::loadFileZipSource($tempfile);  | 
                                                        
| 348 | 360 | }  | 
                                                        
| 349 | 361 | |
| 362 | + /**  | 
                                                        |
| 363 | + * @param string $source  | 
                                                        |
| 364 | + */  | 
                                                        |
| 350 | 365 | protected static function loadFileZipSource($source)  | 
                                                        
| 351 | 366 |      { | 
                                                        
| 352 | 367 | $zipper = new Zipper();  | 
                                                        
@@ -342,7 +342,7 @@ discard block  | 
                                                    ||
| 342 | 342 | unlink($tempfile);  | 
                                                        
| 343 | 343 | $tempfile .= '.zip';  | 
                                                        
| 344 | 344 | stream_copy_to_stream(fopen($source, 'r'), fopen($tempfile, 'w'));  | 
                                                        
| 345 | -        register_shutdown_function(function () use ($tempfile) {unlink($tempfile); }); | 
                                                        |
| 345 | +        register_shutdown_function(function() use ($tempfile) {unlink($tempfile); }); | 
                                                        |
| 346 | 346 | |
| 347 | 347 | return self::loadFileZipSource($tempfile);  | 
                                                        
| 348 | 348 | }  | 
                                                        
@@ -353,7 +353,7 @@ discard block  | 
                                                    ||
| 353 | 353 | $tempdir = tempnam(sys_get_temp_dir(), 'datapackage-php');  | 
                                                        
| 354 | 354 | unlink($tempdir);  | 
                                                        
| 355 | 355 | mkdir($tempdir);  | 
                                                        
| 356 | -        register_shutdown_function(function () use ($tempdir) {Utils::removeDir($tempdir); }); | 
                                                        |
| 356 | +        register_shutdown_function(function() use ($tempdir) {Utils::removeDir($tempdir); }); | 
                                                        |
| 357 | 357 | /* @noinspection PhpUnhandledExceptionInspection File existence is checked afterwards anyway */  | 
                                                        
| 358 | 358 | $zipper->make($source)->extractTo($tempdir);  | 
                                                        
| 359 | 359 | $zipper->close();  |