Skip to content

Commit

Permalink
Merge branch '0.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg-web committed Mar 4, 2019
2 parents 14b9754 + cf7f4fc commit b177a21
Show file tree
Hide file tree
Showing 45 changed files with 3,227 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,6 +1,7 @@
phpunit.xml
/build
/vendor
/lib/*/vendor
/bin
composer.lock
composer.phar
Expand Down
2 changes: 1 addition & 1 deletion .php_cs.dist
Expand Up @@ -3,7 +3,7 @@
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->name('*.php')
->in(__DIR__)
->in([__DIR__.'/src', __DIR__.'/tests'])
;

return PhpCsFixer\Config::create()
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Expand Up @@ -12,26 +12,23 @@
],
"autoload": {
"psr-4": {
"Overblog\\GraphQLBundle\\": "src"
"Overblog\\GraphQLBundle\\": "src/",
"Overblog\\GraphQLGenerator\\": "lib/generator/src/"
}
},
"autoload-dev": {
"psr-4": {
"Overblog\\GraphQLBundle\\Benchmarks\\": "benchmarks",
"Overblog\\GraphQLBundle\\Tests\\": "tests"
},
"files": [
"vendor/overblog/graphql-php-generator/tests/DateTimeType.php",
"vendor/overblog/graphql-php-generator/tests/Resolver.php"
]
"Overblog\\GraphQLBundle\\Benchmarks\\": "benchmarks/",
"Overblog\\GraphQLBundle\\Tests\\": "tests/",
"Overblog\\GraphQLGenerator\\Tests\\": "lib/generator/tests/"
}
},
"config" : {
"bin-dir": "bin",
"sort-packages": true
},
"require": {
"php": ">=7.1",
"overblog/graphql-php-generator": "^0.7.4",
"psr/log": "^1.0",
"symfony/config": "^3.4 || ^4.0",
"symfony/dependency-injection": "^3.4 || ^4.0",
Expand All @@ -42,6 +39,9 @@
"symfony/property-access": "^3.4 || ^4.0",
"webonyx/graphql-php": "^0.12.0"
},
"replace": {
"overblog/graphql-php-generator": "self.version"
},
"suggest": {
"nelmio/cors-bundle": "For more flexibility when using CORS prefight",
"overblog/graphiql-bundle": "If you want to use graphiQL.",
Expand All @@ -60,8 +60,6 @@
"symfony/phpunit-bridge": "^3.4 || ^4.0",
"symfony/process": "^3.4 || ^4.0",
"symfony/security-bundle": "^3.4 || ^4.0",
"symfony/templating": "^3.4 || ^4.0",
"symfony/web-profiler-bundle": "^3.4 || ^4.0",
"symfony/yaml": "^3.4 || ^4.0"
},
"extra": {
Expand All @@ -80,11 +78,13 @@
"fix-cs": [
"@install-cs",
"@php php-cs-fixer.phar self-update",
"@php php-cs-fixer.phar fix --diff -v --allow-risky=yes --ansi"
"@php php-cs-fixer.phar fix --diff -v --allow-risky=yes --ansi",
"@php php-cs-fixer.phar fix --config=lib/generator/.php_cs.dist --diff -v --allow-risky=yes --ansi"
],
"check-cs": [
"@install-cs",
"@php php-cs-fixer.phar fix --dry-run --diff -v --allow-risky=yes --ansi"
"@php php-cs-fixer.phar fix --dry-run --diff -v --allow-risky=yes --ansi",
"@php php-cs-fixer.phar fix --config=lib/generator/.php_cs.dist --dry-run --diff -v --allow-risky=yes --ansi"
],
"code-quality": [
"rm composer.lock",
Expand Down
7 changes: 7 additions & 0 deletions lib/generator/.gitignore
@@ -0,0 +1,7 @@
/vendor/
/bin/
/composer.lock
/composer.phar
/phpunit.xml
/.php_cs
/.php_cs.cache
44 changes: 44 additions & 0 deletions lib/generator/.php_cs.dist
@@ -0,0 +1,44 @@
<?php

/*
* This file is part of the OverblogGraphQLPhpGenerator package.
*
* (c) Overblog <http://github.com/overblog/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$header = <<<EOF
This file is part of the OverblogGraphQLPhpGenerator package.
(c) Overblog <http://github.com/overblog/>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->name('*.php')
->in([__DIR__.'/src', __DIR__.'/tests'])
;

return PhpCsFixer\Config::create()
->setUsingCache(true)
->setFinder($finder)
->setRules([
'@PSR2' => true,
'single_blank_line_before_namespace' => true,
'ordered_imports' => true,
'concat_space' => ['spacing' => 'none'],
'phpdoc_no_alias_tag' => ['type' => 'var'],
'no_mixed_echo_print' => ['use' => 'echo'],
'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false],
'general_phpdoc_annotation_remove' => ['author', 'category', 'copyright', 'created', 'license', 'package', 'since', 'subpackage', 'version'],
'native_function_invocation' => true,
'fully_qualified_strict_types' => true,
'native_constant_invocation' => true,
'header_comment' => ['header' => $header],
])
;
7 changes: 7 additions & 0 deletions lib/generator/.scrutinizer.yml
@@ -0,0 +1,7 @@
tools:
external_code_coverage:
timeout: 1200
build:
tests:
override:
- true
59 changes: 59 additions & 0 deletions lib/generator/.travis.yml
@@ -0,0 +1,59 @@
dist: trusty

language: php

git:
depth: 50

branches:
only:
- master
- /^\d+\.\d+$/

cache:
directories:
- $HOME/.composer/cache
- $HOME/.php_cs.cache

before_install:
- if [ "${STABILITY}" != "" ]; then perl -pi -e 's/^}$/,"minimum-stability":"'"${STABILITY}"'"}/' composer.json; fi;
- if [ "${PHPUNIT_VERSION}" != "" ]; then composer req "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update; fi;
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
- composer selfupdate
- if [ $GRAPHQLPHP_VERSION ]; then composer require "webonyx/graphql-php:${GRAPHQLPHP_VERSION}" --dev --no-update; fi;

install: travis_retry composer update --prefer-source --no-interaction --optimize-autoloader ${COMPOSER_UPDATE_FLAGS}

script: bin/phpunit --color=always -v --debug

jobs:
include:
- stage: Test
php: 5.6
- php: 7.0
- php: 7.1
- php: 7.1
env: COMPOSER_UPDATE_FLAGS=--prefer-lowest
- php: 7.2
- php: 7.3
- php: nightly
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs

- stage: Code Quality
php: 7.2
env: COVERAGE
before_script:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
script: bin/phpunit --color=always -v --debug -d xdebug.max_nesting_level=1000 --coverage-clover=build/logs/clover.xml
after_script:
- wget https://scrutinizer-ci.com/ocular.phar && travis_retry php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml

- stage: Code Quality
php: 7.2
env: CODING_STANDARDS
script: bin/php-cs-fixer fix --dry-run --diff -v --allow-risky=yes --ansi

allow_failures:
- php: nightly
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
21 changes: 21 additions & 0 deletions lib/generator/LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Overblog

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
74 changes: 74 additions & 0 deletions lib/generator/README.md
@@ -0,0 +1,74 @@
OverblogGraphQLPhpGenerator
===========================


GraphQL PHP types generator...

[![Code Coverage](https://scrutinizer-ci.com/g/overblog/GraphQLPhpGenerator/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/overblog/GraphQLPhpGenerator/?branch=master)
[![Build Status](https://travis-ci.org/overblog/GraphQLPhpGenerator.svg?branch=master)](https://travis-ci.org/overblog/GraphQLPhpGenerator)

Requirements
------------
PHP >= 5.4

Installation
------------

```bash
composer require overblog/graphql-php-generator
```

Usage
-----

```php
<?php
$loader = require __DIR__.'/vendor/autoload.php';

use GraphQL\Schema;
use Overblog\GraphQLGenerator\Generator\TypeGenerator;
use Symfony\Component\ExpressionLanguage\Expression;

$configs = [
'Character' => [
'type' => 'interface',
'config' => [
'description' => new Expression('\'A character\' ~ \' in the Star Wars Trilogy\''),
'fields' => [
'id' => ['type' => 'String!', 'description' => 'The id of the character.'],
'name' => ['type' => 'String', 'description' => 'The name of the character.'],
'friends' => ['type' => '[Character]', 'description' => 'The friends of the character.'],
'appearsIn' => ['type' => '[Episode]', 'description' => 'Which movies they appear in.'],
],
'resolveType' => 'Overblog\\GraphQLGenerator\\Tests\\Resolver::resolveType',
],
],
/*...*/
'Query' => [
'type' => 'object',
'config' => [
'description' => 'A humanoid creature in the Star Wars universe or a faction in the Star Wars saga.',
'fields' => [
'hero' => [
'type' => 'Character',
'args' => [
'episode' => [
'type' => 'Episode',
'description' => 'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.',
],
],
'resolve' => ['Overblog\\GraphQLGenerator\\Tests\\Resolver', 'getHero'],
],
],
],
/*...*/
],
];

