Skip to content

Commit

Permalink
Merge pull request #100 from dkarlovi/fix/package-isolation-fixes
Browse files Browse the repository at this point in the history
fix: package isolation issues
  • Loading branch information
dkarlovi authored Feb 28, 2020
2 parents d23e286 + e49edda commit 1d9b3fd
Show file tree
Hide file tree
Showing 33 changed files with 440 additions and 43 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ $symfonySerializer = new \Symfony\Component\Serializer\Serializer([
new \Symfony\Component\Serializer\Normalizer\PropertyNormalizer(),
]);
$normalizer = new \Xezilaires\Bridge\Symfony\Serializer\ObjectSerializer($symfonySerializer);
$iteratorFactory = new \Xezilaires\SpreadsheetIteratorFactory($normalizer);
$iteratorFactory = new \Xezilaires\SpreadsheetIteratorFactory($normalizer, [
\Xezilaires\Bridge\PhpSpreadsheet\Spreadsheet::class,
]);

$iterator = $iteratorFactory->fromFile(
// https://github.com/dkarlovi/xezilaires/raw/master/resources/fixtures/products.xlsx
new \SplFileObject(__DIR__.'/../../resources/fixtures/products.xlsx'),
// https://github.com/dkarlovi/xezilaires-dev/raw/master/src/Xezilaires/Test/resources/fixtures/products.xlsx
new \SplFileObject(__DIR__.'/../../src/Xezilaires/Test/resources/fixtures/products.xlsx'),
new \Xezilaires\Metadata\Mapping(
Model\Product::class,
[
Expand Down Expand Up @@ -72,12 +74,14 @@ $symfonySerializer = new \Symfony\Component\Serializer\Serializer([
new \Symfony\Component\Serializer\Normalizer\PropertyNormalizer(),
]);
$normalizer = new \Xezilaires\Bridge\Symfony\Serializer\ObjectSerializer($symfonySerializer);
$iteratorFactory = new \Xezilaires\SpreadsheetIteratorFactory($normalizer);
$iteratorFactory = new \Xezilaires\SpreadsheetIteratorFactory($normalizer, [
\Xezilaires\Bridge\PhpSpreadsheet\Spreadsheet::class,
]);
$annotationDriver = new \Xezilaires\Metadata\Annotation\AnnotationDriver();

$iterator = $iteratorFactory->fromFile(
// https://github.com/dkarlovi/xezilaires/raw/master/resources/fixtures/products.xlsx
new \SplFileObject(__DIR__.'/../../resources/fixtures/products.xlsx'),
// https://github.com/dkarlovi/xezilaires-dev/raw/master/src/Xezilaires/Test/resources/fixtures/products.xlsx
new \SplFileObject(__DIR__.'/../../src/Xezilaires/Test/resources/fixtures/products.xlsx'),
$annotationDriver->getMetadataMapping(Product::class, ['reverse' => true])
);
```
Expand Down
6 changes: 4 additions & 2 deletions docs/examples/annotations.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
new \Symfony\Component\Serializer\Normalizer\PropertyNormalizer(),
]);
$normalizer = new \Xezilaires\Serializer\ObjectSerializer($symfonySerializer);
$iteratorFactory = new \Xezilaires\SpreadsheetIteratorFactory($normalizer);
$iteratorFactory = new \Xezilaires\SpreadsheetIteratorFactory($normalizer, [
\Xezilaires\Bridge\PhpSpreadsheet\Spreadsheet::class,
]);
$annotationDriver = new \Xezilaires\Metadata\Annotation\AnnotationDriver();
// </demo>

$iterator = $iteratorFactory->fromFile(
// https://github.com/dkarlovi/xezilaires/raw/master/resources/fixtures/products.xlsx
new \SplFileObject(__DIR__.'/../../resources/fixtures/products.xlsx'),
new \SplFileObject(__DIR__.'/../../src/Xezilaires/Test/resources/fixtures/products.xlsx'),
$annotationDriver->getMetadataMapping(Product::class)
);

Expand Down
6 changes: 4 additions & 2 deletions docs/examples/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
new \Symfony\Component\Serializer\Normalizer\PropertyNormalizer(),
]);
$normalizer = new \Xezilaires\Serializer\ObjectSerializer($symfonySerializer);
$iteratorFactory = new \Xezilaires\SpreadsheetIteratorFactory($normalizer);
$iteratorFactory = new \Xezilaires\SpreadsheetIteratorFactory($normalizer, [
\Xezilaires\Bridge\PhpSpreadsheet\Spreadsheet::class,
]);
// </demo>

$iterator = $iteratorFactory->fromFile(
// https://github.com/dkarlovi/xezilaires/raw/master/resources/fixtures/products.xlsx
new \SplFileObject(__DIR__.'/../../resources/fixtures/products.xlsx'),
new \SplFileObject(__DIR__.'/../../src/Xezilaires/Test/resources/fixtures/products.xlsx'),
new \Xezilaires\Metadata\Mapping(
// what class to denormalize into
Model\Product::class,
Expand Down
6 changes: 4 additions & 2 deletions docs/examples/reverse.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
new \Symfony\Component\Serializer\Normalizer\PropertyNormalizer(),
]);
$normalizer = new \Xezilaires\Serializer\ObjectSerializer($symfonySerializer);
$iteratorFactory = new \Xezilaires\SpreadsheetIteratorFactory($normalizer);
$iteratorFactory = new \Xezilaires\SpreadsheetIteratorFactory($normalizer, [
\Xezilaires\Bridge\PhpSpreadsheet\Spreadsheet::class,
]);
$annotationDriver = new \Xezilaires\Metadata\Annotation\AnnotationDriver();
// </demo>

$iterator = $iteratorFactory->fromFile(
// https://github.com/dkarlovi/xezilaires/raw/master/resources/fixtures/products.xlsx
new \SplFileObject(__DIR__.'/../../resources/fixtures/products.xlsx'),
new \SplFileObject(__DIR__.'/../../src/Xezilaires/Test/resources/fixtures/products.xlsx'),
$annotationDriver->getMetadataMapping(Product::class, ['reverse' => true])
);

Expand Down
7 changes: 6 additions & 1 deletion infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"mutators": {
"@default": true,
"IdenticalEqual": false,
"NotIdenticalNotEqual": false
"NotIdenticalNotEqual": false,
"MethodCallRemoval": {
"ignore": [
"Xezilaires\\Bridge\\Symfony\\DependencyInjection\\XezilairesExtension::load::44"
]
}
}
}
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ parameters:
- message: '#Return type \(bool\) of method class@anonymous\/src\/Xezilaires\/Test\/FixtureTrait\.php:28::getRealPath\(\) should be covariant with return type \(string\|false\) of method SplFileInfo::getRealPath\(\)#'
paths:
- %currentWorkingDirectory%/src/Bridge/Spout/Test/SpreadsheetTest.php
- %currentWorkingDirectory%/src/Bridge/Symfony/Test/Functional/XezilairesBundleTest.php
- %currentWorkingDirectory%/src/Xezilaires/Test/Functional/FunctionalTestCase.php
5 changes: 5 additions & 0 deletions src/Bridge/PhpSpreadsheet/Spreadsheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public function __construct(\SplFileObject $file)
$this->file = $file;
}

public static function fromFile(\SplFileObject $file): SpreadsheetInterface
{
return new self($file);
}

/**
* {@inheritdoc}
*/
Expand Down
6 changes: 6 additions & 0 deletions src/Bridge/PhpSpreadsheet/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"dkarlovi/xezilaires": "^0.3",
"phpoffice/phpspreadsheet": "^1.4,>1.4.1"
},
"require-dev": {
"doctrine/annotations": "^1.6",
"phpunit/phpunit": "^8.5",
"symfony/property-access": "^3.4 || ^4.0 || ^5.0",
"symfony/property-info": "^3.4 || ^4.0 || ^5.0"
},
"suggest": {
"dkarlovi/xezilaires-symfony": "Symfony bundle integration, bin/xezilaires use"
},
Expand Down
19 changes: 19 additions & 0 deletions src/Bridge/PhpSpreadsheet/infection.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"phpUnit": {
"customPath": "vendor/bin/phpunit"
},
"timeout": 1,
"source": {
"directories": [
"."
]
},
"logs": {
"text": "var\/infection.log"
},
"mutators": {
"@default": true,
"IdenticalEqual": false,
"NotIdenticalNotEqual": false
}
}
14 changes: 14 additions & 0 deletions src/Bridge/PhpSpreadsheet/phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
includes:
- /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-deprecation-rules/rules.neon
- /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon
- /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-phpunit/extension.neon
parameters:
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
tmpDir: %currentWorkingDirectory%/var/phpstan
level: max
paths:
- ./
excludes_analyse:
- var/
- vendor/
32 changes: 32 additions & 0 deletions src/Bridge/PhpSpreadsheet/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutResourceUsageDuringSmallTests="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="./vendor/autoload.php"
colors="true"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
forceCoversAnnotation="true"
verbose="true">
<testsuites>
<testsuite name="Xezilaires">
<directory>./Test</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./</directory>
<exclude>
<directory suffix=".php">./Exception</directory>
<directory suffix=".php">./Test</directory>
<directory suffix=".php">./var</directory>
<directory suffix=".php">./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
39 changes: 39 additions & 0 deletions src/Bridge/PhpSpreadsheet/psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
cacheDirectory="var/psalm"
totallyTyped="true">

<projectFiles>
<directory name="."/>
<ignoreFiles>
<directory name="var/"/>
<directory name="vendor/"/>
</ignoreFiles>
</projectFiles>

<issueHandlers>
<InternalMethod>
<errorLevel type="info">
<directory name="Test/" />
</errorLevel>
</InternalMethod>
<PropertyNotSetInConstructor>
<errorLevel type="info">
<directory name="Test/" />
</errorLevel>
</PropertyNotSetInConstructor>

<!-- false positives -->
<MixedMethodCall>
<errorLevel type="info">
<file name="Test/RowIteratorTest.php" />
</errorLevel>
</MixedMethodCall>
</issueHandlers>

<mockClasses>
<class name="PHPUnit\Framework\MockObject\MockObject"/>
</mockClasses>
</psalm>
5 changes: 5 additions & 0 deletions src/Bridge/Spout/Spreadsheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public function __construct(\SplFileObject $file)
$this->file = $file;
}

public static function fromFile(\SplFileObject $file): SpreadsheetInterface
{
return new self($file);
}

/**
* {@inheritdoc}
*/
Expand Down
7 changes: 7 additions & 0 deletions src/Bridge/Spout/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
"box/spout": "^3.0",
"dkarlovi/xezilaires": "^0.3"
},
"require-dev": {
"doctrine/annotations": "^1.6",
"nyholm/nsa": "^1.1",
"phpunit/phpunit": "^8.5",
"symfony/property-access": "^3.4 || ^4.0 || ^5.0",
"symfony/property-info": "^3.4 || ^4.0 || ^5.0"
},
"suggest": {
"dkarlovi/xezilaires-symfony": "Symfony bundle integration, bin/xezilaires use"
},
Expand Down
19 changes: 19 additions & 0 deletions src/Bridge/Spout/infection.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"phpUnit": {
"customPath": "vendor/bin/phpunit"
},
"timeout": 1,
"source": {
"directories": [
"."
]
},
"logs": {
"text": "var\/infection.log"
},
"mutators": {
"@default": true,
"IdenticalEqual": false,
"NotIdenticalNotEqual": false
}
}
14 changes: 14 additions & 0 deletions src/Bridge/Spout/phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
includes:
- /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-deprecation-rules/rules.neon
- /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon
- /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-phpunit/extension.neon
parameters:
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
tmpDir: %currentWorkingDirectory%/var/phpstan
level: max
paths:
- ./
excludes_analyse:
- var/
- vendor/
32 changes: 32 additions & 0 deletions src/Bridge/Spout/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutResourceUsageDuringSmallTests="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="./vendor/autoload.php"
colors="true"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
forceCoversAnnotation="true"
verbose="true">
<testsuites>
<testsuite name="Xezilaires">
<directory>./Test</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./</directory>
<exclude>
<directory suffix=".php">./Exception</directory>
<directory suffix=".php">./Test</directory>
<directory suffix=".php">./var</directory>
<directory suffix=".php">./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
39 changes: 39 additions & 0 deletions src/Bridge/Spout/psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
cacheDirectory="var/psalm"
totallyTyped="true">

<projectFiles>
<directory name="."/>
<ignoreFiles>
<directory name="var/"/>
<directory name="vendor/"/>
</ignoreFiles>
</projectFiles>

<issueHandlers>
<InternalMethod>
<errorLevel type="info">
<directory name="Test/" />
</errorLevel>
</InternalMethod>
<PropertyNotSetInConstructor>
<errorLevel type="info">
<directory name="Test/" />
</errorLevel>
</PropertyNotSetInConstructor>

<!-- false positives -->
<MixedMethodCall>
<errorLevel type="info">
<file name="Test/RowIteratorTest.php" />
</errorLevel>
</MixedMethodCall>
</issueHandlers>

<mockClasses>
<class name="PHPUnit\Framework\MockObject\MockObject"/>
</mockClasses>
</psalm>
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function registerBundles(): array
*/
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__.'/resources/config/services.xml');
$loader->load(__DIR__.'/Resources/bin-config/services.xml');
}

public function getCacheDir(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class Application extends BaseApplication
/ . \ __// /| | | (_| | | | | __/\__ \
/_/ \_\___/___|_|_|\__,_|_|_| \___||___/ ';

private const APP_VERSION = '0.1.0';
private const APP_VERSION = '0.3.0';

public function __construct(KernelInterface $kernel)
{
Expand Down
Loading

0 comments on commit 1d9b3fd

Please sign in to comment.