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
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,17 +335,17 @@ final class Data
* 'merged'?: bool,
* 'number'?: int,
* 'title'?: string,
* ...<int|string, mixed>,
* ...,
* }>,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* } $data
* @param list<array{
* 'code': string,
* 'debugMessage'?: string,
* 'message': string,
* ...<int|string, mixed>,
* ...,
* }> $errors
*/
public function __construct(
Expand Down Expand Up @@ -767,29 +767,29 @@ final class Data
* 'node': array{
* 'id': int,
* 'name': string,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* }>,
* ...<int|string, mixed>,
* ...,
* },
* 'issues': list<array{
* 'id': int,
* 'name': string,
* ...<int|string, mixed>,
* ...,
* }>,
* 'projects': list<array{
* 'id': string,
* 'name': string,
* ...<int|string, mixed>,
* ...,
* }>,
* ...<int|string, mixed>,
* ...,
* } $data
* @param list<array{
* 'code': string,
* 'debugMessage'?: string,
* 'message': string,
* ...<int|string, mixed>,
* ...,
* }> $errors
*/
public function __construct(
Expand Down Expand Up @@ -870,9 +870,9 @@ final class Viewer
* 'project': null|array{
* 'id': string,
* 'name': string,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down Expand Up @@ -1088,7 +1088,7 @@ final class ProjectView
* 'description': null|string,
* 'name': string,
* 'state': null|string,
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down Expand Up @@ -1122,7 +1122,7 @@ final class Project
* 'description': null|string,
* 'name': string,
* 'state': null|string,
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"composer-runtime-api": "^2.0",
"nikic/php-parser": "^5.7",
"phpstan/phpdoc-parser": "^2.3",
"phpstan/phpstan": "^2.1.18",
"phpstan/phpstan": "^2.2.1",
"ruudk/code-generator": "^0.4.7",
"sebastian/diff": "^7 || ^8",
"symfony/console": "^8.0",
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/Generated/Fragment/PullRequestInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class PullRequestInfo
* 'merged': bool,
* 'number': int,
* 'title': string,
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
8 changes: 4 additions & 4 deletions examples/Generated/Query/Search/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ final class Data
* 'merged'?: bool,
* 'number'?: int,
* 'title'?: string,
* ...<int|string, mixed>,
* ...,
* }>,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* } $data
* @param list<array{
* 'code': string,
* 'debugMessage'?: string,
* 'message': string,
* ...<int|string, mixed>,
* ...,
* }> $errors
*/
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ final class SearchResultItemConnection
* 'merged'?: bool,
* 'number'?: int,
* 'title'?: string,
* ...<int|string, mixed>,
* ...,
* }>,
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ final class Node
* 'merged'?: bool,
* 'number'?: int,
* 'title'?: string,
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class AsIssue
* '__typename': 'Issue',
* 'number': int,
* 'title': string,
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion examples/Generated/Query/Search/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @param array{
* 'debugMessage'?: string,
* 'message': string,
* ...<int|string, mixed>,
* ...,
* } $error
*/
public function __construct(array $error)
Expand Down
6 changes: 3 additions & 3 deletions examples/Generated/Query/Viewer/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ final class Data
* @param array{
* 'viewer': array{
* 'login': string,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* } $data
* @param list<array{
* 'code': string,
* 'debugMessage'?: string,
* 'message': string,
* ...<int|string, mixed>,
* ...,
* }> $errors
*/
public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion examples/Generated/Query/Viewer/Data/Viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class Viewer
/**
* @param array{
* 'login': string,
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion examples/Generated/Query/Viewer/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @param array{
* 'debugMessage'?: string,
* 'message': string,
* ...<int|string, mixed>,
* ...,
* } $error
*/
public function __construct(array $error)
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/DataClassGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private function dumpLoadersShape(array $batchedHooks, array $plansByFqcn, CodeG
// which holds every batched hook in the operation, not just the subset a
// single nested class consumes. Extras are typed wide; HookLoader's
// covariant template params let any specific instantiation fit here.
$entries[] = sprintf('...<string, %s<array<int, mixed>, mixed>>', $hookLoader);
$entries[] = sprintf('...<string, %s<array{...}, mixed>>', $hookLoader);

return sprintf("array{\n %s,\n}", implode(",\n ", $entries));
}
Expand Down
24 changes: 15 additions & 9 deletions src/Type/TypeDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Ruudk\GraphQLCodeGenerator\Type;

use Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\TypeIdentifier;

final class TypeDumper
{
Expand Down Expand Up @@ -43,15 +44,20 @@ public static function dump(Type $type, ?callable $importer = null, int $indenta
$extraKey = $type->getExtraKeyType();
$extraValue = $type->getExtraValueType();

// Always emit `...<K, V>` rather than the bare `...` short form:
// PHPStan's `missingType.iterableValue` rule at level 6+ rejects
// the implicit `array-key, mixed` extras, treating them as a
// missing iterable value type.
$items[] = sprintf(
'...<%s, %s>',
self::dump($extraKey ?? Type::arrayKey(), $importer, $indentation + 1),
self::dump($extraValue ?? Type::mixed(), $importer, $indentation + 1),
);
$isDefaultExtras = ($extraKey === null || (
$extraKey->isIdentifiedBy(TypeIdentifier::INT)
&& $extraKey->isIdentifiedBy(TypeIdentifier::STRING)
)) && ($extraValue === null || $extraValue->isIdentifiedBy(TypeIdentifier::MIXED));

if ($isDefaultExtras) {
$items[] = '...';
} else {
$items[] = sprintf(
'...<%s, %s>',
self::dump($extraKey ?? Type::arrayKey(), $importer, $indentation + 1),
self::dump($extraValue ?? Type::mixed(), $importer, $indentation + 1),
);
}
}

if ($items === []) {
Expand Down
14 changes: 7 additions & 7 deletions tests/ConnectionNames/Generated/Query/Test/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,33 @@ final class Data
* 'id': string,
* 'name': string,
* 'status': string,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* }>,
* 'pageInfo': array{
* 'endCursor': null|string,
* 'hasNextPage': bool,
* 'hasPreviousPage': bool,
* 'startCursor': null|string,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* },
* 'viewer': null|array{
* 'createdAt': scalar,
* 'id': string,
* 'name': string,
* 'role': string,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* } $data
* @param list<array{
* 'code': string,
* 'debugMessage'?: string,
* 'message': string,
* ...<int|string, mixed>,
* ...,
* }> $errors
*/
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ final class ProjectConnection
* 'id': string,
* 'name': string,
* 'status': string,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* }>,
* 'pageInfo': array{
* 'endCursor': null|string,
* 'hasNextPage': bool,
* 'hasPreviousPage': bool,
* 'startCursor': null|string,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class PageInfo
* 'hasNextPage': bool,
* 'hasPreviousPage': bool,
* 'startCursor': null|string,
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ final class ProjectEdge
* 'id': string,
* 'name': string,
* 'status': string,
* ...<int|string, mixed>,
* ...,
* },
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class Project
* 'id': string,
* 'name': string,
* 'status': string,
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion tests/ConnectionNames/Generated/Query/Test/Data/Viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class Viewer
* 'id': string,
* 'name': string,
* 'role': string,
* ...<int|string, mixed>,
* ...,
* } $data
*/
public function __construct(
Expand Down
Loading
Loading