Skip to content

Commit

Permalink
Merge pull request #6 from danolshev/f/add_array_of_string_to_mixed
Browse files Browse the repository at this point in the history
F/add array of string to mixed
  • Loading branch information
zakirullin authored Aug 1, 2020
2 parents 7551e15 + 5c18640 commit eb61c29
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"autoload-dev": {
"psr-4": {
"Zakirullin\\Mess\\Tests\\": "tests/unit"
"Zakirullin\\Mess\\Tests\\": "tests/unit/"
}
}
}
1 change: 1 addition & 0 deletions src/Enum/TypeEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ final class TypeEnum
public const ARRAY_OF_STRING_TO_INT = 'array<string,int>';
public const ARRAY_OF_STRING_TO_BOOL = 'array<string,bool>';
public const ARRAY_OF_STRING_TO_STRING = 'array<string,string>';
public const ARRAY_OF_STRING_TO_MIXED = 'array<string,mixed>';
}
31 changes: 31 additions & 0 deletions src/Mess.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Zakirullin\Mess\Exception\UncastableValueException;
use Zakirullin\Mess\Exception\UnexpectedKeyTypeException;
use Zakirullin\Mess\Exception\UnexpectedTypeException;
use Zakirullin\Mess\Finder\ArrayOfStringToMixedFinder;
use Zakirullin\Mess\Finder\ArrayOfStringToTypeFinder;
use Zakirullin\Mess\Finder\ListOfTypeFinder;
use function is_array;
Expand Down Expand Up @@ -174,6 +175,22 @@ public function getArrayOfStringToString(): array
return $this->value;
}

/**
* @psalm-pure
* @psalm-return array<string,mixed>
*
* @return array
*/
public function getArrayOfStringToMixed(): array
{
$this->assertType($this->findArrayOfStringToMixed(), TypeEnum::ARRAY_OF_STRING_TO_MIXED);

/**
* @psalm-var array<string,mixed>
*/
return $this->value;
}

/**
* @psalm-pure
*
Expand Down Expand Up @@ -406,6 +423,20 @@ public function findArrayOfStringToString(): ?array
return ArrayOfStringToTypeFinder::find($this->value, 'is_string');
}

/**
* @psalm-pure
* @psalm-return array<string,mixed>|null
*
* @return array|null
*/
public function findArrayOfStringToMixed(): ?array
{
/**
* @psalm-var array<string,string>|null
*/
return ArrayOfStringToMixedFinder::find($this->value);
}

/**
* @psalm-pure
*
Expand Down
1 change: 0 additions & 1 deletion src/TypedAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
*/
final class TypedAccessor extends Mess
{

}

0 comments on commit eb61c29

Please sign in to comment.