Skip to content

Commit

Permalink
Add mixed as parameter type and return type
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Nov 28, 2023
1 parent 0e3919d commit 8a18b4c
Show file tree
Hide file tree
Showing 45 changed files with 100 additions and 303 deletions.
12 changes: 3 additions & 9 deletions src/Helper/AccessableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ trait AccessableTrait

/**
* Set a value
*
* @param mixed $value The Value
*/
final protected function set(string $key, $value): void
final protected function set(string $key, mixed $value): void
{
// Allow non-associative array for collections
if ($key === '') {
Expand Down Expand Up @@ -93,10 +91,8 @@ final public function has($key): bool
* Get a value by a key
*
* @param int|string|AccessKey<string> $key The key
*
* @return mixed
*/
public function get($key)
public function get($key): mixed
{
if (!is_int($key) && !is_string($key) && (!is_object($key) || !$key instanceof AccessKey)) {
trigger_error(sprintf(
Expand Down Expand Up @@ -131,10 +127,8 @@ public function get($key)
* Get a value by the key
*
* @throws AccessException
*
* @return mixed The value
*/
private function getValue(string $key)
private function getValue(string $key): mixed
{
if (array_key_exists($key, $this->data)) {
return $this->data[$key];
Expand Down
4 changes: 1 addition & 3 deletions src/Input/StringInputTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ final public function prepareString($string): string
* Decodes a json string
*
* @throws InputException if something went wrong with the input
*
* @return mixed
*/
final protected function decodeJson(string $jsonString)
final protected function decodeJson(string $jsonString): mixed
{
$jsonErrors = [
\JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded',
Expand Down
6 changes: 1 addition & 5 deletions src/Manager/ErrorAbortManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,8 @@ public function getFactory(): Factory

/**
* Get a param by key
*
* @param mixed $default
*
* @return mixed
*/
public function getParam(string $key, $default)
public function getParam(string $key, mixed $default): mixed
{
if (array_key_exists($key, $this->config)) {
return $this->config[$key];
Expand Down
6 changes: 1 addition & 5 deletions src/Serializer/ArraySerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ public function serialize(Accessable $data): ?array

/**
* Transforms objects to arrays
*
* @param mixed $val
*
* @return mixed
*/
private function objectTransform($val)
private function objectTransform(mixed $val): mixed
{
if (!is_object($val)) {
return $val;
Expand Down
8 changes: 2 additions & 6 deletions src/V1/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class Attributes extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Attributes has to be an object, "' . gettype($object) . '" given.');
Expand All @@ -52,10 +50,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ final class Document extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Document has to be an object, "' . gettype($object) . '" given.');
Expand Down Expand Up @@ -75,10 +73,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/DocumentLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ final class DocumentLink extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException(
Expand Down Expand Up @@ -105,10 +103,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class Error extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException(
Expand Down Expand Up @@ -107,10 +105,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/ErrorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class ErrorCollection extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_array($object)) {
throw new ValidationException('Errors for a collection has to be in an array, "' . gettype($object) . '" given.');
Expand All @@ -46,10 +44,8 @@ protected function parse($object): void
* Get a value by the key of this document
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/ErrorLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ final class ErrorLink extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Link has to be an object, "' . gettype($object) . '" given.');
Expand Down Expand Up @@ -65,10 +63,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/ErrorSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class ErrorSource extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('ErrorSource has to be an object, "' . gettype($object) . '" given.');
Expand All @@ -54,10 +52,8 @@ protected function parse($object): void
* Get a value by the key of this document
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/Jsonapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class Jsonapi extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Jsonapi has to be an object, "' . gettype($object) . '" given.');
Expand All @@ -50,10 +48,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
12 changes: 3 additions & 9 deletions src/V1/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class Link extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Link has to be an object or string, "' . gettype($object) . '" given.');
Expand All @@ -46,10 +44,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand All @@ -60,10 +56,8 @@ public function get($key)

/**
* Set a link
*
* @param mixed $link The Link
*/
private function setAsLink(string $name, $link): void
private function setAsLink(string $name, mixed $link): void
{
if ($name === 'meta') {
$this->set($name, $this->create('Meta', $link));
Expand Down
8 changes: 2 additions & 6 deletions src/V1/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class Meta extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Meta has to be an object, "' . gettype($object) . '" given.');
Expand All @@ -48,10 +46,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class Relationship extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Relationship has to be an object, "' . gettype($object) . '" given.');
Expand Down Expand Up @@ -61,10 +59,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/RelationshipCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class RelationshipCollection extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Relationships has to be an object, "' . gettype($object) . '" given.');
Expand Down Expand Up @@ -56,10 +54,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
Loading

0 comments on commit 8a18b4c

Please sign in to comment.