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
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions box.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"base-path": "build/schema-generator",
"directories": [
"data/",
"src/",
Expand Down
64 changes: 64 additions & 0 deletions scoper.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* 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;
},
],
];