@@ -31,7 +31,7 @@ |
||
| 31 | 31 | ->addField('friends', new ListType([ |
| 32 | 32 | 'item' => new CharacterInterface() |
| 33 | 33 | ]), [ |
| 34 | - 'resolve' => function ($droid) { |
|
| 34 | + 'resolve' => function($droid) { |
|
| 35 | 35 | return StarWarsData::getFriends($droid); |
| 36 | 36 | }, |
| 37 | 37 | ]) |
@@ -98,21 +98,21 @@ discard block |
||
| 98 | 98 | 'friends' => [ |
| 99 | 99 | [ |
| 100 | 100 | 'name' => 'Luke Skywalker', |
| 101 | - 'appearsIn' => ['NEWHOPE', 'EMPIRE', 'JEDI',], |
|
| 101 | + 'appearsIn' => ['NEWHOPE', 'EMPIRE', 'JEDI', ], |
|
| 102 | 102 | 'friends' => [ |
| 103 | - ['name' => 'Han Solo',], |
|
| 104 | - ['name' => 'Leia Organa',], |
|
| 105 | - ['name' => 'C-3PO',], |
|
| 106 | - ['name' => 'R2-D2',], |
|
| 103 | + ['name' => 'Han Solo', ], |
|
| 104 | + ['name' => 'Leia Organa', ], |
|
| 105 | + ['name' => 'C-3PO', ], |
|
| 106 | + ['name' => 'R2-D2', ], |
|
| 107 | 107 | ], |
| 108 | 108 | ], |
| 109 | 109 | [ |
| 110 | 110 | 'name' => 'Han Solo', |
| 111 | 111 | 'appearsIn' => ['NEWHOPE', 'EMPIRE', 'JEDI'], |
| 112 | 112 | 'friends' => [ |
| 113 | - ['name' => 'Luke Skywalker',], |
|
| 113 | + ['name' => 'Luke Skywalker', ], |
|
| 114 | 114 | ['name' => 'Leia Organa'], |
| 115 | - ['name' => 'R2-D2',], |
|
| 115 | + ['name' => 'R2-D2', ], |
|
| 116 | 116 | ] |
| 117 | 117 | ], |
| 118 | 118 | [ |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | 'appearsIn' => ['NEWHOPE', 'EMPIRE', 'JEDI'], |
| 121 | 121 | 'friends' => |
| 122 | 122 | [ |
| 123 | - ['name' => 'Luke Skywalker',], |
|
| 124 | - ['name' => 'Han Solo',], |
|
| 125 | - ['name' => 'C-3PO',], |
|
| 126 | - ['name' => 'R2-D2',], |
|
| 123 | + ['name' => 'Luke Skywalker', ], |
|
| 124 | + ['name' => 'Han Solo', ], |
|
| 125 | + ['name' => 'C-3PO', ], |
|
| 126 | + ['name' => 'R2-D2', ], |
|
| 127 | 127 | ], |
| 128 | 128 | ], |
| 129 | 129 | ], |
@@ -29,9 +29,9 @@ |
||
| 29 | 29 | |
| 30 | 30 | public function getDescription() |
| 31 | 31 | { |
| 32 | - return 'The `Int` scalar type represents non-fractional signed whole numeric ' . |
|
| 33 | - 'values. Int can represent values between -(2^53 - 1) and 2^53 - 1 since ' . |
|
| 34 | - 'represented in JSON as double-precision floating point numbers specified' . |
|
| 32 | + return 'The `Int` scalar type represents non-fractional signed whole numeric '. |
|
| 33 | + 'values. Int can represent values between -(2^53 - 1) and 2^53 - 1 since '. |
|
| 34 | + 'represented in JSON as double-precision floating point numbers specified'. |
|
| 35 | 35 | 'by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,9 +40,9 @@ |
||
| 40 | 40 | public function getDescription() |
| 41 | 41 | { |
| 42 | 42 | return 'The `Int` scalar type represents non-fractional signed whole numeric ' . |
| 43 | - 'values. Int can represent values between -(2^53 - 1) and 2^53 - 1 since ' . |
|
| 44 | - 'represented in JSON as double-precision floating point numbers specified' . |
|
| 45 | - 'by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
|
| 43 | + 'values. Int can represent values between -(2^53 - 1) and 2^53 - 1 since ' . |
|
| 44 | + 'represented in JSON as double-precision floating point numbers specified' . |
|
| 45 | + 'by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | } |
@@ -23,8 +23,8 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function getDescription() |
| 25 | 25 | { |
| 26 | - return 'The `Float` scalar type represents signed double-precision fractional ' . |
|
| 27 | - 'values as specified by ' . |
|
| 26 | + return 'The `Float` scalar type represents signed double-precision fractional '. |
|
| 27 | + 'values as specified by '. |
|
| 28 | 28 | '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -29,8 +29,8 @@ |
||
| 29 | 29 | public function getDescription() |
| 30 | 30 | { |
| 31 | 31 | return 'The `Float` scalar type represents signed double-precision fractional ' . |
| 32 | - 'values as specified by ' . |
|
| 33 | - '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
|
| 32 | + 'values as specified by ' . |
|
| 33 | + '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | if (array_key_exists('required', $fieldRules)) { |
| 47 | 47 | unset($fieldRules['required']); |
| 48 | 48 | if (!array_key_exists($fieldName, $data)) { |
| 49 | - $this->addError(new ValidationException('Field \'' . $fieldName . '\' of ' . $this->getContextName() . ' is required')); |
|
| 49 | + $this->addError(new ValidationException('Field \''.$fieldName.'\' of '.$this->getContextName().' is required')); |
|
| 50 | 50 | continue; |
| 51 | 51 | } |
| 52 | 52 | } elseif (!array_key_exists($fieldName, $data)) { |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | /** Validation of all other rules*/ |
| 57 | 57 | foreach ($fieldRules as $ruleName => $ruleInfo) { |
| 58 | 58 | if (!array_key_exists($ruleName, $this->validationRules)) { |
| 59 | - $this->addError(new ValidationException('Field \'' . $fieldName . '\' has invalid rule \'' . $ruleInfo . '\'')); |
|
| 59 | + $this->addError(new ValidationException('Field \''.$fieldName.'\' has invalid rule \''.$ruleInfo.'\'')); |
|
| 60 | 60 | continue; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | if (!$this->validationRules[$ruleName]->validate($data[$fieldName], $ruleInfo)) { |
| 64 | 64 | $this->addError( |
| 65 | - new ValidationException('Field \'' . $fieldName . '\' of ' . $this->getContextName() |
|
| 66 | - . ' expected to be ' . $ruleName . ': \'' . (string)$ruleInfo . '\', but got: ' . gettype($data[$fieldName]))); |
|
| 65 | + new ValidationException('Field \''.$fieldName.'\' of '.$this->getContextName() |
|
| 66 | + . ' expected to be '.$ruleName.': \''.(string)$ruleInfo.'\', but got: '.gettype($data[$fieldName]))); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | foreach (array_keys($data) as $fieldName) { |
| 73 | 73 | if (!in_array($fieldName, $processedFields)) { |
| 74 | 74 | $this->addError( |
| 75 | - new ValidationException('Field \'' . $fieldName . '\' is not expected in ' . $this->getContextName())); |
|
| 75 | + new ValidationException('Field \''.$fieldName.'\' is not expected in '.$this->getContextName())); |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function validate($data, $rules = [], $extraFieldsAllowed = null) |
| 38 | 38 | { |
| 39 | - if ($extraFieldsAllowed !== null) $this->setExtraFieldsAllowed($extraFieldsAllowed); |
|
| 39 | + if ($extraFieldsAllowed !== null) { |
|
| 40 | + $this->setExtraFieldsAllowed($extraFieldsAllowed); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | $processedFields = []; |
| 42 | 44 | foreach ($rules as $fieldName => $fieldRules) { |
@@ -54,7 +56,9 @@ discard block |
||
| 54 | 56 | } elseif (!array_key_exists($fieldName, $data)) { |
| 55 | 57 | continue; |
| 56 | 58 | } |
| 57 | - if (!empty($fieldRules['final'])) unset($fieldRules['final']); |
|
| 59 | + if (!empty($fieldRules['final'])) { |
|
| 60 | + unset($fieldRules['final']); |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | 63 | /** Validation of all other rules*/ |
| 60 | 64 | foreach ($fieldRules as $ruleName => $ruleInfo) { |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | use Youshido\GraphQL\Processor; |
| 12 | 12 | use Youshido\GraphQL\Schema; |
| 13 | 13 | |
| 14 | -require_once __DIR__ . '/schema-bootstrap.php'; |
|
| 14 | +require_once __DIR__.'/schema-bootstrap.php'; |
|
| 15 | 15 | /** @var Schema $schema */ |
| 16 | 16 | $schema = new BlogSchema(); |
| 17 | 17 | |
@@ -25,8 +25,8 @@ |
||
| 25 | 25 | 'args' => [ |
| 26 | 26 | 'truncated' => new BooleanType() |
| 27 | 27 | ], |
| 28 | - 'resolve' => function ($value, $args) { |
|
| 29 | - return (!empty($args['truncated'])) ? explode(' ', $value)[0] . '...' : $value; |
|
| 28 | + 'resolve' => function($value, $args) { |
|
| 29 | + return (!empty($args['truncated'])) ? explode(' ', $value)[0].'...' : $value; |
|
| 30 | 30 | } |
| 31 | 31 | ]) |
| 32 | 32 | ->addField('title', new NonNullType(new StringType())) |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | public static function getPost($id) |
| 11 | 11 | { |
| 12 | 12 | return [ |
| 13 | - "id" => "post-" . $id, |
|
| 14 | - "title" => "Post " . $id . " title", |
|
| 13 | + "id" => "post-".$id, |
|
| 14 | + "title" => "Post ".$id." title", |
|
| 15 | 15 | "summary" => "This new GraphQL library for PHP works really well", |
| 16 | 16 | "status" => 1, |
| 17 | 17 | "likeCount" => 2 |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | public static function getBanner($id) |
| 22 | 22 | { |
| 23 | 23 | return [ |
| 24 | - 'id' => "banner-" . $id, |
|
| 25 | - 'title' => "Banner " . $id, |
|
| 26 | - 'imageLink' => "banner" . $id . ".jpg" |
|
| 24 | + 'id' => "banner-".$id, |
|
| 25 | + 'title' => "Banner ".$id, |
|
| 26 | + 'imageLink' => "banner".$id.".jpg" |
|
| 27 | 27 | ]; |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -27,7 +27,9 @@ |
||
| 27 | 27 | if (!$type) { |
| 28 | 28 | return; |
| 29 | 29 | } |
| 30 | - if (is_object($type) && array_key_exists($type->getName(), $this->types)) return; |
|
| 30 | + if (is_object($type) && array_key_exists($type->getName(), $this->types)) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | switch ($type->getKind()) { |
| 33 | 35 | case TypeMap::KIND_INTERFACE: |