diff --git a/.gitignore b/.gitignore
index 496b505..b3337d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@
/composer.lock
/phpunit.coverage.xml
/phpunit.xml
+/.idea
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index e45890c..fbd5e91 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -1,7 +1,7 @@
build:
environment:
php:
- version: '7.0'
+ version: '7.2'
tests:
override:
-
diff --git a/.travis.yml b/.travis.yml
index 6c02786..0f56848 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,24 +6,14 @@ sudo: false
matrix:
fast_finish: true
include:
- - php: '7.0'
- env: SYMFONY_VERSION='3.2.*'
- - php: '7.0'
- env: SYMFONY_VERSION='3.3.*'
- - php: '7.0'
- env: SYMFONY_VERSION='3.4.*'
- php: '7.1'
env: SYMFONY_VERSION='3.4.*'
- php: '7.2'
env: SYMFONY_VERSION='3.4.*'
- - php: '7.1.3'
- env: SYMFONY_VERSION='4.0.*'
- - php: '7.2'
- env: SYMFONY_VERSION='4.0.*'
- - php: '7.1.3'
- env: SYMFONY_VERSION='4.1.*'
+ - php: '7.1'
+ env: SYMFONY_VERSION='4.3.*'
- php: '7.2'
- env: SYMFONY_VERSION='4.1.*'
+ env: SYMFONY_VERSION='4.3.*'
before_install:
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update symfony/symfony=$SYMFONY_VERSION; fi
@@ -32,4 +22,4 @@ install:
- composer update $COMPOSER_FLAGS --prefer-dist --prefer-stable
script:
- - vendor/bin/simple-phpunit
+ - vendor/bin/simple-phpunit --testdox
diff --git a/CHANGELOG.md b/CHANGELOG.md
index de0d92f..897505a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 1.3
+* Improve test
+* Update namespace
+* fix deprecations
+* Update to phpspreadsheet 1.8.1
+
## 1.1
* Fixed issue #13 'Incorrect cache directory for images' (technetium)
diff --git a/LICENSE b/LICENSE
index 0fafcac..38a7ccc 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2017 Mewes Kochheim
+Copyright (c) 2017-2019 Mewes Kochheim, Erőss Elemér
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 9cbec36..fdaddb8 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
# TwigSpreadsheetBundle
-[![Teavis CI: Build Status](https://travis-ci.org/MewesK/TwigSpreadsheetBundle.png?branch=master)](https://travis-ci.org/MewesK/TwigSpreadsheetBundle)
-[![Scrutinizer: Code Quality](https://scrutinizer-ci.com/g/MewesK/TwigSpreadsheetBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/MewesK/TwigSpreadsheetBundle/?branch=master)
-[![Code Coverage](https://scrutinizer-ci.com/g/MewesK/TwigSpreadsheetBundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/MewesK/TwigSpreadsheetBundle/?branch=master)
-[![SensioLabsInsight: Code Quality](https://insight.sensiolabs.com/projects/f5c25ebe-0cbc-4be1-a094-4ef87d48ea1b/mini.png)](https://insight.sensiolabs.com/projects/f5c25ebe-0cbc-4be1-a094-4ef87d48ea1b)
+[![Teavis CI: Build Status](https://travis-ci.org/erelke/TwigSpreadsheetBundle.png?branch=master)](https://travis-ci.org/erelke/TwigSpreadsheetBundle)
+[![Scrutinizer: Code Quality](https://scrutinizer-ci.com/g/erelke/TwigSpreadsheetBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/erelke/TwigSpreadsheetBundle/?branch=master)
+[![Code Coverage](https://scrutinizer-ci.com/g/erelke/TwigSpreadsheetBundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/erelke/TwigSpreadsheetBundle/?branch=master)
+[![SensioLabsInsight: Code Quality](https://insight.sensiolabs.com/projects/6f1d5477-967f-4754-bb95-505b1a50b71c/mini.png)](https://insight.sensiolabs.com/projects/6f1d5477-967f-4754-bb95-505b1a50b71c)
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
@@ -29,8 +29,8 @@ The following software is required to use PhpSpreadsheet/TwigSpreadsheetBundle.
**Required by this bundle:**
- * PHP 7.0 or newer
- * Symfony 3.2 or newer
+ * PHP 7.1 or newer
+ * Symfony 3.4 or newer
**Required by PhpSpreadsheet:**
@@ -43,7 +43,7 @@ The following software is required to use PhpSpreadsheet/TwigSpreadsheetBundle.
The source of the documentation is stored in the Resources/doc/ folder in this bundle:
-[Resources/doc/index.rst](https://github.com/MewesK/TwigSpreadsheetBundle/blob/master/src/Resources/doc/index.rst)
+[Resources/doc/index.rst](https://github.com/erelke/TwigSpreadsheetBundle/blob/master/src/Resources/doc/index.rst)
You can find a prettier version on [readthedocs.org](httsp://readthedocs.org):
@@ -57,4 +57,4 @@ All the installation instructions are located in the documentation.
This bundle is under the MIT license. See the complete license in the bundle:
-[Resources/meta/LICENSE](https://github.com/MewesK/TwigSpreadsheetBundle/blob/master/LICENSE)
+[Resources/meta/LICENSE](https://github.com/erelke/TwigSpreadsheetBundle/blob/master/LICENSE)
diff --git a/composer.json b/composer.json
index f337ee4..0cd1fff 100644
--- a/composer.json
+++ b/composer.json
@@ -31,9 +31,9 @@
"mpdf/mpdf": "Add support for PDF rendering, requires ~7.0"
},
"autoload": {
- "psr-4": { "MewesK\\TwigSpreadsheetBundle\\": "src/" }
+ "psr-4": { "Erelke\\TwigSpreadsheetBundle\\": "src/" }
},
"autoload-dev": {
- "psr-4": { "MewesK\\TwigSpreadsheetBundle\\Tests\\": "tests/" }
+ "psr-4": { "Erelke\\TwigSpreadsheetBundle\\Tests\\": "tests/" }
}
}
diff --git a/phpunit.coverage.xml.dist b/phpunit.coverage.xml.dist
index 2235e9b..d806436 100644
--- a/phpunit.coverage.xml.dist
+++ b/phpunit.coverage.xml.dist
@@ -5,8 +5,15 @@
colors="true"
bootstrap="./vendor/autoload.php"
>
+
+
+
+
+
+
+
-
+
./tests
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index f5edb98..8761b19 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -13,7 +13,7 @@
-
+
./tests
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index 680c29e..ad2ccc7 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -1,9 +1,11 @@
root('mewes_k_twig_spreadsheet');
+ if (version_compare(Kernel::VERSION, '4.3.0', '>=')) {
+ $treeBuilder = new TreeBuilder('erelke_twig_spreadsheet');
+ $rootNode = $treeBuilder->getRootNode();
+ } else {
+ $treeBuilder = new TreeBuilder();
+ $rootNode = $treeBuilder->root('erelke_twig_spreadsheet');
+ }
$rootNode
->children()
diff --git a/src/DependencyInjection/MewesKTwigSpreadsheetExtension.php b/src/DependencyInjection/ErelkeTwigSpreadsheetExtension.php
similarity index 66%
rename from src/DependencyInjection/MewesKTwigSpreadsheetExtension.php
rename to src/DependencyInjection/ErelkeTwigSpreadsheetExtension.php
index 0a1ec06..4111a36 100644
--- a/src/DependencyInjection/MewesKTwigSpreadsheetExtension.php
+++ b/src/DependencyInjection/ErelkeTwigSpreadsheetExtension.php
@@ -1,28 +1,29 @@
load('services.yml');
- $definition = $container->getDefinition('mewes_k_twig_spreadsheet.twig_spreadsheet_extension');
+ $definition = $container->getDefinition('erelke_twig_spreadsheet.twig_spreadsheet_extension');
$definition->replaceArgument(0, $mergedConfig);
}
}
diff --git a/src/ErelkeTwigSpreadsheetBundle.php b/src/ErelkeTwigSpreadsheetBundle.php
new file mode 100644
index 0000000..40af7a2
--- /dev/null
+++ b/src/ErelkeTwigSpreadsheetBundle.php
@@ -0,0 +1,12 @@
+ &$value) {
- $array1[$key] = \is_array($value) && isset($array1[$key]) && \is_array($array1[$key]) ?
+ $array1[$key] = is_array($value) && isset($array1[$key]) && is_array($array1[$key]) ?
self::mergeRecursive($array1[$key], $value) :
$value;
}
diff --git a/src/Helper/Filesystem.php b/src/Helper/Filesystem.php
index 36087b1..a764fd9 100644
--- a/src/Helper/Filesystem.php
+++ b/src/Helper/Filesystem.php
@@ -1,9 +1,10 @@
addDebugInfo($this)
->write(self::CODE_FIX_CONTEXT)
diff --git a/src/Twig/Node/BaseNode.php b/src/Twig/Node/BaseNode.php
index 1d0590e..badb8c0 100644
--- a/src/Twig/Node/BaseNode.php
+++ b/src/Twig/Node/BaseNode.php
@@ -1,13 +1,14 @@
addDebugInfo($this)
->write(self::CODE_FIX_CONTEXT)
diff --git a/src/Twig/Node/DocumentNode.php b/src/Twig/Node/DocumentNode.php
index 726a418..bf79c9e 100644
--- a/src/Twig/Node/DocumentNode.php
+++ b/src/Twig/Node/DocumentNode.php
@@ -1,8 +1,9 @@
addDebugInfo($this)
->write("ob_start();\n")
diff --git a/src/Twig/Node/DrawingNode.php b/src/Twig/Node/DrawingNode.php
index c3906e0..1535e28 100644
--- a/src/Twig/Node/DrawingNode.php
+++ b/src/Twig/Node/DrawingNode.php
@@ -1,6 +1,8 @@
addDebugInfo($this)
->write(self::CODE_FIX_CONTEXT)
diff --git a/src/Twig/Node/HeaderFooterNode.php b/src/Twig/Node/HeaderFooterNode.php
index 72bca1b..8c42884 100644
--- a/src/Twig/Node/HeaderFooterNode.php
+++ b/src/Twig/Node/HeaderFooterNode.php
@@ -1,8 +1,10 @@
addDebugInfo($this)
->write(self::CODE_FIX_CONTEXT)
diff --git a/src/Twig/Node/RowNode.php b/src/Twig/Node/RowNode.php
index dab77fb..e217a96 100644
--- a/src/Twig/Node/RowNode.php
+++ b/src/Twig/Node/RowNode.php
@@ -1,6 +1,8 @@
addDebugInfo($this)
->write(self::CODE_FIX_CONTEXT)
diff --git a/src/Twig/Node/SheetNode.php b/src/Twig/Node/SheetNode.php
index fef6a44..8db8e59 100644
--- a/src/Twig/Node/SheetNode.php
+++ b/src/Twig/Node/SheetNode.php
@@ -1,6 +1,8 @@
addDebugInfo($this)
->write(self::CODE_FIX_CONTEXT)
diff --git a/src/Twig/NodeVisitor/MacroContextNodeVisitor.php b/src/Twig/NodeVisitor/MacroContextNodeVisitor.php
index 44509ba..2d59f82 100644
--- a/src/Twig/NodeVisitor/MacroContextNodeVisitor.php
+++ b/src/Twig/NodeVisitor/MacroContextNodeVisitor.php
@@ -1,13 +1,20 @@
getTemplateLine());
+ if ($node instanceof Twig_Node_Expression_MethodCall) {
+ $keyNode = new Twig_Node_Expression_Constant(PhpSpreadsheetWrapper::INSTANCE_KEY, $node->getTemplateLine());
// add wrapper even if it not exists, we fix that later
- $valueNode = new \Twig_Node_Expression_Name(PhpSpreadsheetWrapper::INSTANCE_KEY, $node->getTemplateLine());
+ $valueNode = new Twig_Node_Expression_Name(PhpSpreadsheetWrapper::INSTANCE_KEY, $node->getTemplateLine());
$valueNode->setAttribute('ignore_strict_check', true);
/**
- * @var \Twig_Node_Expression_Array $argumentsNode
+ * @var Twig_Node_Expression_Array $argumentsNode
*/
$argumentsNode = $node->getNode('arguments');
$argumentsNode->addElement($valueNode, $keyNode);
@@ -43,7 +50,7 @@ protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env)
/**
* {@inheritdoc}
*/
- protected function doLeaveNode(\Twig_Node $node, \Twig_Environment $env)
+ protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
{
return $node;
}
diff --git a/src/Twig/NodeVisitor/SyntaxCheckNodeVisitor.php b/src/Twig/NodeVisitor/SyntaxCheckNodeVisitor.php
index aefed7d..a674373 100644
--- a/src/Twig/NodeVisitor/SyntaxCheckNodeVisitor.php
+++ b/src/Twig/NodeVisitor/SyntaxCheckNodeVisitor.php
@@ -1,14 +1,20 @@
checkAllowedChildren($node);
}
- } catch (\Twig_Error_Syntax $e) {
+ } catch (Twig_Error_Syntax $e) {
// reset path since throwing an error prevents doLeaveNode to be called
$this->path = [];
throw $e;
}
- $this->path[] = $node !== null ? \get_class($node) : null;
+ $this->path[] = $node !== null ? get_class($node) : null;
return $node;
}
@@ -50,7 +56,7 @@ protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env)
/**
* {@inheritdoc}
*/
- protected function doLeaveNode(\Twig_Node $node, \ Twig_Environment $env)
+ protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
{
array_pop($this->path);
@@ -58,27 +64,27 @@ protected function doLeaveNode(\Twig_Node $node, \ Twig_Environment $env)
}
/**
- * @param \Twig_Node $node
+ * @param Twig_Node $node
*
- * @throws \Twig_Error_Syntax
+ * @throws Twig_Error_Syntax
*/
- private function checkAllowedChildren(\Twig_Node $node)
+ private function checkAllowedChildren(Twig_Node $node)
{
$hasDocumentNode = false;
$hasTextNode = false;
/**
- * @var \Twig_Node $currentNode
+ * @var Twig_Node $currentNode
*/
foreach ($node->getIterator() as $currentNode) {
- if ($currentNode instanceof \Twig_Node_Text) {
+ if ($currentNode instanceof Twig_Node_Text) {
if ($hasDocumentNode) {
- throw new \Twig_Error_Syntax(sprintf('Node "%s" is not allowed after Node "%s".', \Twig_Node_Text::class, DocumentNode::class));
+ throw new Twig_Error_Syntax(sprintf('Node "%s" is not allowed after Node "%s".', Twig_Node_Text::class, DocumentNode::class));
}
$hasTextNode = true;
} elseif ($currentNode instanceof DocumentNode) {
if ($hasTextNode) {
- throw new \Twig_Error_Syntax(sprintf('Node "%s" is not allowed before Node "%s".', \Twig_Node_Text::class, DocumentNode::class));
+ throw new Twig_Error_Syntax(sprintf('Node "%s" is not allowed before Node "%s".', Twig_Node_Text::class, DocumentNode::class));
}
$hasDocumentNode = true;
}
@@ -88,7 +94,7 @@ private function checkAllowedChildren(\Twig_Node $node)
/**
* @param BaseNode $node
*
- * @throws \Twig_Error_Syntax
+ * @throws Twig_Error_Syntax
*/
private function checkAllowedParents(BaseNode $node)
{
@@ -96,7 +102,7 @@ private function checkAllowedParents(BaseNode $node)
// find first parent from this bundle
foreach (array_reverse($this->path) as $className) {
- if (strpos($className, 'MewesK\\TwigSpreadsheetBundle\\Twig\\Node\\') === 0) {
+ if (strpos($className, 'Erelke\\TwigSpreadsheetBundle\\Twig\\Node\\') === 0) {
$parentName = $className;
break;
}
@@ -114,6 +120,6 @@ private function checkAllowedParents(BaseNode $node)
}
}
- throw new \Twig_Error_Syntax(sprintf('Node "%s" is not allowed inside of Node "%s".', \get_class($node), $parentName));
+ throw new Twig_Error_Syntax(sprintf('Node "%s" is not allowed inside of Node "%s".', get_class($node), $parentName));
}
}
diff --git a/src/Twig/TokenParser/AlignmentTokenParser.php b/src/Twig/TokenParser/AlignmentTokenParser.php
index b64e88e..4efeb44 100644
--- a/src/Twig/TokenParser/AlignmentTokenParser.php
+++ b/src/Twig/TokenParser/AlignmentTokenParser.php
@@ -1,9 +1,11 @@
getAttributes(), $lineNo, $this->getTag(), $this->alignment);
}
diff --git a/src/Twig/TokenParser/BaseTokenParser.php b/src/Twig/TokenParser/BaseTokenParser.php
index facbcc3..8912225 100644
--- a/src/Twig/TokenParser/BaseTokenParser.php
+++ b/src/Twig/TokenParser/BaseTokenParser.php
@@ -1,11 +1,21 @@
parseParameters($this->configureParameters($token));
@@ -90,22 +100,22 @@ public function parse(\Twig_Token $token)
/**
* @param array $parameterConfiguration
*
- * @throws \Exception
- * @throws \InvalidArgumentException
- * @throws \Twig_Error_Syntax
+ * @throws Exception
+ * @throws InvalidArgumentException
+ * @throws Twig_Error_Syntax
*
- * @return \Twig_Node_Expression[]
+ * @return Twig_Node_Expression[]
*/
private function parseParameters(array $parameterConfiguration = []): array
{
// parse expressions
$expressions = [];
- while (!$this->parser->getStream()->test(\Twig_Token::BLOCK_END_TYPE)) {
+ while (!$this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) {
$expressions[] = $this->parser->getExpressionParser()->parseExpression();
}
// end of expressions
- $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
// map expressions to parameters
$parameters = [];
@@ -116,14 +126,14 @@ private function parseParameters(array $parameterConfiguration = []): array
switch ($parameterOptions['type']) {
case self::PARAMETER_TYPE_ARRAY:
// check if expression is valid array
- $valid = $expression instanceof \Twig_Node_Expression_Array;
+ $valid = $expression instanceof Twig_Node_Expression_Array;
break;
case self::PARAMETER_TYPE_VALUE:
// check if expression is valid value
- $valid = !($expression instanceof \Twig_Node_Expression_Array);
+ $valid = !($expression instanceof Twig_Node_Expression_Array);
break;
default:
- throw new \InvalidArgumentException('Invalid parameter type');
+ throw new InvalidArgumentException('Invalid parameter type');
}
if ($valid) {
@@ -135,27 +145,27 @@ private function parseParameters(array $parameterConfiguration = []): array
// set default as parameter otherwise or throw exception if default is false
if ($parameterOptions['default'] === false) {
- throw new \Twig_Error_Syntax('A required parameter is missing');
+ throw new Twig_Error_Syntax('A required parameter is missing');
}
$parameters[$parameterName] = $parameterOptions['default'];
}
- if (\count($expressions) > 0) {
- throw new \Twig_Error_Syntax('Too many parameters');
+ if (count($expressions) > 0) {
+ throw new Twig_Error_Syntax('Too many parameters');
}
return $parameters;
}
/**
- * @return \Twig_Node
- * @throws \Twig_Error_Syntax
+ * @return Twig_Node
+ * @throws Twig_Error_Syntax
*/
- private function parseBody(): \Twig_Node
+ private function parseBody(): Twig_Node
{
// parse till matching end tag is found
- $body = $this->parser->subparse(function (\Twig_Token $token) { return $token->test('end'.$this->getTag()); }, true);
- $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
+ $body = $this->parser->subparse(function (Twig_Token $token) { return $token->test('end'.$this->getTag()); }, true);
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
return $body;
}
}
diff --git a/src/Twig/TokenParser/CellTokenParser.php b/src/Twig/TokenParser/CellTokenParser.php
index d040c69..137416e 100644
--- a/src/Twig/TokenParser/CellTokenParser.php
+++ b/src/Twig/TokenParser/CellTokenParser.php
@@ -1,8 +1,12 @@
[
'type' => self::PARAMETER_TYPE_VALUE,
- 'default' => new \Twig_Node_Expression_Constant(null, $token->getLine()),
+ 'default' => new Twig_Node_Expression_Constant(null, $token->getLine()),
],
'properties' => [
'type' => self::PARAMETER_TYPE_ARRAY,
- 'default' => new \Twig_Node_Expression_Array([], $token->getLine()),
+ 'default' => new Twig_Node_Expression_Array([], $token->getLine()),
],
];
}
@@ -29,7 +33,7 @@ public function configureParameters(\Twig_Token $token): array
/**
* {@inheritdoc}
*/
- public function createNode(array $nodes = [], int $lineNo = 0): \Twig_Node
+ public function createNode(array $nodes = [], int $lineNo = 0): Twig_Node
{
return new CellNode($nodes, $this->getAttributes(), $lineNo, $this->getTag());
}
diff --git a/src/Twig/TokenParser/DocumentTokenParser.php b/src/Twig/TokenParser/DocumentTokenParser.php
index a0804d8..7482e5a 100644
--- a/src/Twig/TokenParser/DocumentTokenParser.php
+++ b/src/Twig/TokenParser/DocumentTokenParser.php
@@ -1,8 +1,11 @@
[
'type' => self::PARAMETER_TYPE_ARRAY,
- 'default' => new \Twig_Node_Expression_Array([], $token->getLine()),
+ 'default' => new Twig_Node_Expression_Array([], $token->getLine()),
],
];
}
@@ -25,7 +28,7 @@ public function configureParameters(\Twig_Token $token): array
/**
* {@inheritdoc}
*/
- public function createNode(array $nodes = [], int $lineNo = 0): \Twig_Node
+ public function createNode(array $nodes = [], int $lineNo = 0): Twig_Node
{
return new DocumentNode($nodes, $this->getAttributes(), $lineNo, $this->getTag());
}
diff --git a/src/Twig/TokenParser/DrawingTokenParser.php b/src/Twig/TokenParser/DrawingTokenParser.php
index 4442f83..7a35cdc 100644
--- a/src/Twig/TokenParser/DrawingTokenParser.php
+++ b/src/Twig/TokenParser/DrawingTokenParser.php
@@ -1,8 +1,11 @@
[
@@ -21,7 +24,7 @@ public function configureParameters(\Twig_Token $token): array
],
'properties' => [
'type' => self::PARAMETER_TYPE_ARRAY,
- 'default' => new \Twig_Node_Expression_Array([], $token->getLine()),
+ 'default' => new Twig_Node_Expression_Array([], $token->getLine()),
],
];
}
@@ -29,7 +32,7 @@ public function configureParameters(\Twig_Token $token): array
/**
* {@inheritdoc}
*/
- public function createNode(array $nodes = [], int $lineNo = 0): \Twig_Node
+ public function createNode(array $nodes = [], int $lineNo = 0): Twig_Node
{
return new DrawingNode($nodes, $this->getAttributes(), $lineNo, $this->getTag());
}
diff --git a/src/Twig/TokenParser/HeaderFooterTokenParser.php b/src/Twig/TokenParser/HeaderFooterTokenParser.php
index 01e64ea..30a1df6 100644
--- a/src/Twig/TokenParser/HeaderFooterTokenParser.php
+++ b/src/Twig/TokenParser/HeaderFooterTokenParser.php
@@ -1,9 +1,14 @@
[
'type' => self::PARAMETER_TYPE_VALUE,
- 'default' => new \Twig_Node_Expression_Constant(null, $token->getLine()),
+ 'default' => new Twig_Node_Expression_Constant(null, $token->getLine()),
],
'properties' => [
'type' => self::PARAMETER_TYPE_ARRAY,
- 'default' => new \Twig_Node_Expression_Array([], $token->getLine()),
+ 'default' => new Twig_Node_Expression_Array([], $token->getLine()),
],
];
}
@@ -50,9 +55,9 @@ public function configureParameters(\Twig_Token $token): array
/**
* {@inheritdoc}
*
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
- public function createNode(array $nodes = [], int $lineNo = 0): \Twig_Node
+ public function createNode(array $nodes = [], int $lineNo = 0): Twig_Node
{
return new HeaderFooterNode($nodes, $this->getAttributes(), $lineNo, $this->getTag(), $this->baseType);
}
diff --git a/src/Twig/TokenParser/RowTokenParser.php b/src/Twig/TokenParser/RowTokenParser.php
index 8b48b3e..657af06 100644
--- a/src/Twig/TokenParser/RowTokenParser.php
+++ b/src/Twig/TokenParser/RowTokenParser.php
@@ -1,8 +1,11 @@
[
'type' => self::PARAMETER_TYPE_VALUE,
- 'default' => new \Twig_Node_Expression_Constant(null, $token->getLine()),
+ 'default' => new Twig_Node_Expression_Constant(null, $token->getLine()),
],
];
}
@@ -25,7 +28,7 @@ public function configureParameters(\Twig_Token $token): array
/**
* {@inheritdoc}
*/
- public function createNode(array $nodes = [], int $lineNo = 0): \Twig_Node
+ public function createNode(array $nodes = [], int $lineNo = 0): Twig_Node
{
return new RowNode($nodes, $this->getAttributes(), $lineNo, $this->getTag());
}
diff --git a/src/Twig/TokenParser/SheetTokenParser.php b/src/Twig/TokenParser/SheetTokenParser.php
index 59cb7a7..62c7ce5 100644
--- a/src/Twig/TokenParser/SheetTokenParser.php
+++ b/src/Twig/TokenParser/SheetTokenParser.php
@@ -1,8 +1,12 @@
[
'type' => self::PARAMETER_TYPE_VALUE,
- 'default' => new \Twig_Node_Expression_Constant(null, $token->getLine()),
+ 'default' => new Twig_Node_Expression_Constant(null, $token->getLine()),
],
'properties' => [
'type' => self::PARAMETER_TYPE_ARRAY,
- 'default' => new \Twig_Node_Expression_Array([], $token->getLine()),
+ 'default' => new Twig_Node_Expression_Array([], $token->getLine()),
],
];
}
@@ -29,7 +33,7 @@ public function configureParameters(\Twig_Token $token): array
/**
* {@inheritdoc}
*/
- public function createNode(array $nodes = [], int $lineNo = 0): \Twig_Node
+ public function createNode(array $nodes = [], int $lineNo = 0): Twig_Node
{
return new SheetNode($nodes, $this->getAttributes(), $lineNo, $this->getTag());
}
diff --git a/src/Twig/TwigSpreadsheetExtension.php b/src/Twig/TwigSpreadsheetExtension.php
index d135fc8..7dc59ab 100644
--- a/src/Twig/TwigSpreadsheetExtension.php
+++ b/src/Twig/TwigSpreadsheetExtension.php
@@ -1,25 +1,29 @@
true]),
- new \Twig_SimpleFunction('xlsrowindex', [$this, 'getCurrentRow'], ['needs_context' => true]),
+ new Twig_SimpleFunction('xlsmergestyles', [$this, 'mergeStyles']),
+ new Twig_SimpleFunction('xlscellindex', [$this, 'getCurrentColumn'], ['needs_context' => true]),
+ new Twig_SimpleFunction('xlsrowindex', [$this, 'getCurrentRow'], ['needs_context' => true]),
];
}
/**
* {@inheritdoc}
*
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function getTokenParsers()
{
@@ -92,14 +96,14 @@ public function getNodeVisitors()
* @param array $style1
* @param array $style2
*
- * @throws \Twig_Error_Runtime
+ * @throws Twig_Error_Runtime
*
* @return array
*/
public function mergeStyles(array $style1, array $style2): array
{
- if (!\is_array($style1) || !\is_array($style2)) {
- throw new \Twig_Error_Runtime('The xlsmergestyles function only works with arrays.');
+ if (!is_array($style1) || !is_array($style2)) {
+ throw new Twig_Error_Runtime('The xlsmergestyles function only works with arrays.');
}
return Arrays::mergeRecursive($style1, $style2);
}
@@ -107,13 +111,13 @@ public function mergeStyles(array $style1, array $style2): array
/**
* @param array $context
*
- * @throws \Twig_Error_Runtime
+ * @throws Twig_Error_Runtime
*
* @return int|null
*/
public function getCurrentColumn(array $context) {
if (!isset($context[PhpSpreadsheetWrapper::INSTANCE_KEY])) {
- throw new \Twig_Error_Runtime('The PhpSpreadsheetWrapper instance is missing.');
+ throw new Twig_Error_Runtime('The PhpSpreadsheetWrapper instance is missing.');
}
return $context[PhpSpreadsheetWrapper::INSTANCE_KEY]->getCurrentColumn();
}
@@ -121,13 +125,13 @@ public function getCurrentColumn(array $context) {
/**
* @param array $context
*
- * @throws \Twig_Error_Runtime
+ * @throws Twig_Error_Runtime
*
* @return int|null
*/
public function getCurrentRow(array $context) {
if (!isset($context[PhpSpreadsheetWrapper::INSTANCE_KEY])) {
- throw new \Twig_Error_Runtime('The PhpSpreadsheetWrapper instance is missing.');
+ throw new Twig_Error_Runtime('The PhpSpreadsheetWrapper instance is missing.');
}
return $context[PhpSpreadsheetWrapper::INSTANCE_KEY]->getCurrentRow();
}
diff --git a/src/Wrapper/BaseWrapper.php b/src/Wrapper/BaseWrapper.php
index 57f9cb6..94a20b5 100644
--- a/src/Wrapper/BaseWrapper.php
+++ b/src/Wrapper/BaseWrapper.php
@@ -1,6 +1,11 @@
context = $context;
$this->environment = $environment;
@@ -88,7 +93,7 @@ protected function configureMappings(): array
* @param array|null $mappings
* @param string|null $column
*
- * @throws \RuntimeException
+ * @throws RuntimeException
*/
protected function setProperties(array $properties, array $mappings = null, string $column = null)
{
@@ -98,10 +103,10 @@ protected function setProperties(array $properties, array $mappings = null, stri
foreach ($properties as $key => $value) {
if (!isset($mappings[$key])) {
- throw new \RuntimeException(sprintf('Missing mapping for key "%s"', $key));
+ throw new RuntimeException(sprintf('Missing mapping for key "%s"', $key));
}
- if (\is_array($value) && \is_array($mappings[$key])) {
+ if (is_array($value) && is_array($mappings[$key])) {
// recursion
if (isset($mappings[$key]['__multi'])) {
// handle multi target structure (with columns)
@@ -115,7 +120,7 @@ protected function setProperties(array $properties, array $mappings = null, stri
// handle single target structure
$this->setProperties($value, $mappings[$key]);
}
- } elseif (\is_callable($mappings[$key])) {
+ } elseif (is_callable($mappings[$key])) {
// call single and multi target mapping
// if column is set it is used to get object from the callback in __multi
$mappings[$key](
@@ -123,7 +128,7 @@ protected function setProperties(array $properties, array $mappings = null, stri
$column !== null ? $mappings['__multi']($column) : null
);
} else {
- throw new \RuntimeException(sprintf('Invalid mapping for key "%s"', $key));
+ throw new RuntimeException(sprintf('Invalid mapping for key "%s"', $key));
}
}
}
diff --git a/src/Wrapper/CellWrapper.php b/src/Wrapper/CellWrapper.php
index 1a10cb8..eb0d73f 100644
--- a/src/Wrapper/CellWrapper.php
+++ b/src/Wrapper/CellWrapper.php
@@ -1,9 +1,15 @@
sheetWrapper->getObject() === null) {
- throw new \LogicException();
+ throw new LogicException();
}
if ($index === null) {
@@ -68,7 +74,7 @@ public function start(int $index = null, array $properties = [])
/**
* @param mixed|null $value
*
- * @throws \PhpOffice\PhpSpreadsheet\Exception
+ * @throws Exception
*/
public function value($value = null)
{
@@ -105,11 +111,11 @@ public function setObject(Cell $object = null)
$this->object = $object;
}
- /**
- * {@inheritdoc}
- *
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- */
+ /**
+ * {@inheritdoc}
+ *
+ * @return array
+ */
protected function configureMappings(): array
{
return [
@@ -131,7 +137,7 @@ protected function configureMappings(): array
'type' => function ($value) { $this->object->getDataValidation()->setType($value); },
],
'merge' => function ($value) {
- if (\is_int($value)) {
+ if (is_int($value)) {
$value = Coordinate::stringFromColumnIndex($value).$this->sheetWrapper->getRow();
}
$this->sheetWrapper->getObject()->mergeCells(sprintf('%s:%s', $this->object->getCoordinate(), $value));
diff --git a/src/Wrapper/DocumentWrapper.php b/src/Wrapper/DocumentWrapper.php
index eb42967..8d87a55 100644
--- a/src/Wrapper/DocumentWrapper.php
+++ b/src/Wrapper/DocumentWrapper.php
@@ -1,15 +1,24 @@
object === null) {
- throw new \LogicException();
+ throw new LogicException();
}
$format = null;
@@ -100,7 +109,7 @@ public function end()
}
// set default
- if ($format === null || !\is_string($format)) {
+ if ($format === null || !is_string($format)) {
$format = 'xlsx';
} else {
$format = strtolower($format);
@@ -109,7 +118,7 @@ public function end()
// set up mPDF
if ($format === 'pdf') {
if (!class_exists('\Mpdf\Mpdf')) {
- throw new \RuntimeException('Error loading mPDF. Is mPDF correctly installed?');
+ throw new RuntimeException('Error loading mPDF. Is mPDF correctly installed?');
}
IOFactory::registerWriter('Pdf', Mpdf::class);
}
@@ -162,11 +171,11 @@ public function setObject(Spreadsheet $object = null)
$this->object = $object;
}
- /**
- * {@inheritdoc}
- *
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- */
+ /**
+ * {@inheritdoc}
+ *
+ * @return array
+ */
protected function configureMappings(): array
{
return [
@@ -207,9 +216,9 @@ private function expandPath(string $path): string
{
$loader = $this->environment->getLoader();
- if ($loader instanceof \Twig_Loader_Filesystem && mb_strpos($path, '@') === 0) {
+ if ($loader instanceof Twig_Loader_Filesystem && mb_strpos($path, '@') === 0) {
/*
- * @var \Twig_Loader_Filesystem
+ * @var Twig_Loader_Filesystem
*/
foreach ($loader->getNamespaces() as $namespace) {
if (mb_strpos($path, $namespace) === 1) {
diff --git a/src/Wrapper/DrawingWrapper.php b/src/Wrapper/DrawingWrapper.php
index d7d015e..21ec297 100644
--- a/src/Wrapper/DrawingWrapper.php
+++ b/src/Wrapper/DrawingWrapper.php
@@ -1,10 +1,16 @@
sheetWrapper->getObject() === null) {
- throw new \LogicException();
+ throw new LogicException();
}
// create local copy of the asset
@@ -88,7 +94,7 @@ public function start(string $path, array $properties = [])
$headerFooterParameters['value'][HeaderFooterWrapper::ALIGNMENT_RIGHT] .= '&G';
break;
default:
- throw new \InvalidArgumentException(sprintf('Unknown alignment type "%s"', $alignment));
+ throw new InvalidArgumentException(sprintf('Unknown alignment type "%s"', $alignment));
}
$location .= $headerFooterParameters['baseType'] === HeaderFooterWrapper::BASETYPE_HEADER ? 'H' : 'F';
@@ -161,8 +167,8 @@ protected function configureMappings(): array
/**
* @param string $path
*
- * @throws \InvalidArgumentException
- * @throws \Symfony\Component\Filesystem\Exception\IOException
+ * @throws InvalidArgumentException
+ * @throws IOException
*
* @return string
*/
@@ -176,7 +182,7 @@ private function createTempCopy(string $path): string
if (!Filesystem::exists($tempPath)) {
$data = file_get_contents($path);
if ($data === false) {
- throw new \InvalidArgumentException($path.' does not exist.');
+ throw new InvalidArgumentException($path.' does not exist.');
}
Filesystem::dumpFile($tempPath, $data);
unset($data);
diff --git a/src/Wrapper/HeaderFooterWrapper.php b/src/Wrapper/HeaderFooterWrapper.php
index df2612e..c79f60c 100644
--- a/src/Wrapper/HeaderFooterWrapper.php
+++ b/src/Wrapper/HeaderFooterWrapper.php
@@ -1,8 +1,13 @@
sheetWrapper->getObject() === null) {
- throw new \LogicException();
+ throw new LogicException();
}
if ($type !== null) {
$type = strtolower($type);
- if (!\in_array($type, [self::TYPE_EVEN, self::TYPE_FIRST, self::TYPE_ODD], true)) {
- throw new \InvalidArgumentException(sprintf('Unknown type "%s"', $type));
+ if (!in_array($type, [self::TYPE_EVEN, self::TYPE_FIRST, self::TYPE_ODD], true)) {
+ throw new InvalidArgumentException(sprintf('Unknown type "%s"', $type));
}
}
@@ -116,13 +121,13 @@ public function start(string $baseType, string $type = null, array $properties =
}
/**
- * @throws \InvalidArgumentException
- * @throws \LogicException
+ * @throws InvalidArgumentException
+ * @throws LogicException
*/
public function end()
{
if ($this->object === null) {
- throw new \LogicException();
+ throw new LogicException();
}
$value = implode('', $this->parameters['value']);
@@ -173,13 +178,13 @@ public function end()
* @param string $alignment
* @param array $properties
*
- * @throws \InvalidArgumentException
- * @throws \LogicException
+ * @throws InvalidArgumentException
+ * @throws LogicException
*/
public function startAlignment(string $alignment, array $properties = [])
{
if ($this->object === null) {
- throw new \LogicException();
+ throw new LogicException();
}
$alignment = self::validateAlignment(strtolower($alignment));
@@ -203,13 +208,13 @@ public function startAlignment(string $alignment, array $properties = [])
/**
* @param string $value
*
- * @throws \InvalidArgumentException
- * @throws \LogicException
+ * @throws InvalidArgumentException
+ * @throws LogicException
*/
public function endAlignment($value)
{
if ($this->object === null || !isset($this->alignmentParameters['type'])) {
- throw new \LogicException();
+ throw new LogicException();
}
if (strpos($this->parameters['value'][$this->alignmentParameters['type']], '&G') === false) {
diff --git a/src/Wrapper/PhpSpreadsheetWrapper.php b/src/Wrapper/PhpSpreadsheetWrapper.php
index c65f9ff..8690e8b 100644
--- a/src/Wrapper/PhpSpreadsheetWrapper.php
+++ b/src/Wrapper/PhpSpreadsheetWrapper.php
@@ -1,6 +1,16 @@
documentWrapper = new DocumentWrapper($context, $environment, $attributes);
$this->sheetWrapper = new SheetWrapper($context, $environment, $this->documentWrapper);
@@ -95,9 +105,9 @@ public function getCurrentRow()
/**
* @param array $properties
*
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
- * @throws \RuntimeException
+ * @throws Exception
+ * @throws Reader_Exception
+ * @throws RuntimeException
*/
public function startDocument(array $properties = [])
{
@@ -105,12 +115,12 @@ public function startDocument(array $properties = [])
}
/**
- * @throws \RuntimeException
- * @throws \LogicException
- * @throws \InvalidArgumentException
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
- * @throws \Symfony\Component\Filesystem\Exception\IOException
+ * @throws RuntimeException
+ * @throws LogicException
+ * @throws InvalidArgumentException
+ * @throws Exception
+ * @throws Writer_Exception
+ * @throws IOException
*/
public function endDocument()
{
@@ -121,9 +131,9 @@ public function endDocument()
* @param int|string|null $index
* @param array $properties
*
- * @throws \LogicException
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- * @throws \RuntimeException
+ * @throws LogicException
+ * @throws Exception
+ * @throws RuntimeException
*/
public function startSheet($index = null, array $properties = [])
{
@@ -131,7 +141,7 @@ public function startSheet($index = null, array $properties = [])
}
/**
- * @throws \LogicException
+ * @throws LogicException
* @throws \Exception
*/
public function endSheet()
@@ -142,7 +152,7 @@ public function endSheet()
/**
* @param int|null $index
*
- * @throws \LogicException
+ * @throws LogicException
*/
public function startRow(int $index = null)
{
@@ -150,7 +160,7 @@ public function startRow(int $index = null)
}
/**
- * @throws \LogicException
+ * @throws LogicException
*/
public function endRow()
{
@@ -161,9 +171,9 @@ public function endRow()
* @param int|null $index
* @param array $properties
*
- * @throws \InvalidArgumentException
- * @throws \LogicException
- * @throws \RuntimeException
+ * @throws InvalidArgumentException
+ * @throws LogicException
+ * @throws RuntimeException
*/
public function startCell(int $index = null, array $properties = [])
{
@@ -173,7 +183,7 @@ public function startCell(int $index = null, array $properties = [])
/**
* @param null|mixed $value
*
- * @throws \PhpOffice\PhpSpreadsheet\Exception
+ * @throws Exception
*/
public function setCellValue($value = null)
{
@@ -190,9 +200,9 @@ public function endCell()
* @param string|null $type
* @param array $properties
*
- * @throws \LogicException
- * @throws \RuntimeException
- * @throws \InvalidArgumentException
+ * @throws LogicException
+ * @throws RuntimeException
+ * @throws InvalidArgumentException
*/
public function startHeaderFooter(string $baseType, string $type = null, array $properties = [])
{
@@ -200,8 +210,8 @@ public function startHeaderFooter(string $baseType, string $type = null, array $
}
/**
- * @throws \LogicException
- * @throws \InvalidArgumentException
+ * @throws LogicException
+ * @throws InvalidArgumentException
*/
public function endHeaderFooter()
{
@@ -212,8 +222,8 @@ public function endHeaderFooter()
* @param null|string $type
* @param array $properties
*
- * @throws \InvalidArgumentException
- * @throws \LogicException
+ * @throws InvalidArgumentException
+ * @throws LogicException
*/
public function startAlignment(string $type = null, array $properties = [])
{
@@ -223,8 +233,8 @@ public function startAlignment(string $type = null, array $properties = [])
/**
* @param null|string $value
*
- * @throws \InvalidArgumentException
- * @throws \LogicException
+ * @throws InvalidArgumentException
+ * @throws LogicException
*/
public function endAlignment(string $value = null)
{
@@ -235,11 +245,11 @@ public function endAlignment(string $value = null)
* @param string $path
* @param array $properties
*
- * @throws \Symfony\Component\Filesystem\Exception\IOException
- * @throws \InvalidArgumentException
- * @throws \LogicException
- * @throws \RuntimeException
- * @throws \PhpOffice\PhpSpreadsheet\Exception
+ * @throws IOException
+ * @throws InvalidArgumentException
+ * @throws LogicException
+ * @throws RuntimeException
+ * @throws Exception
*/
public function startDrawing(string $path, array $properties = [])
{
diff --git a/src/Wrapper/RowWrapper.php b/src/Wrapper/RowWrapper.php
index 7b14e7a..8ad6167 100644
--- a/src/Wrapper/RowWrapper.php
+++ b/src/Wrapper/RowWrapper.php
@@ -1,6 +1,9 @@
sheetWrapper->getObject() === null) {
- throw new \LogicException();
+ throw new LogicException();
}
if ($index === null) {
@@ -45,12 +48,12 @@ public function start(int $index = null)
}
/**
- * @throws \LogicException
+ * @throws LogicException
*/
public function end()
{
if ($this->sheetWrapper->getObject() === null) {
- throw new \LogicException();
+ throw new LogicException();
}
$this->sheetWrapper->setColumn(null);
diff --git a/src/Wrapper/SheetWrapper.php b/src/Wrapper/SheetWrapper.php
index 53d4fdc..4e06bc5 100644
--- a/src/Wrapper/SheetWrapper.php
+++ b/src/Wrapper/SheetWrapper.php
@@ -1,11 +1,17 @@
documentWrapper->getObject() === null) {
- throw new \LogicException();
+ throw new LogicException();
}
- if (\is_int($index) && $index < $this->documentWrapper->getObject()->getSheetCount()) {
+ if (is_int($index) && $index < $this->documentWrapper->getObject()->getSheetCount()) {
$this->object = $this->documentWrapper->getObject()->setActiveSheetIndex($index);
- } elseif (\is_string($index)) {
+ } elseif (is_string($index)) {
if (!$this->documentWrapper->getObject()->sheetNameExists($index)) {
// create new sheet with a name
$this->documentWrapper->getObject()->createSheet()->setTitle($index);
@@ -93,18 +99,18 @@ public function start($index, array $properties = [])
/**
* @throws \Exception
- * @throws \LogicException
+ * @throws LogicException
*/
public function end()
{
if ($this->object === null) {
- throw new \LogicException();
+ throw new LogicException();
}
// auto-size columns
if (
isset($this->parameters['properties']['columnDimension']) &&
- \is_array($this->parameters['properties']['columnDimension'])
+ is_array($this->parameters['properties']['columnDimension'])
) {
/**
* @var array $columnDimension
@@ -194,11 +200,11 @@ public function setColumn($column)
$this->column = $column;
}
- /**
- * {@inheritdoc}
- *
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- */
+ /**
+ * {@inheritdoc}
+ *
+ * @return array
+ */
protected function configureMappings(): array
{
return [
diff --git a/tests/Functional/BaseFunctionalTest.php b/tests/Functional/BaseFunctionalTest.php
index 534b520..cb3280c 100644
--- a/tests/Functional/BaseFunctionalTest.php
+++ b/tests/Functional/BaseFunctionalTest.php
@@ -1,9 +1,9 @@
getContainer()->get('mewes_k_twig_spreadsheet.twig_spreadsheet_extension');
+ $extension = static::$kernel->getContainer()->get('erelke_twig_spreadsheet.twig_spreadsheet_extension');
static::assertFalse($extension->getAttributes()['pre_calculate_formulas'], 'Unexpected attribute');
@@ -34,31 +35,31 @@ public function testPreCalculateFormulas()
}
/**
- * @throws \Exception
+ * @throws Exception
*/
public function testXmlCacheDirectory()
{
// make request to fill the disk cache
- $response = $this->getResponse('test_default', ['templateName' => 'simple']);
+ $response = $this->_getResponse('test_default', ['templateName' => 'simple']);
static::assertNotNull($response, 'Response does not exist');
/**
* @var TwigSpreadsheetExtension $extension
*/
- $extension = static::$kernel->getContainer()->get('mewes_k_twig_spreadsheet.twig_spreadsheet_extension');
+ $extension = static::$kernel->getContainer()->get('erelke_twig_spreadsheet.twig_spreadsheet_extension');
static::assertDirectoryExists($extension->getAttributes()['cache']['xml'], 'Cache directory does not exist');
}
/**
- * @throws \Exception
+ * @throws Exception
*/
public function testCsvWriterAttributes()
{
/**
* @var TwigSpreadsheetExtension $extension
*/
- $extension = static::$kernel->getContainer()->get('mewes_k_twig_spreadsheet.twig_spreadsheet_extension');
+ $extension = static::$kernel->getContainer()->get('erelke_twig_spreadsheet.twig_spreadsheet_extension');
static::assertEquals(';', $extension->getAttributes()['csv_writer']['delimiter'], 'Unexpected attribute');
static::assertEquals('\'', $extension->getAttributes()['csv_writer']['enclosure'], 'Unexpected attribute');
diff --git a/tests/Functional/Fixtures/TestAppKernel.php b/tests/Functional/Fixtures/TestAppKernel.php
index f15c16a..a41cd41 100644
--- a/tests/Functional/Fixtures/TestAppKernel.php
+++ b/tests/Functional/Fixtures/TestAppKernel.php
@@ -1,7 +1,13 @@
getResponse('test_custom_response', ['templateName' => 'simple', '_format' => $format]);
+ $response = $this->_getResponse('test_custom_response', ['templateName' => 'simple', '_format' => $format]);
static::assertNotNull($response, 'Response does not exist');
static::assertContains('foobar.bin', $response->headers->get('Content-Disposition'), 'Unexpected or missing header "Content-Disposition"');
@@ -65,7 +67,7 @@ public function testCustomResponse($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
@@ -86,7 +88,7 @@ public function testDocumentTemplatePath1($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
diff --git a/tests/Twig/BaseTwigTest.php b/tests/Twig/BaseTwigTest.php
index b23756e..39240cd 100644
--- a/tests/Twig/BaseTwigTest.php
+++ b/tests/Twig/BaseTwigTest.php
@@ -1,15 +1,21 @@
addPath(sprintf('%s/%s', __DIR__, static::TEMPLATE_PATH), 'templates');
- static::$environment = new \Twig_Environment($twigFileSystem, ['debug' => true, 'strict_variables' => true]);
+ static::$environment = new Twig_Environment($twigFileSystem, ['debug' => true, 'strict_variables' => true]);
static::$environment->addExtension(new TwigSpreadsheetExtension([
'pre_calculate_formulas' => true,
'cache' => [
@@ -63,18 +69,16 @@ public static function setUpBeforeClass()
static::$environment->setCache($cachePath.'/twig');
}
- /**
- * @param string $templateName
- * @param string $format
- *
- * @throws \Twig_Error_Syntax
- * @throws \Twig_Error_Loader
- * @throws \Symfony\Component\Filesystem\Exception\IOException
- *
- * @return Spreadsheet|string
- * @throws \Twig_Error_Runtime
- * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
- */
+ /**
+ * @param string $templateName
+ * @param string $format
+ *
+ * @return Spreadsheet|string
+ * @throws Exception
+ * @throws Twig_Error_Loader
+ * @throws RuntimeError
+ * @throws SyntaxError
+ */
protected function getDocument($templateName, $format)
{
$format = strtolower($format);
diff --git a/tests/Twig/CsvOdsXlsXlsxErrorTwigTest.php b/tests/Twig/CsvOdsXlsXlsxErrorTwigTest.php
index 0d8cf3c..cc65696 100644
--- a/tests/Twig/CsvOdsXlsXlsxErrorTwigTest.php
+++ b/tests/Twig/CsvOdsXlsXlsxErrorTwigTest.php
@@ -1,6 +1,10 @@
expectException(\Twig_Error_Syntax::class);
- $this->expectExceptionMessage('Node "MewesK\TwigSpreadsheetBundle\Twig\Node\DocumentNode" is not allowed inside of Node "MewesK\TwigSpreadsheetBundle\Twig\Node\SheetNode"');
+ $this->expectException(Twig_Error_Syntax::class);
+ $this->expectExceptionMessage('Node "Erelke\TwigSpreadsheetBundle\Twig\Node\DocumentNode" is not allowed inside of Node "Erelke\TwigSpreadsheetBundle\Twig\Node\SheetNode"');
$this->getDocument('documentError', $format);
}
@@ -37,14 +41,14 @@ public function testDocumentError($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
public function testDocumentErrorTextAfter($format)
{
- $this->expectException(\Twig_Error_Syntax::class);
- $this->expectExceptionMessage('Node "Twig_Node_Text" is not allowed after Node "MewesK\TwigSpreadsheetBundle\Twig\Node\DocumentNode"');
+ $this->expectException(Twig_Error_Syntax::class);
+ $this->expectExceptionMessage('Node "Twig\Node\TextNode" is not allowed after Node "Erelke\TwigSpreadsheetBundle\Twig\Node\DocumentNode"');
$this->getDocument('documentErrorTextAfter', $format);
}
@@ -52,14 +56,14 @@ public function testDocumentErrorTextAfter($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
public function testDocumentErrorTextBefore($format)
{
- $this->expectException(\Twig_Error_Syntax::class);
- $this->expectExceptionMessage('Node "Twig_Node_Text" is not allowed before Node "MewesK\TwigSpreadsheetBundle\Twig\Node\DocumentNode"');
+ $this->expectException(Twig_Error_Syntax::class);
+ $this->expectExceptionMessage('Node "Twig\Node\TextNode" is not allowed before Node "Erelke\TwigSpreadsheetBundle\Twig\Node\DocumentNode"');
$this->getDocument('documentErrorTextBefore', $format);
}
@@ -67,14 +71,14 @@ public function testDocumentErrorTextBefore($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
public function testStartCellIndexError($format)
{
- $this->expectException(\TypeError::class);
- $this->expectExceptionMessage('Argument 1 passed to MewesK\TwigSpreadsheetBundle\Wrapper\PhpSpreadsheetWrapper::startCell() must be of the type int or null');
+ $this->expectException(TypeError::class);
+ $this->expectExceptionMessage('Argument 1 passed to Erelke\TwigSpreadsheetBundle\Wrapper\PhpSpreadsheetWrapper::startCell() must be of the type int or null');
$this->getDocument('cellIndexError', $format);
}
@@ -82,13 +86,13 @@ public function testStartCellIndexError($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
public function testStartRowIndexError($format)
{
- $this->expectException(\TypeError::class);
+ $this->expectException(TypeError::class);
$this->expectExceptionMessage('Argument 1 passed to MewesK\TwigSpreadsheetBundle\Wrapper\PhpSpreadsheetWrapper::startRow() must be of the type int or null');
$this->getDocument('rowIndexError', $format);
@@ -97,14 +101,14 @@ public function testStartRowIndexError($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
public function testSheetError($format)
{
- $this->expectException(\Twig_Error_Syntax::class);
- $this->expectExceptionMessage('Node "MewesK\TwigSpreadsheetBundle\Twig\Node\RowNode" is not allowed inside of Node "MewesK\TwigSpreadsheetBundle\Twig\Node\DocumentNode"');
+ $this->expectException(Twig_Error_Syntax::class);
+ $this->expectExceptionMessage('Node "Erelke\TwigSpreadsheetBundle\Twig\Node\RowNode" is not allowed inside of Node "Erelke\TwigSpreadsheetBundle\Twig\Node\DocumentNode"');
$this->getDocument('sheetError', $format);
}
diff --git a/tests/Twig/CsvOdsXlsXlsxTwigTest.php b/tests/Twig/CsvOdsXlsXlsxTwigTest.php
index f6d7047..76915f4 100644
--- a/tests/Twig/CsvOdsXlsXlsxTwigTest.php
+++ b/tests/Twig/CsvOdsXlsXlsxTwigTest.php
@@ -1,6 +1,8 @@
getDescription(), 'Unexpected value in description');
- // +/- 24h range to allow possible timezone differences (946684800)
- static::assertGreaterThanOrEqual(946598400, $properties->getModified(), 'Unexpected value in modified');
- static::assertLessThanOrEqual(946771200, $properties->getModified(), 'Unexpected value in modified');
+
+ if ($format === 'ods') {
+ // +/- 60s range
+ $now = new DateTime();
+ $timestamp = $now->getTimestamp();
+ static::assertGreaterThanOrEqual($timestamp - 60, $properties->getModified(), 'Unexpected value in modified');
+ static::assertLessThanOrEqual($timestamp + 60, $properties->getModified(), 'Unexpected value in modified');
+ } else {
+ // +/- 24h range to allow possible timezone differences (946684800)
+ static::assertGreaterThanOrEqual(946598400, $properties->getModified(), 'Unexpected value in modified');
+ static::assertLessThanOrEqual(946771200, $properties->getModified(), 'Unexpected value in modified');
+ }
$security = $document->getSecurity();
static::assertNotNull($security, 'Security does not exist');
@@ -317,7 +328,7 @@ public function testDocumentProperties($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
@@ -338,7 +349,7 @@ public function testDocumentWhitespace($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
@@ -365,7 +376,7 @@ public function testInclude($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
@@ -398,7 +409,7 @@ public function testMacro($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
@@ -427,7 +438,7 @@ public function testRowIndex($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
@@ -445,7 +456,7 @@ public function testSheet($format)
/**
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
@@ -486,7 +497,7 @@ public function testSheetComplex($format)
*
* @param string $format
*
- * @throws \Exception
+ * @throws Exception
*
* @dataProvider formatProvider
*/
diff --git a/tests/Twig/PdfTwigTest.php b/tests/Twig/PdfTwigTest.php
index 1955ac3..79b38a1 100644
--- a/tests/Twig/PdfTwigTest.php
+++ b/tests/Twig/PdfTwigTest.php
@@ -1,6 +1,8 @@
markTestSkipped('We don\'t use pdf, now...');
+
$path = $this->getDocument('cellProperties', $format);
static::assertFileExists($path, 'File does not exist');
diff --git a/tests/Twig/XlsXlsxTwigTest.php b/tests/Twig/XlsXlsxTwigTest.php
index 7beb075..8221532 100644
--- a/tests/Twig/XlsXlsxTwigTest.php
+++ b/tests/Twig/XlsXlsxTwigTest.php
@@ -1,7 +1,8 @@