Skip to content

Use PHP 7.4 property type hints #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
}
],
"require": {
"php": "^7.2",
"event-engine/php-data": "^1.0",
"php": "^7.4",
"event-engine/php-data": "^2.0-dev",
"event-engine/php-engine-utils": "^0.1",
"event-engine/php-schema": "^0.1",
"ramsey/uuid": "^3.6"
Expand Down
2 changes: 1 addition & 1 deletion tests/Stub/ArrayItemRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private static function arrayPropItemTypeMap(): array
/**
* @var string[]
*/
private $friends;
private array $friends;

/**
* @return string[]
Expand Down
8 changes: 1 addition & 7 deletions tests/Stub/CollectionItemAllowNestedRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@ final class CollectionItemAllowNestedRecord implements JsonSchemaAwareRecord
{
use JsonSchemaAwareRecordLogic;

/**
* @var ScalarPropsRecordAllowNestedCollection
*/
private $friends;
private ScalarPropsRecordAllowNestedCollection $friends;

/**
* @return ScalarPropsRecordAllowNestedCollection
*/
public function friends(): ScalarPropsRecordAllowNestedCollection
{
return $this->friends;
Expand Down
8 changes: 1 addition & 7 deletions tests/Stub/CollectionItemRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@ final class CollectionItemRecord implements JsonSchemaAwareRecord
{
use JsonSchemaAwareRecordLogic;

/**
* @var ScalarPropsRecordCollection
*/
private $friends;
private ScalarPropsRecordCollection $friends;

/**
* @return ScalarPropsRecordCollection
*/
public function friends(): ScalarPropsRecordCollection
{
return $this->friends;
Expand Down
2 changes: 1 addition & 1 deletion tests/Stub/NullableArrayItemRecordAllowNestedRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private static function __allowNestedSchema(): bool
/**
* @var ScalarPropsRecord[]|null
*/
private $friends;
private ?array $friends;

/**
* @return ScalarPropsRecord[]|null
Expand Down
2 changes: 1 addition & 1 deletion tests/Stub/NullableArrayItemRecordRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private static function arrayPropItemTypeMap(): array
/**
* @var ScalarPropsRecord[]|null
*/
private $friends;
private ?array $friends;

/**
* @return ScalarPropsRecord[]|null
Expand Down
32 changes: 4 additions & 28 deletions tests/Stub/NullableScalarPropsRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,29 @@ final class NullableScalarPropsRecord implements JsonSchemaAwareRecord
{
use JsonSchemaAwareRecordLogic;

/**
* @var string|null
*/
private $userId;
private ?string $userId;

/**
* @var int|null
*/
private $age;
private ?int $age;

/**
* @var bool|null
*/
private $member;
private ?bool $member;

/**
* @var float|null
*/
private $score;
private ?float $score;

/**
* @return string|null
*/
public function userId(): ?string
{
return $this->userId;
}

/**
* @return int|null
*/
public function age(): ?int
{
return $this->age;
}

/**
* @return bool|null
*/
public function member(): ?bool
{
return $this->member;
}

/**
* @return float|null
*/
public function score(): ?float
{
return $this->score;
Expand Down
32 changes: 4 additions & 28 deletions tests/Stub/ScalarPropsRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,29 @@ final class ScalarPropsRecord implements JsonSchemaAwareRecord
{
use JsonSchemaAwareRecordLogic;

/**
* @var string
*/
private $userId;
private string $userId;

/**
* @var int
*/
private $age;
private int $age;

/**
* @var bool
*/
private $member;
private bool $member;

/**
* @var float
*/
private $score;
private float $score;

/**
* @return string
*/
public function userId(): string
{
return $this->userId;
}

/**
* @return int
*/
public function age(): int
{
return $this->age;
}

/**
* @return bool
*/
public function member(): bool
{
return $this->member;
}

/**
* @return float
*/
public function score(): float
{
return $this->score;
Expand Down
2 changes: 1 addition & 1 deletion tests/Stub/ScalarPropsRecordAllowNestedCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private static function __allowNestedSchema(): bool
/**
* @var ScalarPropsRecord[]
*/
private $items;
private array $items;

public static function fromArray(array $items): self
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Stub/ScalarPropsRecordCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function validationRules(): array
/**
* @var ScalarPropsRecord[]
*/
private $items;
private array $items;

public static function fromArray(array $items): self
{
Expand Down
32 changes: 4 additions & 28 deletions tests/Stub/VoOptionalPropsRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,13 @@ final class VoOptionalPropsRecord implements JsonSchemaAwareRecord
public const MEMBER = 'member';
public const SCORE = 'score';

/**
* @var UserId
*/
private $userId;
private UserId $userId;

/**
* @var Age
*/
private $age;
private Age $age;

/**
* @var Member
*/
private $member;
private Member $member;

/**
* @var Score
*/
private $score;
private Score $score;

private static function __optionalProperties(): array
{
Expand All @@ -51,33 +39,21 @@ private function init(): void
}
}

/**
* @return UserId
*/
public function userId(): UserId
{
return $this->userId;
}

/**
* @return Age
*/
public function age(): Age
{
return $this->age;
}

/**
* @return Member
*/
public function member(): Member
{
return $this->member;
}

/**
* @return Score
*/
public function score(): Score
{
return $this->score;
Expand Down
2 changes: 1 addition & 1 deletion tests/Stub/VoProp/Age.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

final class Age implements ProvidesValidationRules
{
private $age;
private int $age;

public static function validationRules(): array
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Stub/VoProp/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

final class Member
{
private $flag;
private bool $flag;

public static function fromBool(bool $flag): self
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Stub/VoProp/Score.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

final class Score implements ProvidesValidationRules
{
private $score;
private float $score;

public static function validationRules(): array
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Stub/VoProp/UserId.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class UserId implements ProvidesValidationRules
{
public const PATTERN = '^[0-9]+$';

private $userId;
private string $userId;

public static function validationRules(): array
{
Expand Down
32 changes: 4 additions & 28 deletions tests/Stub/VoPropsRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,29 @@ final class VoPropsRecord implements JsonSchemaAwareRecord
public const MEMBER = 'member';
public const SCORE = 'score';

/**
* @var UserId
*/
private $userId;
private UserId $userId;

/**
* @var Age
*/
private $age;
private Age $age;

/**
* @var Member
*/
private $member;
private Member $member;

/**
* @var Score
*/
private $score;
private Score $score;

/**
* @return UserId
*/
public function userId(): UserId
{
return $this->userId;
}

/**
* @return Age
*/
public function age(): Age
{
return $this->age;
}

/**
* @return Member
*/
public function member(): Member
{
return $this->member;
}

/**
* @return Score
*/
public function score(): Score
{
return $this->score;
Expand Down