@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class InMemoryFileSystem implements FileSystemInterface |
| 17 | 17 | { |
| 18 | - private $fileSystem = []; |
|
| 18 | + private $fileSystem = [ ]; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @param string $filePath |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function write($filePath, $contents) |
| 25 | 25 | { |
| 26 | - $this->fileSystem[$filePath] = $contents; |
|
| 26 | + $this->fileSystem[ $filePath ] = $contents; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -33,6 +33,6 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function get($filePath) |
| 35 | 35 | { |
| 36 | - return $this->fileSystem[$filePath]; |
|
| 36 | + return $this->fileSystem[ $filePath ]; |
|
| 37 | 37 | } |
| 38 | 38 | } |
@@ -21,16 +21,16 @@ discard block |
||
| 21 | 21 | public function write(SchemaRdfaData $schemaData) |
| 22 | 22 | { |
| 23 | 23 | foreach ($schemaData->getProperties() as $property) { |
| 24 | - $className = $property['name']; |
|
| 25 | - $className[0] = strtoupper($className[0]); |
|
| 24 | + $className = $property[ 'name' ]; |
|
| 25 | + $className[ 0 ] = strtoupper($className[ 0 ]); |
|
| 26 | 26 | |
| 27 | - $allowed = []; |
|
| 28 | - foreach ($property['usedOnClass'] as $belongs) { |
|
| 27 | + $allowed = [ ]; |
|
| 28 | + foreach ($property[ 'usedOnClass' ] as $belongs) { |
|
| 29 | 29 | if ('Type' === substr($belongs, -4)) { |
| 30 | 30 | $belongs = substr($belongs, 0, -4); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - $allowed[] = "\t\t'".'http://schema.org/'.$belongs."'"; |
|
| 33 | + $allowed[ ] = "\t\t'".'http://schema.org/'.$belongs."'"; |
|
| 34 | 34 | } |
| 35 | 35 | $allowed = implode(",\n", $allowed); |
| 36 | 36 | |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | use NilPortugues\SchemaOrg\SchemaProperty; |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * {$property['doc']} |
|
| 53 | + * {$property[ 'doc' ]} |
|
| 54 | 54 | */ |
| 55 | 55 | class {$className}Property extends SchemaProperty |
| 56 | 56 | { |
| 57 | - const SCHEMA_URL = "{$property['url']}"; |
|
| 58 | - const PROPERTY_NAME = "{$property['name']}"; |
|
| 57 | + const SCHEMA_URL = "{$property[ 'url' ]}"; |
|
| 58 | + const PROPERTY_NAME = "{$property[ 'name' ]}"; |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * A list of schemas allowed to use this property. |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | foreach ($schemaData->getClassesWithPropertyNames() as $class) { |
| 24 | 24 | $className = $class->name; |
| 25 | - $methods = []; |
|
| 25 | + $methods = [ ]; |
|
| 26 | 26 | |
| 27 | 27 | if (!empty($class->properties)) { |
| 28 | 28 | foreach ($class->properties as $property) { |
| 29 | - $propertyName = $property['name']; |
|
| 29 | + $propertyName = $property[ 'name' ]; |
|
| 30 | 30 | $propertyNameMethodName = $propertyName; |
| 31 | - $propertyNameMethodName[0] = strtoupper($propertyNameMethodName[0]); |
|
| 31 | + $propertyNameMethodName[ 0 ] = strtoupper($propertyNameMethodName[ 0 ]); |
|
| 32 | 32 | |
| 33 | - if (empty($usableProperties[$propertyNameMethodName])) { |
|
| 34 | - $methods[$propertyName] = <<<PHP |
|
| 33 | + if (empty($usableProperties[ $propertyNameMethodName ])) { |
|
| 34 | + $methods[ $propertyName ] = <<<PHP |
|
| 35 | 35 | public function test{$propertyNameMethodName}WillReturnMappingObject() |
| 36 | 36 | { |
| 37 | 37 | \$this->assertInstanceOf(Mapping::class, {$className}::{$propertyName}()); |
@@ -59,18 +59,18 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | namespace NilPortugues\Tests\SchemaOrg\Classes; |
| 61 | 61 | |
| 62 | -use NilPortugues\\SchemaOrg\\Classes\\{$schemaData['name']}; |
|
| 62 | +use NilPortugues\\SchemaOrg\\Classes\\{$schemaData[ 'name' ]}; |
|
| 63 | 63 | use NilPortugues\\SchemaOrg\\Mapping; |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * Classes {$schemaData['name']}Test |
|
| 66 | + * Classes {$schemaData[ 'name' ]}Test |
|
| 67 | 67 | * @package NilPortugues\\Tests\\SchemaOrg\\Classes |
| 68 | 68 | */ |
| 69 | -class {$schemaData['name']}Test extends \PHPUnit_Framework_TestCase |
|
| 69 | +class {$schemaData[ 'name' ]}Test extends \PHPUnit_Framework_TestCase |
|
| 70 | 70 | { |
| 71 | 71 | public function testSchemaUrlReturnsExpectedUrl() |
| 72 | 72 | { |
| 73 | - \$this->assertEquals({$schemaData['name']}::schemaUrl(), "{$schemaData['url']}"); |
|
| 73 | + \$this->assertEquals({$schemaData[ 'name' ]}::schemaUrl(), "{$schemaData[ 'url' ]}"); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $methods |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | /** |
| 668 | 668 | * @var array |
| 669 | 669 | */ |
| 670 | - private static $instances = []; |
|
| 670 | + private static $instances = [ ]; |
|
| 671 | 671 | |
| 672 | 672 | /** |
| 673 | 673 | * @param $method |
@@ -680,15 +680,15 @@ discard block |
||
| 680 | 680 | public function __call($method, $args) |
| 681 | 681 | { |
| 682 | 682 | $name = $method; |
| 683 | - $name[0] = strtoupper($name[0]); |
|
| 683 | + $name[ 0 ] = strtoupper($name[ 0 ]); |
|
| 684 | 684 | |
| 685 | 685 | if (class_exists('NilPortugues\\SchemaOrg\\Classes\\'.$name, true)) { |
| 686 | - if (empty(self::$instances[$name])) { |
|
| 686 | + if (empty(self::$instances[ $name ])) { |
|
| 687 | 687 | $class = 'NilPortugues\\SchemaOrg\\Classes\\'.$name; |
| 688 | - self::$instances[$name] = new $class(); |
|
| 688 | + self::$instances[ $name ] = new $class(); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - return self::$instances[$name]; |
|
| 691 | + return self::$instances[ $name ]; |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | throw new RuntimeException(sprintf('Method %s does not exist.', $name)); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @var array |
| 20 | 20 | */ |
| 21 | - private static $instances = []; |
|
| 21 | + private static $instances = [ ]; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @param string $schemaClass |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | public static function create($schemaClass, $propertyName, $propertyUrl) |
| 31 | 31 | { |
| 32 | 32 | $key = md5(implode('.', func_get_args())); |
| 33 | - if (empty(self::$instances[$key])) { |
|
| 34 | - self::$instances[$key] = new Mapping($schemaClass, $propertyName, $propertyUrl); |
|
| 33 | + if (empty(self::$instances[ $key ])) { |
|
| 34 | + self::$instances[ $key ] = new Mapping($schemaClass, $propertyName, $propertyUrl); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - return self::$instances[$key]; |
|
| 37 | + return self::$instances[ $key ]; |
|
| 38 | 38 | } |
| 39 | 39 | } |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @var array |
| 17 | 17 | */ |
| 18 | - private $classes = []; |
|
| 18 | + private $classes = [ ]; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @var array |
| 22 | 22 | */ |
| 23 | - private $properties = []; |
|
| 23 | + private $properties = [ ]; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @var bool |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $label = $this->renameIfPhpReservedWord(trim($label)); |
| 51 | 51 | |
| 52 | - $this->classes[$label] = (object) [ |
|
| 52 | + $this->classes[ $label ] = (object) [ |
|
| 53 | 53 | 'name' => $label, |
| 54 | 54 | 'doc' => $classComment, |
| 55 | 55 | 'url' => $classUrl, |
| 56 | - 'properties' => [], |
|
| 57 | - 'subClassOf' => array_map([$this, 'renameIfPhpReservedWord'], array_filter($subClassOf)), |
|
| 56 | + 'properties' => [ ], |
|
| 57 | + 'subClassOf' => array_map([ $this, 'renameIfPhpReservedWord' ], array_filter($subClassOf)), |
|
| 58 | 58 | ]; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function addDataType($classUrl, $label, $classComment) |
| 67 | 67 | { |
| 68 | - $this->addClass($classUrl, $label, $classComment, [], []); |
|
| 68 | + $this->addClass($classUrl, $label, $classComment, [ ], [ ]); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | $label = $this->renameIfPhpReservedWord(trim($label)); |
| 81 | 81 | |
| 82 | - $this->properties[$label] = [ |
|
| 82 | + $this->properties[ $label ] = [ |
|
| 83 | 83 | 'name' => $label, |
| 84 | 84 | 'doc' => $propertyComment, |
| 85 | 85 | 'url' => $propertyUrl, |
| 86 | - 'usedOnClass' => array_map([$this, 'renameIfPhpReservedWord'], array_filter($mainClass)), |
|
| 87 | - 'expectedType' => array_map([$this, 'renameIfPhpReservedWord'], array_filter($expectedType)), |
|
| 86 | + 'usedOnClass' => array_map([ $this, 'renameIfPhpReservedWord' ], array_filter($mainClass)), |
|
| 87 | + 'expectedType' => array_map([ $this, 'renameIfPhpReservedWord' ], array_filter($expectedType)), |
|
| 88 | 88 | ]; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -206,15 +206,15 @@ discard block |
||
| 206 | 206 | foreach ($result as &$resultingClass) { |
| 207 | 207 | if (!empty($resultingClass->subClassOf)) { |
| 208 | 208 | foreach ($resultingClass->subClassOf as &$class) { |
| 209 | - $class = $result[$class]; |
|
| 209 | + $class = $result[ $class ]; |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | //Add the properties |
| 215 | 215 | foreach ($this->properties as $propertyName => $propertyStructure) { |
| 216 | - foreach ($propertyStructure['usedOnClass'] as $class) { |
|
| 217 | - $result[$class]->properties[$propertyName] = ['name' => $propertyName, 'parent' => $class]; |
|
| 216 | + foreach ($propertyStructure[ 'usedOnClass' ] as $class) { |
|
| 217 | + $result[ $class ]->properties[ $propertyName ] = [ 'name' => $propertyName, 'parent' => $class ]; |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
@@ -22,35 +22,35 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | foreach ($schemaData->getClassesWithPropertyNames() as $class) { |
| 24 | 24 | $className = $class->name; |
| 25 | - $methods = []; |
|
| 26 | - $usableProperties = []; |
|
| 27 | - $dynamicCall = []; |
|
| 28 | - $useProperties = []; |
|
| 25 | + $methods = [ ]; |
|
| 26 | + $usableProperties = [ ]; |
|
| 27 | + $dynamicCall = [ ]; |
|
| 28 | + $useProperties = [ ]; |
|
| 29 | 29 | |
| 30 | 30 | if (!empty($class->properties)) { |
| 31 | 31 | foreach ($class->properties as $propertyClassName => $property) { |
| 32 | - $propertyName = $property['name']; |
|
| 33 | - $parentClassName = $property['parent']; |
|
| 32 | + $propertyName = $property[ 'name' ]; |
|
| 33 | + $parentClassName = $property[ 'parent' ]; |
|
| 34 | 34 | $propertyNameMethodName = $propertyName; |
| 35 | - $propertyNameMethodName[0] = strtoupper($propertyNameMethodName[0]); |
|
| 35 | + $propertyNameMethodName[ 0 ] = strtoupper($propertyNameMethodName[ 0 ]); |
|
| 36 | 36 | |
| 37 | - $dynamicCall[] = ' * @method static \\NilPortugues\\SchemaOrg\\Properties\\'.$propertyNameMethodName.'Property '.$propertyName.'()'; |
|
| 37 | + $dynamicCall[ ] = ' * @method static \\NilPortugues\\SchemaOrg\\Properties\\'.$propertyNameMethodName.'Property '.$propertyName.'()'; |
|
| 38 | 38 | |
| 39 | - if (empty($usableProperties[$propertyNameMethodName])) { |
|
| 40 | - $usableProperties[$propertyNameMethodName] = $propertyClassName; |
|
| 39 | + if (empty($usableProperties[ $propertyNameMethodName ])) { |
|
| 40 | + $usableProperties[ $propertyNameMethodName ] = $propertyClassName; |
|
| 41 | 41 | |
| 42 | 42 | $schemaClass = '\\NilPortugues\\SchemaOrg\\Classes\\'.$className; |
| 43 | 43 | if ($parentClassName !== $className) { |
| 44 | 44 | $schemaClass = '\\NilPortugues\\SchemaOrg\\Classes\\'.$parentClassName; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $methods[$propertyName] = "\t\t'{$propertyName}' => [\n\t\t\t'propertyClass' => '\\NilPortugues\\SchemaOrg\\Properties\\{$propertyNameMethodName}Property',\n\t\t\t'schemaClass' => '{$schemaClass}',\n\t\t],"; |
|
| 47 | + $methods[ $propertyName ] = "\t\t'{$propertyName}' => [\n\t\t\t'propertyClass' => '\\NilPortugues\\SchemaOrg\\Properties\\{$propertyNameMethodName}Property',\n\t\t\t'schemaClass' => '{$schemaClass}',\n\t\t],"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - $useProperties[] = 'use NilPortugues\SchemaOrg\Mapping;'; |
|
| 53 | - $useProperties[] = 'use NilPortugues\SchemaOrg\SchemaClass;'; |
|
| 52 | + $useProperties[ ] = 'use NilPortugues\SchemaOrg\Mapping;'; |
|
| 53 | + $useProperties[ ] = 'use NilPortugues\SchemaOrg\SchemaClass;'; |
|
| 54 | 54 | |
| 55 | 55 | sort($useProperties, SORT_REGULAR); |
| 56 | 56 | $useProperties = implode("\n", array_unique($useProperties)); |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | {$dynamicCall} |
| 81 | 81 | * METHODEND. |
| 82 | 82 | * |
| 83 | - * {$schemaData['doc']} |
|
| 83 | + * {$schemaData[ 'doc' ]} |
|
| 84 | 84 | */ |
| 85 | -class {$schemaData['name']} extends SchemaClass |
|
| 85 | +class {$schemaData[ 'name' ]} extends SchemaClass |
|
| 86 | 86 | { |
| 87 | 87 | /** |
| 88 | 88 | * @var string |
| 89 | 89 | */ |
| 90 | - protected static \$schemaUrl = "{$schemaData['url']}"; |
|
| 90 | + protected static \$schemaUrl = "{$schemaData[ 'url' ]}"; |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * @var array |