diff --git a/.travis.yml b/.travis.yml index 9b8c9b72..2a98613e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ before_install: - echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - export PATH="$PATH:$HOME/.composer/vendor/bin" - wget https://phar.phpunit.de/phpunit-6.3.phar + - composer global require humbug/php-scoper:^1.0@dev - if [[ $coverage = 1 ]]; then mkdir -p build/logs; fi - if [[ $coverage = 1 ]]; then wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; fi - if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.4.0/php-cs-fixer.phar; fi @@ -36,6 +37,8 @@ script: - | if [[ ! $deps && $TRAVIS_PHP_VERSION = "7.1" ]]; then composer install --no-dev --prefer-dist --classmap-authoritative --no-progress --no-suggest --ansi; + ~/.composer/vendor/bin/php-scoper add-prefix --output-dir=build/schema-generator; + composer -d=build/schema-generator dump-autoload --classmap-authoritative --no-dev; php -d phar.readonly=0 box.phar build; php schema.phar generate-types tmp/ tests/e2e/schema.yml; diff tests/e2e/src/AppBundle/Entity/Person.php tmp/AppBundle/Entity/Person.php; diff --git a/box.json b/box.json index 3b1d63e6..75ae97a6 100644 --- a/box.json +++ b/box.json @@ -1,4 +1,5 @@ { + "base-path": "build/schema-generator", "directories": [ "data/", "src/", diff --git a/scoper.inc.php b/scoper.inc.php new file mode 100644 index 00000000..62869308 --- /dev/null +++ b/scoper.inc.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +use Isolated\Symfony\Component\Finder\Finder; + +return [ + 'finders' => [ + Finder::create()->files() + ->in('src') + ->in('data') + ->in('templates'), + Finder::create() + ->files() + ->ignoreVCS(true) + ->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/') + ->exclude([ + 'doc', + 'test', + 'test_old', + 'tests', + 'Test', + 'Tests', + ]) + ->in('vendor'), + Finder::create()->append([ + 'bin/schema', + 'composer.json', + ]), + Finder::create()->append([ + 'vendor/friendsofphp/php-cs-fixer/tests/Test', + ]), + ], + 'whitelist' => [ + 'ApiPlatform\Core\Annotation\ApiProperty', + 'ApiPlatform\Core\Annotation\ApiResource', + ], + 'patchers' => [ + function (string $filePath, string $prefix, string $content): string { + // + // PHP-CS-Fixer patch + // + + if ($filePath === __DIR__.'/vendor/friendsofphp/php-cs-fixer/src/FixerFactory.php') { + return preg_replace( + '/\$fixerClass = \'PhpCsFixer(.*?\;)/', + sprintf('$fixerClass = \'%s\\PhpCsFixer$1', $prefix), + $content + ); + } + + return $content; + }, + ], +];