Skip to content

Commit

Permalink
Resolved namespace adjustements
Browse files Browse the repository at this point in the history
  • Loading branch information
peldax committed Jun 7, 2021
1 parent 1066317 commit 47388b2
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 81 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"infinityloop-dev/graphpinator": "^1.0-rc27",
"infinityloop-dev/graphpinator": "^1.0-rc28",
"infinityloop-dev/utils": "^2.1.2",
"nette/utils": "^3.2"
},
Expand Down
53 changes: 28 additions & 25 deletions composer.lock

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

6 changes: 3 additions & 3 deletions src/AlphabeticalSorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
final class AlphabeticalSorter implements \Graphpinator\Printer\Sorter
{
/**
* @param array<\Graphpinator\Type\Contract\NamedDefinition> $types
* @param array<\Graphpinator\Directive\Contract\Definition> $directives
* @return array<\Graphpinator\Type\Contract\NamedDefinition|\Graphpinator\Directive\Contract\Definition>
* @param array<\Graphpinator\Typesystem\Contract\NamedType> $types
* @param array<\Graphpinator\Typesystem\Contract\Directive> $directives
* @return array<\Graphpinator\Typesystem\Contract\NamedType|\Graphpinator\Typesystem\Contract\Directive>
*/
public function sort(array $types, array $directives) : array
{
Expand Down
46 changes: 23 additions & 23 deletions src/HtmlVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ final class HtmlVisitor implements PrintComponentVisitor
private const LINK_TEXTS = ['Q', 'M', 'S'];
private const LINK_TITLES = ['Go to query root type', 'Go to mutation root type', 'Go to subscription root type'];

public function visitSchema(\Graphpinator\Type\Schema $schema) : string
public function visitSchema(\Graphpinator\Typesystem\Schema $schema) : string
{
$query = '<span class="field-type">' . self::printTypeLink($schema->getQuery()) . '</span>';
$mutation = $schema->getMutation() instanceof \Graphpinator\Type\Type
$mutation = $schema->getMutation() instanceof \Graphpinator\Typesystem\Type
? '<span class="field-type">' . self::printTypeLink($schema->getMutation()) . '</span>'
: '<span class="null">null</span>';

$subscription = $schema->getSubscription() instanceof \Graphpinator\Type\Type
$subscription = $schema->getSubscription() instanceof \Graphpinator\Typesystem\Type
? '<span class="field-type">' . self::printTypeLink($schema->getSubscription()) . '</span>'
: '<span class="null">null</span>';

Expand Down Expand Up @@ -56,7 +56,7 @@ public function visitSchema(\Graphpinator\Type\Schema $schema) : string
EOL;
}

public function visitType(\Graphpinator\Type\Type $type) : string
public function visitType(\Graphpinator\Typesystem\Type $type) : string
{
return <<<EOL
<section id="graphql-type-{$type->getName()}">
Expand All @@ -80,7 +80,7 @@ public function visitType(\Graphpinator\Type\Type $type) : string
EOL;
}

public function visitInterface(\Graphpinator\Type\InterfaceType $interface) : string
public function visitInterface(\Graphpinator\Typesystem\InterfaceType $interface) : string
{
return <<<EOL
<section id="graphql-type-{$interface->getName()}">
Expand All @@ -104,7 +104,7 @@ public function visitInterface(\Graphpinator\Type\InterfaceType $interface) : st
EOL;
}

public function visitUnion(\Graphpinator\Type\UnionType $union) : string
public function visitUnion(\Graphpinator\Typesystem\UnionType $union) : string
{
$typeNames = [];

Expand All @@ -129,7 +129,7 @@ public function visitUnion(\Graphpinator\Type\UnionType $union) : string
EOL;
}

public function visitInput(\Graphpinator\Type\InputType $input) : string
public function visitInput(\Graphpinator\Typesystem\InputType $input) : string
{
return <<<EOL
<section id="graphql-type-{$input->getName()}">
Expand All @@ -152,7 +152,7 @@ public function visitInput(\Graphpinator\Type\InputType $input) : string
EOL;
}

public function visitScalar(\Graphpinator\Type\ScalarType $scalar) : string
public function visitScalar(\Graphpinator\Typesystem\ScalarType $scalar) : string
{
return <<<EOL
<section id="graphql-type-{$scalar->getName()}">
Expand All @@ -168,7 +168,7 @@ public function visitScalar(\Graphpinator\Type\ScalarType $scalar) : string
EOL;
}

public function visitEnum(\Graphpinator\Type\EnumType $enum) : string
public function visitEnum(\Graphpinator\Typesystem\EnumType $enum) : string
{
return <<<EOL
<section id="graphql-type-{$enum->getName()}">
Expand All @@ -191,7 +191,7 @@ public function visitEnum(\Graphpinator\Type\EnumType $enum) : string
EOL;
}

public function visitDirective(\Graphpinator\Directive\Directive $directive) : string
public function visitDirective(\Graphpinator\Typesystem\Directive $directive) : string
{
$repeatable = $directive->isRepeatable()
? '&nbsp;<span class="keyword">repeatable</span>'
Expand All @@ -216,7 +216,7 @@ public function visitDirective(\Graphpinator\Directive\Directive $directive) : s
EOL;
}

public function visitField(\Graphpinator\Field\Field $field) : string
public function visitField(\Graphpinator\Typesystem\Field\Field $field) : string
{
$link = self::printTypeLink($field->getType());

Expand All @@ -232,7 +232,7 @@ public function visitField(\Graphpinator\Field\Field $field) : string
EOL;
}

public function visitArgument(\Graphpinator\Argument\Argument $argument) : string
public function visitArgument(\Graphpinator\Typesystem\Argument\Argument $argument) : string
{
$defaultValue = '';
$link = '<span class="argument-type">' . self::printTypeLink($argument->getType()) . '</span>';
Expand Down Expand Up @@ -306,7 +306,7 @@ public function glue(array $entries) : string
/**
* @return array<string>
*/
private static function recursiveGetInterfaces(\Graphpinator\Type\InterfaceSet $implements) : array
private static function recursiveGetInterfaces(\Graphpinator\Typesystem\InterfaceSet $implements) : array
{
$return = [];

Expand All @@ -318,23 +318,23 @@ private static function recursiveGetInterfaces(\Graphpinator\Type\InterfaceSet $
return $return;
}

private static function printTypeLink(\Graphpinator\Type\Contract\Definition $type) : string
private static function printTypeLink(\Graphpinator\Typesystem\Contract\Type $type) : string
{
return match ($type::class) {
\Graphpinator\Type\NotNullType::class =>
\Graphpinator\Typesystem\NotNullType::class =>
self::printTypeLink($type->getInnerType()) .
'<span class="exclamation-mark">!</span>',
\Graphpinator\Type\ListType::class =>
\Graphpinator\Typesystem\ListType::class =>
'<span class="bracket-square">[</span>' .
self::printTypeLink($type->getInnerType()) .
'<span class="bracket-square">]</span>',
default => self::printNamedTypeLink($type),
};
}

private static function printNamedTypeLink(\Graphpinator\Type\Contract\NamedDefinition $type) : string
private static function printNamedTypeLink(\Graphpinator\Typesystem\Contract\NamedType $type) : string
{
$href = \str_starts_with($type->getNamedType()::class, 'Graphpinator\Type\Spec')
$href = \str_starts_with($type->getNamedType()::class, 'Graphpinator\Typesystem\Spec')
? ''
: 'href="#graphql-type-' . $type->getNamedType()->getName() . '"';
$description = self::normalizeString($type->getNamedType()->getDescription());
Expand All @@ -346,7 +346,7 @@ private static function printNamedTypeLink(\Graphpinator\Type\Contract\NamedDefi

private static function printDirectiveLink(\Graphpinator\DirectiveUsage\DirectiveUsage $directiveUsage) : string
{
$href = \str_starts_with($directiveUsage->getDirective()::class, 'Graphpinator\Directive\Spec')
$href = \str_starts_with($directiveUsage->getDirective()::class, 'Graphpinator\Typesystem\Spec')
? ''
: 'href="#graphql-directive-' . $directiveUsage->getDirective()->getName() . '"';
$description = self::normalizeString($directiveUsage->getDirective()->getDescription());
Expand Down Expand Up @@ -389,7 +389,7 @@ private static function emptyLine() : string
return '<div class="line">&nbsp;</div>';
}

private function printImplements(\Graphpinator\Type\InterfaceSet $implements) : string
private function printImplements(\Graphpinator\Typesystem\InterfaceSet $implements) : string
{
if (\count($implements) === 0) {
return '';
Expand All @@ -399,7 +399,7 @@ private function printImplements(\Graphpinator\Type\InterfaceSet $implements) :
. \implode('&nbsp;<span class="ampersand">&</span>&nbsp;', self::recursiveGetInterfaces($implements));
}

private function printDirectiveUsages(\Graphpinator\DirectiveUsage\DirectiveUsageSet $set) : string
private function printDirectiveUsages(\Graphpinator\Typesystem\DirectiveUsage\DirectiveUsageSet $set) : string
{
$return = '';

Expand All @@ -411,7 +411,7 @@ private function printDirectiveUsages(\Graphpinator\DirectiveUsage\DirectiveUsag
}

private function printItems(
\Graphpinator\Field\FieldSet|\Graphpinator\Argument\ArgumentSet|\Graphpinator\EnumItem\EnumItemSet $set,
\Graphpinator\Typesystem\Field\FieldSet|\Graphpinator\Typesystem\Argument\ArgumentSet|\Graphpinator\Typesystem\EnumItem\EnumItemSet $set,
) : string
{
$result = '';
Expand Down Expand Up @@ -489,7 +489,7 @@ private function printValue(\Graphpinator\Value\InputedValue $value) : string
return $openingChar . '<span class="value">' . $components . '</span>' . $closingChar;
}

private function printArguments(\Graphpinator\Directive\Directive|\Graphpinator\Field\Field $component) : string
private function printArguments(\Graphpinator\Typesystem\Directive|\Graphpinator\Typesystem\Field\Field $component) : string
{
if ($component->getArguments()->count() === 0) {
return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
?? new AlphabeticalSorter();
}

public function printSchema(\Graphpinator\Type\Schema $schema) : string
public function printSchema(\Graphpinator\Typesystem\Schema $schema) : string
{
$entries = [$schema->accept($this->visitor)];
$printables = $this->sorter->sort($schema->getContainer()->getTypes(), $schema->getContainer()->getDirectives());
Expand Down
6 changes: 3 additions & 3 deletions src/Sorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
interface Sorter
{
/**
* @param array<\Graphpinator\Type\Contract\NamedDefinition> $types
* @param array<\Graphpinator\Directive\Contract\Definition> $directives
* @return array<\Graphpinator\Type\Contract\NamedDefinition|\Graphpinator\Directive\Contract\Definition>
* @param array<\Graphpinator\Typesystem\Contract\NamedType> $types
* @param array<\Graphpinator\Typesystem\Contract\Directive> $directives
* @return array<\Graphpinator\Typesystem\Contract\NamedType|\Graphpinator\Typesystem\Contract\Directive>
*/
public function sort(array $types, array $directives) : array;
}
Loading

0 comments on commit 47388b2

Please sign in to comment.