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

Commit 0e431da

Browse files
#156 Allow built-in type ANY (#157)
1 parent 1e8183c commit 0e431da

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/ApiDefinition.php

+1
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ public static function getStraightForwardTypes()
604604
'file',
605605
'array',
606606
'object',
607+
'any',
607608
];
608609
}
609610

src/NamedParameter.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class NamedParameter implements ArrayInstantiationInterface
1212
{
1313
// Type constants
1414

15+
/**
16+
* @var string
17+
*/
18+
const TYPE_ANY = 'any';
19+
1520
/**
1621
* @var string
1722
*/
@@ -140,6 +145,7 @@ class NamedParameter implements ArrayInstantiationInterface
140145
* @var string[]
141146
*/
142147
protected $validTypes = [
148+
self::TYPE_ANY,
143149
self::TYPE_STRING,
144150
self::TYPE_NUMBER,
145151
self::TYPE_INTEGER,
@@ -602,12 +608,12 @@ public function getMinimum()
602608
*
603609
* @param int $minimum
604610
*
605-
* @throws \Exception
611+
* @throws \InvalidArgumentException
606612
*/
607613
public function setMinimum($minimum)
608614
{
609615
if (!\in_array($this->type, [self::TYPE_INTEGER, self::TYPE_NUMBER], true)) {
610-
throw new \Exception('minimum can only be set on type "integer" or "number');
616+
throw new \InvalidArgumentException('minimum can only be set on type "integer" or "number');
611617
}
612618

613619
$this->minimum = (int) $minimum;
@@ -630,12 +636,12 @@ public function getMaximum()
630636
*
631637
* @param int $maximum
632638
*
633-
* @throws \Exception
639+
* @throws \InvalidArgumentException
634640
*/
635641
public function setMaximum($maximum)
636642
{
637643
if (!\in_array($this->type, [self::TYPE_INTEGER, self::TYPE_NUMBER], true)) {
638-
throw new \Exception('maximum can only be set on type "integer" or "number');
644+
throw new \InvalidArgumentException('maximum can only be set on type "integer" or "number');
639645
}
640646

641647
$this->maximum = (int) $maximum;

src/Types/ObjectType.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static function createFromArray($name, array $data = [])
106106
}
107107

108108
/**
109-
* @param string $value
109+
* @param array $value
110110
* @return bool
111111
*/
112112
public function discriminate($value)
@@ -153,7 +153,7 @@ public function setProperties(array $properties)
153153
* Returns a property by name
154154
*
155155
* @param string $name
156-
* @return null|Type
156+
* @return void|Type
157157
*/
158158
public function getPropertyByName($name)
159159
{

tests/ParseTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ public function shouldThrowExceptionOnBadQueryParameter()
794794
$this->assertEquals('invalid', $e->getType());
795795
$this->assertEquals(
796796
[
797+
'any',
797798
'string',
798799
'number',
799800
'integer',

0 commit comments

Comments
 (0)