$typeGenerator = new TypeGenerator('\\My\\Schema\\NP');
$classesMap = $typeGenerator->generateClasses($configs, __DIR__ . '/cache/types');

$loader->addClassMap($classesMap);

$schema = new Schema(\My\Schema\NP\QueryType::getInstance());
```
39 changes: 39 additions & 0 deletions lib/generator/composer.json
@@ -0,0 +1,39 @@
{
"name": "overblog/graphql-php-generator",
"type": "library",
"description": "GraphQL types generator",
"keywords": ["GraphQL", "type", "generator"],
"license": "MIT",
"authors": [
{
"name": "Overblog",
"homepage": "http://www.over-blog.com"
}
],
"config" : {
"sort-packages": true,
"bin-dir": "bin"
},
"require": {
"php": ">=5.6",
"webonyx/graphql-php": "^0.11.2|^0.12.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
"phpunit/phpunit": "^5.7.26 || ^6.0 || ^7.2",
"symfony/expression-language": "^3.4",
"symfony/filesystem": "^3.4",
"symfony/process": "^3.4",
"symfony/yaml": "^3.4"
},
"autoload": {
"psr-4": {
"Overblog\\GraphQLGenerator\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Overblog\\GraphQLGenerator\\Tests\\": "tests/"
}
}
}
35 changes: 35 additions & 0 deletions lib/generator/phpunit.xml.dist
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="overblog/graphql-php-generator Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./tests</directory>
<directory>./src/Overblog/Resources</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>

<php>
<ini name="error_reporting" value="E_ALL"/>
</php>

</phpunit>

0 comments on commit b177a21

Please sign in to comment.