Skip to content

Commit 5e807f2

Browse files
authored
Improve (#25)
1 parent 2c46d44 commit 5e807f2

14 files changed

+130
-53
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"require": {
3333
"php": ">=7.1",
34-
"yoanm/jsonrpc-server-doc-sdk": "dev-release/0.1.0"
34+
"yoanm/jsonrpc-server-doc-sdk": "v0.1.0"
3535
},
3636
"require-dev": {
3737
"ext-json": "*",

src/App/Helper/ArrayAppendHelperTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trait ArrayAppendHelperTrait
1313
*
1414
* @return array
1515
*/
16-
protected function appendIfValueHaveSiblings(string $key, array $value, array $doc = [])
16+
protected function appendIfValueHaveSiblings(string $key, array $value, array $doc = []) : array
1717
{
1818
return $this->appendIf((count($value) > 0), $key, $value, $doc);
1919
}
@@ -25,7 +25,7 @@ protected function appendIfValueHaveSiblings(string $key, array $value, array $d
2525
*
2626
* @return array
2727
*/
28-
protected function appendIfValueNotNull(string $key, $value, array $doc = [])
28+
protected function appendIfValueNotNull(string $key, $value, array $doc = []) : array
2929
{
3030
return $this->appendIf((null !== $value), $key, $value, $doc);
3131
}
@@ -38,7 +38,7 @@ protected function appendIfValueNotNull(string $key, $value, array $doc = [])
3838
*
3939
* @return array
4040
*/
41-
protected function appendIf(bool $doAppend, string $key, $value, array $doc = [])
41+
protected function appendIf(bool $doAppend, string $key, $value, array $doc = []) : array
4242
{
4343
if (true === $doAppend) {
4444
$doc[$key] = $value;

src/App/Normalizer/Component/ErrorDocNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
*
3333
* @throws \ReflectionException
3434
*/
35-
public function normalize(ErrorDoc $errorDoc)
35+
public function normalize(ErrorDoc $errorDoc) : array
3636
{
3737
$requiredDoc = ['required' => ['code']];
3838
$properties = [

src/App/Normalizer/Component/ExternalSchemaListDocNormalizer.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(
4646
*
4747
* @throws \ReflectionException
4848
*/
49-
public function normalize(ServerDoc $doc)
49+
public function normalize(ServerDoc $doc) : array
5050
{
5151
return array_merge(
5252
$this->getMethodsExternalSchemaList($doc),
@@ -63,7 +63,7 @@ public function normalize(ServerDoc $doc)
6363
*
6464
* @throws \ReflectionException
6565
*/
66-
protected function getMethodsExternalSchemaList(ServerDoc $doc)
66+
protected function getMethodsExternalSchemaList(ServerDoc $doc) : array
6767
{
6868
$list = [];
6969
foreach ($doc->getMethodList() as $method) {
@@ -81,7 +81,7 @@ protected function getMethodsExternalSchemaList(ServerDoc $doc)
8181
*
8282
* @throws \ReflectionException
8383
*/
84-
protected function getMethodErrorsExternalSchemaList(ServerDoc $doc)
84+
protected function getMethodErrorsExternalSchemaList(ServerDoc $doc) : array
8585
{
8686
$list = [];
8787
foreach ($doc->getMethodList() as $method) {
@@ -105,7 +105,7 @@ protected function getMethodErrorsExternalSchemaList(ServerDoc $doc)
105105
*
106106
* @throws \ReflectionException
107107
*/
108-
protected function getServerErrorsExtraSchemaList(ServerDoc $doc)
108+
protected function getServerErrorsExtraSchemaList(ServerDoc $doc) : array
109109
{
110110
return array_merge(
111111
$this->normalizeErrorList(
@@ -154,9 +154,10 @@ protected function getMethodExternalSchemaList(MethodDoc $method) : array
154154

155155
/**
156156
* @param ServerDoc $doc
157+
*
157158
* @return array
158159
*/
159-
protected function getDefaultSchemaList(ServerDoc $doc)
160+
protected function getDefaultSchemaList(ServerDoc $doc) : array
160161
{
161162
$propertyList = [
162163
'code' => [
@@ -213,7 +214,7 @@ function (ErrorDoc $errorDoc) {
213214
*
214215
* @throws \ReflectionException
215216
*/
216-
private function normalizeErrorList(array $errorDocList, $definitionType)
217+
private function normalizeErrorList(array $errorDocList, $definitionType) : array
217218
{
218219
$list = [];
219220
foreach ($errorDocList as $errorDoc) {
@@ -234,7 +235,7 @@ private function normalizeErrorList(array $errorDocList, $definitionType)
234235
*
235236
* @throws \ReflectionException
236237
*/
237-
protected function appendAndNormalizeIfNotNull(string $key, $value, array $list = [])
238+
protected function appendAndNormalizeIfNotNull(string $key, $value, array $list = []) : array
238239
{
239240
if (null !== $value) {
240241
$list[$key] = $this->typeDocNormalizer->normalize($value);

src/App/Normalizer/Component/OperationDocNormalizer.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ public function normalize(MethodDoc $method) : array
7474

7575
/**
7676
* @param MethodDoc $method
77+
*
7778
* @return array
7879
*/
79-
protected function getDescriptionDoc(MethodDoc $method)
80+
protected function getDescriptionDoc(MethodDoc $method) : array
8081
{
8182
$docDescription = [];
8283
if (null !== $method->getDescription()) {
@@ -104,7 +105,7 @@ protected function getDescriptionDoc(MethodDoc $method)
104105
*
105106
* @return string|null
106107
*/
107-
private function getResponseDescription(MethodDoc $method)
108+
private function getResponseDescription(MethodDoc $method) : ?string
108109
{
109110
if (count($method->getCustomErrorList())) {
110111
$self = $this;
@@ -132,7 +133,12 @@ function (ErrorDoc $errorDoc) use ($self) {
132133
return null;
133134
}
134135

135-
private function formatErrorForDescription(ErrorDoc $errorDoc)
136+
/**
137+
* @param ErrorDoc $errorDoc
138+
*
139+
* @return string
140+
*/
141+
private function formatErrorForDescription(ErrorDoc $errorDoc) : string
136142
{
137143
return sprintf(
138144
'*%s* (**Definitions->%s**)',

src/App/Normalizer/Component/RequestDocNormalizer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ public function __construct(
2727
}
2828

2929
/**
30-
* {@inheritdoc}
30+
* @param MethodDoc $method
31+
*
32+
* @return array
3133
*/
32-
public function normalize(MethodDoc $method)
34+
public function normalize(MethodDoc $method) : array
3335
{
3436
$requestSchema = ['allOf' => [$this->shapeNormalizer->getRequestShapeDefinition()]];
3537
// Append custom if params required

src/App/Normalizer/Component/ResponseDocNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
*
3333
* @return array
3434
*/
35-
public function normalize(MethodDoc $method)
35+
public function normalize(MethodDoc $method) : array
3636
{
3737
return [
3838
'allOf' => array_merge(
@@ -78,7 +78,7 @@ function ($errorIdentifier) {
7878
*
7979
* @return array
8080
*/
81-
protected function getMethodResultArrayDoc(MethodDoc $method)
81+
protected function getMethodResultArrayDoc(MethodDoc $method) : array
8282
{
8383
if (null !== $method->getResultDoc()) {
8484
return [

src/App/Normalizer/Component/ResultDocNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(DefinitionRefResolver $definitionRefResolver)
2525
*
2626
* @return array
2727
*/
28-
public function normalize(MethodDoc $method)
28+
public function normalize(MethodDoc $method) : array
2929
{
3030
if (null !== $method->getResultDoc()) {
3131
return [

src/App/Normalizer/Component/SchemaTypeNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ class SchemaTypeNormalizer
3333
/**
3434
* @param TypeDoc $doc
3535
*
36-
* @return mixed|string
36+
* @return string
3737
*
3838
* @throws \ReflectionException
3939
*/
40-
public function normalize(TypeDoc $doc)
40+
public function normalize(TypeDoc $doc) : string
4141
{
4242
$type = str_replace('Doc', '', lcfirst((new \ReflectionClass($doc))->getShortName()));
4343
if (in_array($type, self::MANAGED_TYPE_LIST)) {

src/App/Normalizer/Component/ShapeNormalizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ShapeNormalizer
99
/**
1010
* @return array
1111
*/
12-
public function getRequestShapeDefinition()
12+
public function getRequestShapeDefinition() : array
1313
{
1414
return [
1515
'type' => 'object',
@@ -32,7 +32,7 @@ public function getRequestShapeDefinition()
3232
/**
3333
* @return array
3434
*/
35-
public function getResponseShapeDefinition()
35+
public function getResponseShapeDefinition() : array
3636
{
3737
return [
3838
'type' => 'object',
@@ -55,7 +55,7 @@ public function getResponseShapeDefinition()
5555
/**
5656
* @return array
5757
*/
58-
public function getErrorShapeDefinition()
58+
public function getErrorShapeDefinition() : array
5959
{
6060
return [
6161
'type' => 'object',

0 commit comments

Comments
 (0)