Skip to content

Commit

Permalink
Remove "modern" PHP syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
yvo-niedrich committed Aug 7, 2024
1 parent c7fd254 commit f64d6de
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Attributes/LodataProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
$alternativeKey = false,
$searchable = false,
$filterable = true,
?bool $immutable = false,
?bool $immutable = false
) {
$this->name = $name;
$this->description = $description;
Expand Down Expand Up @@ -182,7 +182,7 @@ public function addProperty(EntitySet $entitySet): Property
if ($this->hasScale()) {
$property->setScale($this->getScale());
}

$property->setAlternativeKey($this->isAlternativeKey());
$property->setFilterable($this->isFilterable());
$property->setSearchable($this->isSearchable());
Expand Down
3 changes: 1 addition & 2 deletions src/PrimitiveType.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ public function getOpenAPISchema(): array
return $this->instance()->getOpenAPISchema();
}

#[\Override]
public function allowsValue($value): bool
{
return $this->instance()->allows($value);
}
}
}
11 changes: 6 additions & 5 deletions src/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,11 @@ public function isSearchable(): bool
*/
public function assertAllowsValue($value)
{
if ($this->isNullable() && $value === null) {
return;
}
if ($value === null) {
if ($this->isNullable()) {
return;
}

throw new BadRequestException(
'property_not_nullable',
sprintf("The property '%s' cannot be set to null", $this->getName())
Expand All @@ -389,8 +390,8 @@ public function assertAllowsValue($value)

if (!$this->type->allowsValue($value)) {
throw new BadRequestException(
'property_not_valid_for_type',
sprintf("Property value '%s' is not valid for the type", $this->getName()),
'property_value_invalid',
sprintf("The value property '%s' is not valid", $this->getName()),
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ public function is(string $class): bool
{
return is_a($this->factory, $class, true);
}
public function allowsValue(mixed $value): bool

public function allowsValue($value): bool
{
return true;
}
Expand Down
1 change: 0 additions & 1 deletion src/Type/Guid.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public function getOpenAPISchema(?Property $property = null): array
]);
}

#[\Override]
public function allows($value): bool
{
return Lexer::patternCheck(Lexer::guid, (string) $value);
Expand Down

0 comments on commit f64d6de

Please sign in to comment.