Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.

Commit 43cb580

Browse files
Modernise codebase with features from PHP 7.3 (#168)
* Update PHP-CS-Fixer rules * Remove banner for unstable version
1 parent ed93ddc commit 43cb580

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+862
-2488
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[![Build Status](https://api.travis-ci.org/raml-org/raml-php-parser.svg?branch=master)](https://www.travis-ci.org/raml-org/raml-php-parser)
22
[![Coverage Status](https://coveralls.io/repos/github/raml-org/raml-php-parser/badge.svg?branch=master)](https://coveralls.io/github/raml-org/raml-php-parser?branch=master)
33
[![Latest Stable Version](https://poser.pugx.org/raml-org/raml-php-parser/v/stable)](https://packagist.org/packages/raml-org/raml-php-parser)
4-
[![Latest Unstable Version](https://poser.pugx.org/raml-org/raml-php-parser/v/unstable)](https://packagist.org/packages/raml-org/raml-php-parser)
54
[![Total Downloads](https://poser.pugx.org/raml-org/raml-php-parser/downloads)](https://packagist.org/packages/raml-org/raml-php-parser)
65

76
See the [RAML specification](https://github.com/raml-org/raml-spec).

src/ApiDefinition.php

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ class ApiDefinition implements ArrayInstantiationInterface
2525
/**
2626
* @var string
2727
*/
28-
const PROTOCOL_HTTP = 'HTTP';
28+
public const PROTOCOL_HTTP = 'HTTP';
2929

3030
/**
3131
* @var string
3232
*/
33-
const PROTOCOL_HTTPS = 'HTTPS';
33+
public const PROTOCOL_HTTPS = 'HTTPS';
3434

3535
/**
3636
* The API Title (required)
@@ -423,7 +423,7 @@ public function getBaseUri()
423423
return ($this->version) ? \str_replace('{version}', $this->version, $this->baseUri) : $this->baseUri;
424424
}
425425

426-
public function setBaseUri($baseUrl)
426+
public function setBaseUri($baseUrl): void
427427
{
428428
$this->baseUri = $baseUrl;
429429

@@ -447,9 +447,8 @@ public function getBaseUriParameters()
447447

448448
/**
449449
* Add a new base uri parameter
450-
*
451450
*/
452-
public function addBaseUriParameter(NamedParameter $namedParameter)
451+
public function addBaseUriParameter(NamedParameter $namedParameter): void
453452
{
454453
$this->baseUriParameters[$namedParameter->getKey()] = $namedParameter;
455454
}
@@ -490,7 +489,7 @@ public function getProtocols()
490489
* @param string $protocol
491490
* @throws \InvalidArgumentException
492491
*/
493-
private function addProtocol($protocol)
492+
private function addProtocol($protocol): void
494493
{
495494
if (!\in_array($protocol, [self::PROTOCOL_HTTP, self::PROTOCOL_HTTPS], true)) {
496495
throw new InvalidProtocolException(\sprintf('"%s" is not a valid protocol', $protocol));
@@ -516,7 +515,7 @@ public function getDefaultMediaTypes()
516515
*
517516
* @param string $defaultMediaType
518517
*/
519-
public function setDefaultMediaType($defaultMediaType)
518+
public function setDefaultMediaType($defaultMediaType): void
520519
{
521520
if (!\in_array($defaultMediaType, $this->defaultMediaTypes, true)) {
522521
return;
@@ -540,7 +539,7 @@ public function getSchemaCollections()
540539
* @param string $collectionName
541540
* @param array $schemas
542541
*/
543-
public function addSchemaCollection($collectionName, $schemas)
542+
public function addSchemaCollection($collectionName, $schemas): void
544543
{
545544
$this->schemaCollections[$collectionName] = [];
546545

@@ -558,7 +557,7 @@ public function addSchemaCollection($collectionName, $schemas)
558557
*
559558
* @throws InvalidSchemaDefinitionException
560559
*/
561-
private function addSchema($collectionName, $schemaName, $schema)
560+
private function addSchema($collectionName, $schemaName, $schema): void
562561
{
563562
if (!\is_string($schema) && !$schema instanceof SchemaDefinitionInterface) {
564563
throw new InvalidSchemaDefinitionException();
@@ -583,7 +582,7 @@ public function getDocumentationList()
583582
* @param string $title
584583
* @param string $documentation
585584
*/
586-
public function addDocumentation($title, $documentation)
585+
public function addDocumentation($title, $documentation): void
587586
{
588587
$this->documentationList[$title] = $documentation;
589588
}
@@ -672,9 +671,8 @@ public static function determineTrait($name, $definition)
672671

673672
/**
674673
* Add data type
675-
*
676674
*/
677-
public function addType(TypeInterface $type)
675+
public function addType(TypeInterface $type): void
678676
{
679677
$this->types->add($type);
680678
}
@@ -691,9 +689,8 @@ public function getTypes()
691689

692690
/**
693691
* Add trait
694-
*
695692
*/
696-
public function addTrait(TraitDefinition $trait)
693+
public function addTrait(TraitDefinition $trait): void
697694
{
698695
$this->traits->add($trait);
699696
}
@@ -720,18 +717,16 @@ public function getResources()
720717

721718
/**
722719
* Add an additional resource
723-
*
724720
*/
725-
public function addResource(Resource $resource)
721+
public function addResource(Resource $resource): void
726722
{
727723
$this->resources[$resource->getUri()] = $resource;
728724
}
729725

730726
/**
731727
* Removes Resource from ApiDefinition
732-
*
733728
*/
734-
public function removeResource(Resource $resource)
729+
public function removeResource(Resource $resource): void
735730
{
736731
if (!isset($this->resources[$resource->getUri()])) {
737732
return;
@@ -753,9 +748,8 @@ public function getSecurityScheme($schemeName)
753748

754749
/**
755750
* Add an additional security scheme
756-
*
757751
*/
758-
public function addSecurityScheme(SecurityScheme $securityScheme)
752+
public function addSecurityScheme(SecurityScheme $securityScheme): void
759753
{
760754
$this->securitySchemes[$securityScheme->getKey()] = $securityScheme;
761755
}
@@ -772,9 +766,8 @@ public function getSecuredBy()
772766

773767
/**
774768
* Add an additional security scheme to the list of schemes the whole API is secured by
775-
*
776769
*/
777-
public function addSecuredBy(SecurityScheme $securityScheme)
770+
public function addSecuredBy(SecurityScheme $securityScheme): void
778771
{
779772
$this->securedBy[$securityScheme->getKey()] = $securityScheme;
780773
}
@@ -815,7 +808,7 @@ private function getMethodsAsArray(array $resources)
815808
return $all;
816809
}
817810

818-
private function setProtocolsFromBaseUri()
811+
private function setProtocolsFromBaseUri(): void
819812
{
820813
$schema = \mb_strtoupper(\parse_url($this->baseUri, PHP_URL_SCHEME));
821814

src/Body.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function getDescription()
153153
*
154154
* @param string $description
155155
*/
156-
public function setDescription($description)
156+
public function setDescription($description): void
157157
{
158158
$this->description = $description;
159159
}
@@ -187,7 +187,7 @@ public function getValidator()
187187
*
188188
* @throws \Exception
189189
*/
190-
public function setSchema($schema)
190+
public function setSchema($schema): void
191191
{
192192
if (!\is_string($schema) && !$schema instanceof SchemaDefinitionInterface) {
193193
throw new InvalidSchemaDefinitionException();
@@ -214,7 +214,7 @@ public function getType()
214214
*
215215
* @throws \Exception Throws exception when type does not parse
216216
*/
217-
public function setType(TypeInterface $type)
217+
public function setType(TypeInterface $type): void
218218
{
219219
$this->type = $type;
220220
}
@@ -246,7 +246,7 @@ public function getExamples()
246246
*
247247
* @param string $example
248248
*/
249-
public function addExample($example)
249+
public function addExample($example): void
250250
{
251251
$this->examples[] = $example;
252252
}

src/MessageSchemaInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public function getHeaders();
1313

1414
/**
1515
* Add a new header
16-
*
1716
*/
1817
public function addHeader(NamedParameter $header);
1918

@@ -37,7 +36,6 @@ public function getBodies();
3736

3837
/**
3938
* Add a body
40-
*
4139
*/
4240
public function addBody(BodyInterface $body);
4341
}

src/Method.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public function getDescription()
249249
*
250250
* @param string $description
251251
*/
252-
public function setDescription($description)
252+
public function setDescription($description): void
253253
{
254254
$this->description = $description;
255255
}
@@ -271,7 +271,7 @@ public function getDisplayName()
271271
*
272272
* @param string|null $displayName
273273
*/
274-
public function setDisplayName($displayName)
274+
public function setDisplayName($displayName): void
275275
{
276276
$this->displayName = $displayName;
277277
}
@@ -290,9 +290,8 @@ public function getBaseUriParameters()
290290

291291
/**
292292
* Add a new base uri parameter
293-
*
294293
*/
295-
public function addBaseUriParameter(NamedParameter $namedParameter)
294+
public function addBaseUriParameter(NamedParameter $namedParameter): void
296295
{
297296
$this->baseUriParameters[$namedParameter->getKey()] = $namedParameter;
298297
}
@@ -311,9 +310,8 @@ public function getHeaders()
311310

312311
/**
313312
* Add a new header
314-
*
315313
*/
316-
public function addHeader(NamedParameter $header)
314+
public function addHeader(NamedParameter $header): void
317315
{
318316
$this->headers[$header->getKey()] = $header;
319317
}
@@ -358,7 +356,7 @@ public function getProtocols()
358356
*/
359357
public function getExampleByType($type)
360358
{
361-
return isset($this->bodyList[$type]['example']) ? $this->bodyList[$type]['example'] : null;
359+
return $this->bodyList[$type]['example'] ?? null;
362360
}
363361

364362
/**
@@ -368,7 +366,7 @@ public function getExampleByType($type)
368366
*
369367
* @throws \InvalidArgumentException
370368
*/
371-
public function addProtocol($protocol)
369+
public function addProtocol($protocol): void
372370
{
373371
if (!\in_array($protocol, [ApiDefinition::PROTOCOL_HTTP, ApiDefinition::PROTOCOL_HTTPS], true)) {
374372
throw new \InvalidArgumentException(\sprintf('"%s" is not a valid protocol', $protocol));
@@ -393,9 +391,8 @@ public function getQueryParameters()
393391

394392
/**
395393
* Add a query parameter
396-
*
397394
*/
398-
public function addQueryParameter(NamedParameter $queryParameter)
395+
public function addQueryParameter(NamedParameter $queryParameter): void
399396
{
400397
$this->queryParameters[$queryParameter->getKey()] = $queryParameter;
401398
}
@@ -443,9 +440,8 @@ public function getBodies()
443440

444441
/**
445442
* Add a body
446-
*
447443
*/
448-
public function addBody(BodyInterface $body)
444+
public function addBody(BodyInterface $body): void
449445
{
450446
$this->bodyList[$body->getMediaType()] = $body;
451447
}
@@ -471,14 +467,13 @@ public function getResponses()
471467
*/
472468
public function getResponse($responseCode)
473469
{
474-
return isset($this->responses[$responseCode]) ? $this->responses[$responseCode] : null;
470+
return $this->responses[$responseCode] ?? null;
475471
}
476472

477473
/**
478474
* Add a response
479-
*
480475
*/
481-
public function addResponse(Response $response)
476+
public function addResponse(Response $response): void
482477
{
483478
$this->responses[$response->getStatusCode()] = $response;
484479
}
@@ -498,7 +493,7 @@ public function getSecuritySchemes()
498493
/**
499494
* @param bool $merge Set to true to merge the security scheme data with the method, or false to not merge it.
500495
*/
501-
public function addSecurityScheme(SecurityScheme $securityScheme, $merge = true)
496+
public function addSecurityScheme(SecurityScheme $securityScheme, $merge = true): void
502497
{
503498
$this->securitySchemes[$securityScheme->getKey()] = $securityScheme;
504499

0 commit comments

Comments
 (0)