Skip to content
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
6 changes: 3 additions & 3 deletions .github/workflows/autoformat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
composer-normalize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

Expand All @@ -29,7 +29,7 @@ jobs:
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

Expand All @@ -44,7 +44,7 @@ jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v2
Expand All @@ -60,13 +60,15 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"
dependencies:
- "prefer-lowest"
- "prefer-stable"

steps:
- name: "Checkout"
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v2
Expand All @@ -87,7 +89,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v2
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## v6.4.0

### Added

- Support `thecodingmachine/safe` 3

## v6.3.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"ext-json": "*",
"egulias/email-validator": "^2.1.17 || ^3 || ^4",
"spatie/regex": "^1.4 || ^2 || ^3",
"thecodingmachine/safe": "^1.3 || ^2",
"thecodingmachine/safe": "^1.3 || ^2 || ^3",
"webonyx/graphql-php": "^15"
},
"require-dev": {
Expand Down
5 changes: 1 addition & 4 deletions src/DateScalar.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public function parseValue($value): \DateTimeInterface
public function parseLiteral($valueNode, ?array $variables = null): \DateTimeInterface
{
if (! $valueNode instanceof StringValueNode) {
throw new Error(
"Query error: Can only parse strings, got {$valueNode->kind}",
$valueNode
);
throw new Error("Query error: Can only parse strings, got {$valueNode->kind}", $valueNode);
}

return $this->tryParsingDate($valueNode->value, Error::class);
Expand Down
4 changes: 1 addition & 3 deletions src/JSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ protected function decodeJSON(mixed $value): mixed
// @phpstan-ignore-next-line we attempt unsafe values and let it throw
$decoded = \Safe\json_decode($value);
} catch (JsonException $jsonException) {
throw new Error(
$jsonException->getMessage()
);
throw new Error($jsonException->getMessage());
}

return $decoded;
Expand Down
13 changes: 3 additions & 10 deletions src/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public function serialize($value): string
$stringValue = Utils::coerceToString($value, InvariantViolation::class);

if (! static::matchesRegex($stringValue)) {
throw new InvariantViolation(
static::unmatchedRegexMessage($stringValue)
);
throw new InvariantViolation(static::unmatchedRegexMessage($stringValue));
}

return $stringValue;
Expand All @@ -68,9 +66,7 @@ public function parseValue($value): string
$stringValue = Utils::coerceToString($value, Error::class);

if (! static::matchesRegex($stringValue)) {
throw new Error(
static::unmatchedRegexMessage($stringValue)
);
throw new Error(static::unmatchedRegexMessage($stringValue));
}

return $stringValue;
Expand All @@ -81,10 +77,7 @@ public function parseLiteral($valueNode, ?array $variables = null): string
$value = Utils::extractStringFromLiteral($valueNode);

if (! static::matchesRegex($value)) {
throw new Error(
static::unmatchedRegexMessage($value),
$valueNode
);
throw new Error(static::unmatchedRegexMessage($value), $valueNode);
}

return $value;
Expand Down
13 changes: 3 additions & 10 deletions src/StringScalar.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public function serialize($value): string
$stringValue = Utils::coerceToString($value, InvariantViolation::class);

if (! $this->isValid($stringValue)) {
throw new InvariantViolation(
$this->invalidStringMessage($stringValue)
);
throw new InvariantViolation($this->invalidStringMessage($stringValue));
}

return $stringValue;
Expand All @@ -64,9 +62,7 @@ public function parseValue($value): string
$stringValue = Utils::coerceToString($value, Error::class);

if (! $this->isValid($stringValue)) {
throw new Error(
$this->invalidStringMessage($stringValue)
);
throw new Error($this->invalidStringMessage($stringValue));
}

return $stringValue;
Expand All @@ -77,10 +73,7 @@ public function parseLiteral($valueNode, ?array $variables = null): string
$stringValue = Utils::extractStringFromLiteral($valueNode);

if (! $this->isValid($stringValue)) {
throw new Error(
$this->invalidStringMessage($stringValue),
$valueNode
);
throw new Error($this->invalidStringMessage($stringValue), $valueNode);
}

return $stringValue;
Expand Down
5 changes: 1 addition & 4 deletions src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ public static function canBeString(mixed $value): bool
public static function extractStringFromLiteral(Node $valueNode): string
{
if (! $valueNode instanceof StringValueNode) {
throw new Error(
"Query error: Can only parse strings got: {$valueNode->kind}",
$valueNode
);
throw new Error("Query error: Can only parse strings got: {$valueNode->kind}", $valueNode);
}

return $valueNode->value;
Expand Down
Loading