generated from spawnia/php-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Escape class names of result types named after PHP reserved keywords
- Loading branch information
Showing
32 changed files
with
283 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\PhpKeywords\Operations; | ||
|
||
/** | ||
* @extends \Spawnia\Sailor\Operation<\Spawnia\Sailor\PhpKeywords\Operations\AllCases\AllCasesResult> | ||
*/ | ||
class AllCases extends \Spawnia\Sailor\Operation | ||
{ | ||
public static function execute(): AllCases\AllCasesResult | ||
{ | ||
return self::executeOperation( | ||
); | ||
} | ||
|
||
protected static function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
]; | ||
} | ||
|
||
public static function document(): string | ||
{ | ||
return /* @lang GraphQL */ 'query AllCases { | ||
__typename | ||
cases { | ||
__typename | ||
id | ||
} | ||
}'; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'php-keywords'; | ||
} | ||
|
||
public static function config(): string | ||
{ | ||
return \Safe\realpath(__DIR__ . '/../../sailor.php'); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
examples/php-keywords/expected/Operations/AllCases/AllCases.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\PhpKeywords\Operations\AllCases; | ||
|
||
/** | ||
* @property array<int, \Spawnia\Sailor\PhpKeywords\Operations\AllCases\Cases\_Case> $cases | ||
* @property string $__typename | ||
*/ | ||
class AllCases extends \Spawnia\Sailor\ObjectLike | ||
{ | ||
/** | ||
* @param array<int, \Spawnia\Sailor\PhpKeywords\Operations\AllCases\Cases\_Case> $cases | ||
*/ | ||
public static function make($cases): self | ||
{ | ||
$instance = new self; | ||
|
||
if ($cases !== self::UNDEFINED) { | ||
$instance->cases = $cases; | ||
} | ||
$instance->__typename = 'Query'; | ||
|
||
return $instance; | ||
} | ||
|
||
protected function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
'cases' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\ListConverter(new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\PhpKeywords\Operations\AllCases\Cases\_Case))), | ||
'__typename' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\StringConverter), | ||
]; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'php-keywords'; | ||
} | ||
|
||
public static function config(): string | ||
{ | ||
return \Safe\realpath(__DIR__ . '/../../../sailor.php'); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/php-keywords/expected/Operations/AllCases/AllCasesErrorFreeResult.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\PhpKeywords\Operations\AllCases; | ||
|
||
class AllCasesErrorFreeResult extends \Spawnia\Sailor\ErrorFreeResult | ||
{ | ||
public AllCases $data; | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'php-keywords'; | ||
} | ||
|
||
public static function config(): string | ||
{ | ||
return \Safe\realpath(__DIR__ . '/../../../sailor.php'); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
examples/php-keywords/expected/Operations/AllCases/AllCasesResult.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\PhpKeywords\Operations\AllCases; | ||
|
||
class AllCasesResult extends \Spawnia\Sailor\Result | ||
{ | ||
public ?AllCases $data = null; | ||
|
||
protected function setData(\stdClass $data): void | ||
{ | ||
$this->data = AllCases::fromStdClass($data); | ||
} | ||
|
||
/** | ||
* Useful for instantiation of successful mocked results. | ||
* | ||
* @return static | ||
*/ | ||
public static function fromData(AllCases $data): self | ||
{ | ||
$instance = new static; | ||
$instance->data = $data; | ||
|
||
return $instance; | ||
} | ||
|
||
public function errorFree(): AllCasesErrorFreeResult | ||
{ | ||
return AllCasesErrorFreeResult::fromResult($this); | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'php-keywords'; | ||
} | ||
|
||
public static function config(): string | ||
{ | ||
return \Safe\realpath(__DIR__ . '/../../../sailor.php'); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
examples/php-keywords/expected/Operations/AllCases/Cases/_Case.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\PhpKeywords\Operations\AllCases\Cases; | ||
|
||
/** | ||
* @property string $id | ||
* @property string $__typename | ||
*/ | ||
class _Case extends \Spawnia\Sailor\ObjectLike | ||
{ | ||
/** | ||
* @param string $id | ||
*/ | ||
public static function make($id): self | ||
{ | ||
$instance = new self; | ||
|
||
if ($id !== self::UNDEFINED) { | ||
$instance->id = $id; | ||
} | ||
$instance->__typename = 'Case'; | ||
|
||
return $instance; | ||
} | ||
|
||
protected function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
'id' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\IDConverter), | ||
'__typename' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\StringConverter), | ||
]; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'php-keywords'; | ||
} | ||
|
||
public static function config(): string | ||
{ | ||
return \Safe\realpath(__DIR__ . '/../../../../sailor.php'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,9 @@ query Catch { | |
} | ||
} | ||
} | ||
|
||
query AllCases { | ||
cases { | ||
id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.