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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/src/Tests/
/build/
/phpunit.xml
/.php_cs/cache

node_modules

Expand Down
Empty file added .php_cs/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion .styleci.yml

This file was deleted.

11 changes: 3 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: php
cache:
directories:
- $HOME/.composer/cache
- .php_cs
jobs:
include:
- stage: test
Expand All @@ -14,6 +15,7 @@ jobs:
- &phpunit
"./vendor/bin/phpunit"
- composer phpstan
- composer cs-check
after_script:
- ./vendor/bin/coveralls -v
- stage: test
Expand All @@ -24,14 +26,7 @@ jobs:
script:
- *phpunit
- stage: test
php: 7.1
env: PREFER_LOWEST=""
before_script:
- *composerupdate
script:
- *phpunit
- stage: test
php: 7.1
php: 7.2
env: PREFER_LOWEST="--prefer-lowest"
before_script:
- *composerupdate
Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": ">=7.1",
"php": ">=7.2",
"webonyx/graphql-php": "^0.13",
"psr/container": "^1",
"doctrine/annotations": "^1.2",
Expand All @@ -24,13 +24,14 @@
"symfony/lock": "^3 || ^4"
},
"require-dev": {
"phpunit/phpunit": "^6.1",
"phpunit/phpunit": "^7.5.9",
"satooshi/php-coveralls": "^1.0",
"symfony/cache": "^4.1.4",
"mouf/picotainer": "^1.1",
"phpstan/phpstan": "^0.11",
"beberlei/porpaginas": "^1.2",
"myclabs/php-enum": "^1.6.6"
"myclabs/php-enum": "^1.6.6",
"doctrine/coding-standard": "^6.0"
},
"suggest": {
"beberlei/porpaginas": "If you want automatic pagination in your GraphQL types"
Expand All @@ -46,7 +47,9 @@
}
},
"scripts": {
"phpstan": "phpstan analyse src -c phpstan.neon --level=4 --no-progress -vvv"
"phpstan": "phpstan analyse src -c phpstan.neon --level=4 --no-progress -vvv",
"cs-check": "phpcs",
"cs-fix": "phpcbf"
},
"extra": {
"branch-alias": {
Expand Down
46 changes: 46 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="16"/>
<arg name="cache" value=".php_cs/cache"/>
<arg name="colors"/>

<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>

<!-- Directories to be checked -->
<file>src</file>
<!-- <file>tests</file> -->

<exclude-pattern>tests/dependencies/*</exclude-pattern>

<!-- Include full Doctrine Coding Standard -->
<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix"/>
<exclude name="Squiz.Commenting.FunctionComment.InvalidNoReturn" />
<exclude name="Generic.Formatting.MultipleStatementAlignment" />
</rule>

<!-- Do not align assignments -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<severity>0</severity>
</rule>

<!-- Do not align comments -->
<rule ref="Squiz.Commenting.FunctionComment.SpacingAfterParamName">
<severity>0</severity>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.SpacingAfterParamType">
<severity>0</severity>
</rule>

<!-- Require no space before colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
</ruleset>
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
<testsuites>
Expand All @@ -24,7 +23,7 @@
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
26 changes: 10 additions & 16 deletions src/AggregateControllerQueryProvider.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite;

use Psr\Container\ContainerInterface;
use TheCodingMachine\GraphQLite\Mappers\RecursiveTypeMapperInterface;
use function array_merge;

/**
* A query provider that looks into all controllers of your application to fetch queries.
*/
class AggregateControllerQueryProvider implements QueryProviderInterface
{
/**
* @var array|string[]
*/
/** @var array|string[] */
private $controllers;
/**
* @var ContainerInterface
*/
/** @var ContainerInterface */
private $controllersContainer;
/**
* @var FieldsBuilder
*/
/** @var FieldsBuilder */
private $fieldsBuilder;

/**
* @param string[] $controllers A list of controllers name in the container.
* @param FieldsBuilder $fieldsBuilder
* @param string[] $controllers A list of controllers name in the container.
* @param ContainerInterface $controllersContainer The container we will fetch controllers from.
*/
public function __construct(iterable $controllers, FieldsBuilder $fieldsBuilder, ContainerInterface $controllersContainer)
{
$this->controllers = $controllers;
$this->fieldsBuilder = $fieldsBuilder;
$this->controllers = $controllers;
$this->fieldsBuilder = $fieldsBuilder;
$this->controllersContainer = $controllersContainer;
}

Expand All @@ -45,7 +39,7 @@ public function getQueries(): array

foreach ($this->controllers as $controllerName) {
$controller = $this->controllersContainer->get($controllerName);
$queryList = array_merge($queryList, $this->fieldsBuilder->getQueries($controller));
$queryList = array_merge($queryList, $this->fieldsBuilder->getQueries($controller));
}

return $queryList;
Expand All @@ -59,7 +53,7 @@ public function getMutations(): array
$mutationList = [];

foreach ($this->controllers as $controllerName) {
$controller = $this->controllersContainer->get($controllerName);
$controller = $this->controllersContainer->get($controllerName);
$mutationList = array_merge($mutationList, $this->fieldsBuilder->getMutations($controller));
}

Expand Down
15 changes: 10 additions & 5 deletions src/AggregateQueryProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\GraphQLite;

Expand All @@ -13,9 +14,7 @@
*/
class AggregateQueryProvider implements QueryProviderInterface
{
/**
* @var QueryProviderInterface[]
*/
/** @var QueryProviderInterface[] */
private $queryProviders;

/**
Expand All @@ -31,10 +30,13 @@ public function __construct(iterable $queryProviders)
*/
public function getQueries(): array
{
$queriesArray = array_map(function(QueryProviderInterface $queryProvider) { return $queryProvider->getQueries(); }, $this->queryProviders);
$queriesArray = array_map(static function (QueryProviderInterface $queryProvider) {
return $queryProvider->getQueries();
}, $this->queryProviders);
if ($queriesArray === []) {
return [];
}

return array_merge(...$queriesArray);
}

Expand All @@ -43,10 +45,13 @@ public function getQueries(): array
*/
public function getMutations(): array
{
$mutationsArray = array_map(function(QueryProviderInterface $queryProvider) { return $queryProvider->getMutations(); }, $this->queryProviders);
$mutationsArray = array_map(static function (QueryProviderInterface $queryProvider) {
return $queryProvider->getMutations();
}, $this->queryProviders);
if ($mutationsArray === []) {
return [];
}

return array_merge(...$mutationsArray);
}
}
Loading