diff --git a/.php_cs.dist b/.php_cs.dist
index 59a7eea8..6c6d0e3f 100644
--- a/.php_cs.dist
+++ b/.php_cs.dist
@@ -10,38 +10,48 @@ return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setFinder($finder)
->setRules([
+ 'align_multiline_comment' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_return' => true,
+ 'blank_line_before_statement' => true,
'braces' => true,
'cast_spaces' => true,
'class_definition' => true,
'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
+ 'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'declare_strict_types' => false, // Too early to adopt strict types
'dir_constant' => true,
+ 'doctrine_annotation_array_assignment' => true,
+ 'doctrine_annotation_braces' => true,
+ 'doctrine_annotation_indentation' => true,
+ 'doctrine_annotation_spaces' => true,
'elseif' => true,
'encoding' => true,
'ereg_to_preg' => true,
'full_opening_tag' => true,
'function_declaration' => true,
+ 'function_to_constant' => true,
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false, // No use for that
'hash_to_slash_comment' => true,
'header_comment' => false, // We don't use common header in all our files
'heredoc_to_nowdoc' => false, // Not sure about this one
- 'is_null' => false, // Risky
'include' => true,
'indentation_type' => true,
- 'line_ending' => true,
+ 'is_null' => ['use_yoda_style' => false],
'linebreak_after_opening_tag' => true,
+ 'line_ending' => true,
+ 'list_syntax' => ['syntax' => 'short'],
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
+ 'magic_constant_casing' => true,
'mb_str_functions' => false, // No, too dangerous to change that
'method_argument_space' => true,
'method_separation' => true,
@@ -53,44 +63,47 @@ return PhpCsFixer\Config::create()
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
+ 'no_break_comment' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'useTrait', 'curly_brace_block', 'parenthesis_brace_block', 'square_brace_block'],
+ 'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
+ 'non_printable_character' => true,
+ 'no_null_property_initialization' => true,
'no_php4_constructor' => true,
+ 'normalize_index_brace' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
+ 'no_superfluous_elseif' => false, // Might be risky on a huge code base
+ 'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
+ 'not_operator_with_successor_space' => false, // idem
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
- 'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
+ 'no_trailing_whitespace' => true,
'no_unneeded_control_parentheses' => true,
+ 'no_unneeded_curly_braces' => true,
+ 'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
- 'normalize_index_brace' => true,
- 'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
- 'not_operator_with_successor_space' => false, // idem
'object_operator_without_whitespace' => true,
'ordered_class_elements' => false, // We prefer to keep some freedom
'ordered_imports' => true,
- 'php_unit_construct' => true,
- 'php_unit_dedicate_assert' => true,
- 'php_unit_fqcn_annotation' => true,
- 'php_unit_strict' => false, // We sometime actually need assertEquals
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => false, // Waste of time
'phpdoc_annotation_without_dot' => true,
@@ -109,8 +122,14 @@ return PhpCsFixer\Config::create()
'phpdoc_summary' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
+ 'phpdoc_types_order' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
+ 'php_unit_construct' => true,
+ 'php_unit_dedicate_assert' => true,
+ 'php_unit_fqcn_annotation' => true,
+ 'php_unit_strict' => false, // We sometime actually need assertEquals
+ 'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage
'pow_to_exponentiation' => false,
'pre_increment' => true,
'protected_to_private' => true,
@@ -128,6 +147,7 @@ return PhpCsFixer\Config::create()
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
+ 'single_line_comment_style' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
@@ -141,5 +161,7 @@ return PhpCsFixer\Config::create()
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
+ 'void_return' => false, // Cannot use that with PHP 5.6
'whitespace_after_comma_in_array' => true,
+ 'yoda_style' => false,
]);
diff --git a/composer.lock b/composer.lock
index 92d9bea9..0a1f0b77 100644
--- a/composer.lock
+++ b/composer.lock
@@ -56,6 +56,136 @@
}
],
"packages-dev": [
+ {
+ "name": "composer/semver",
+ "version": "1.4.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/composer/semver.git",
+ "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/composer/semver/zipball/c7cb9a2095a074d131b65a8a0cd294479d785573",
+ "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.3.2 || ^7.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.5 || ^5.0.5",
+ "phpunit/phpunit-mock-objects": "2.3.0 || ^3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Composer\\Semver\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nils Adermann",
+ "email": "naderman@naderman.de",
+ "homepage": "http://www.naderman.de"
+ },
+ {
+ "name": "Jordi Boggiano",
+ "email": "j.boggiano@seld.be",
+ "homepage": "http://seld.be"
+ },
+ {
+ "name": "Rob Bast",
+ "email": "rob.bast@gmail.com",
+ "homepage": "http://robbast.nl"
+ }
+ ],
+ "description": "Semver library that offers utilities, version constraint parsing and validation.",
+ "keywords": [
+ "semantic",
+ "semver",
+ "validation",
+ "versioning"
+ ],
+ "time": "2016-08-30T16:08:34+00:00"
+ },
+ {
+ "name": "doctrine/annotations",
+ "version": "v1.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/annotations.git",
+ "reference": "5beebb01b025c94e93686b7a0ed3edae81fe3e7f"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/annotations/zipball/5beebb01b025c94e93686b7a0ed3edae81fe3e7f",
+ "reference": "5beebb01b025c94e93686b7a0ed3edae81fe3e7f",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/lexer": "1.*",
+ "php": "^7.1"
+ },
+ "require-dev": {
+ "doctrine/cache": "1.*",
+ "phpunit/phpunit": "^5.7"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.5.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Roman Borschel",
+ "email": "roman@code-factory.org"
+ },
+ {
+ "name": "Benjamin Eberlei",
+ "email": "kontakt@beberlei.de"
+ },
+ {
+ "name": "Guilherme Blanco",
+ "email": "guilhermeblanco@gmail.com"
+ },
+ {
+ "name": "Jonathan Wage",
+ "email": "jonwage@gmail.com"
+ },
+ {
+ "name": "Johannes Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Docblock Annotations Parser",
+ "homepage": "http://www.doctrine-project.org",
+ "keywords": [
+ "annotations",
+ "docblock",
+ "parser"
+ ],
+ "time": "2017-07-22T10:58:02+00:00"
+ },
{
"name": "doctrine/instantiator",
"version": "1.0.5",
@@ -110,6 +240,60 @@
],
"time": "2015-06-14T21:17:01+00:00"
},
+ {
+ "name": "doctrine/lexer",
+ "version": "v1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/lexer.git",
+ "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c",
+ "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Doctrine\\Common\\Lexer\\": "lib/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Roman Borschel",
+ "email": "roman@code-factory.org"
+ },
+ {
+ "name": "Guilherme Blanco",
+ "email": "guilhermeblanco@gmail.com"
+ },
+ {
+ "name": "Johannes Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
+ "homepage": "http://www.doctrine-project.org",
+ "keywords": [
+ "lexer",
+ "parser"
+ ],
+ "time": "2014-09-09T13:34:57+00:00"
+ },
{
"name": "dompdf/dompdf",
"version": "v0.8.0",
@@ -174,53 +358,71 @@
},
{
"name": "friendsofphp/php-cs-fixer",
- "version": "v2.1.2",
+ "version": "v2.7.0",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
- "reference": "c7de769d7b44f2c9de68e1f678b65efd8126f60b"
+ "reference": "e4e93a120117e879cfc1f231fbf29274707cd834"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c7de769d7b44f2c9de68e1f678b65efd8126f60b",
- "reference": "c7de769d7b44f2c9de68e1f678b65efd8126f60b",
+ "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/e4e93a120117e879cfc1f231fbf29274707cd834",
+ "reference": "e4e93a120117e879cfc1f231fbf29274707cd834",
"shasum": ""
},
"require": {
+ "composer/semver": "^1.4",
+ "doctrine/annotations": "^1.2",
+ "ext-json": "*",
"ext-tokenizer": "*",
- "php": "^5.3.6 || >=7.0 <7.2",
- "sebastian/diff": "^1.1",
- "symfony/console": "^2.3 || ^3.0",
- "symfony/event-dispatcher": "^2.1 || ^3.0",
- "symfony/filesystem": "^2.4 || ^3.0",
- "symfony/finder": "^2.2 || ^3.0",
- "symfony/polyfill-php54": "^1.0",
- "symfony/polyfill-php55": "^1.3",
- "symfony/polyfill-xml": "^1.3",
- "symfony/process": "^2.3 || ^3.0",
- "symfony/stopwatch": "^2.5 || ^3.0"
+ "gecko-packages/gecko-php-unit": "^2.0",
+ "php": "^5.6 || >=7.0 <7.3",
+ "php-cs-fixer/diff": "^1.0",
+ "symfony/console": "^3.2",
+ "symfony/event-dispatcher": "^3.0",
+ "symfony/filesystem": "^3.0",
+ "symfony/finder": "^3.0",
+ "symfony/options-resolver": "^3.0",
+ "symfony/polyfill-php70": "^1.0",
+ "symfony/polyfill-php72": "^1.4",
+ "symfony/process": "^3.0",
+ "symfony/stopwatch": "^3.0"
},
"conflict": {
- "hhvm": "<3.9"
+ "hhvm": "*"
},
"require-dev": {
- "gecko-packages/gecko-php-unit": "^2.0",
+ "johnkary/phpunit-speedtrap": "^1.1",
"justinrainbow/json-schema": "^5.0",
- "phpunit/phpunit": "^4.5 || ^5.0",
+ "php-cs-fixer/accessible-object": "^1.0",
+ "phpunit/phpunit": "^4.8.35 || ^5.4.3",
"satooshi/php-coveralls": "^1.0",
- "symfony/phpunit-bridge": "^3.2"
+ "symfony/phpunit-bridge": "^3.2.2"
},
"suggest": {
- "ext-xml": "For better performance."
+ "ext-mbstring": "For handling non-UTF8 characters in cache signature.",
+ "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible."
},
"bin": [
"php-cs-fixer"
],
"type": "application",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.7-dev"
+ }
+ },
"autoload": {
"psr-4": {
"PhpCsFixer\\": "src/"
- }
+ },
+ "classmap": [
+ "tests/Test/Assert/AssertTokensTrait.php",
+ "tests/Test/AbstractFixerTestCase.php",
+ "tests/Test/AbstractIntegrationTestCase.php",
+ "tests/Test/IntegrationCase.php",
+ "tests/Test/IntegrationCaseFactory.php"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -237,7 +439,51 @@
}
],
"description": "A tool to automatically fix PHP code style",
- "time": "2017-03-15T17:13:07+00:00"
+ "time": "2017-09-29T15:19:05+00:00"
+ },
+ {
+ "name": "gecko-packages/gecko-php-unit",
+ "version": "v2.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/GeckoPackages/GeckoPHPUnit.git",
+ "reference": "ab525fac9a9ffea219687f261b02008b18ebf2d1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/GeckoPackages/GeckoPHPUnit/zipball/ab525fac9a9ffea219687f261b02008b18ebf2d1",
+ "reference": "ab525fac9a9ffea219687f261b02008b18ebf2d1",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.3.6 || ^7.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8.35 || ^5.4.3"
+ },
+ "suggest": {
+ "ext-dom": "When testing with xml.",
+ "ext-libxml": "When testing with xml.",
+ "phpunit/phpunit": "This is an extension for it so make sure you have it some way."
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "GeckoPackages\\PHPUnit\\": "src/PHPUnit"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Additional PHPUnit asserts and constraints.",
+ "homepage": "https://github.com/GeckoPackages",
+ "keywords": [
+ "extension",
+ "filesystem",
+ "phpunit"
+ ],
+ "time": "2017-08-23T07:39:54+00:00"
},
{
"name": "ircmaxell/password-compat",
@@ -515,6 +761,53 @@
"homepage": "https://github.com/PhenX/php-svg-lib",
"time": "2016-12-13T20:25:45+00:00"
},
+ {
+ "name": "php-cs-fixer/diff",
+ "version": "v1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHP-CS-Fixer/diff.git",
+ "reference": "d068edadcb8f7bc2ea3d3769cdbaf609026ec4f4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/d068edadcb8f7bc2ea3d3769cdbaf609026ec4f4",
+ "reference": "d068edadcb8f7bc2ea3d3769cdbaf609026ec4f4",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.6 || ^7.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8.35 || ^5.4.3"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Kore Nordmann",
+ "email": "mail@kore-nordmann.de"
+ },
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "sebastian/diff v2 backport support for PHP5.6",
+ "homepage": "https://github.com/PHP-CS-Fixer",
+ "keywords": [
+ "diff"
+ ],
+ "time": "2017-09-23T16:02:08+00:00"
+ },
{
"name": "phpdocumentor/reflection-common",
"version": "1.0",
@@ -2120,6 +2413,60 @@
"homepage": "https://symfony.com",
"time": "2017-02-21T09:12:04+00:00"
},
+ {
+ "name": "symfony/options-resolver",
+ "version": "v3.3.9",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/options-resolver.git",
+ "reference": "ee4e22978fe885b54ee5da8c7964f0a5301abfb6"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/options-resolver/zipball/ee4e22978fe885b54ee5da8c7964f0a5301abfb6",
+ "reference": "ee4e22978fe885b54ee5da8c7964f0a5301abfb6",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.5.9|>=7.0.8"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.3-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\OptionsResolver\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony OptionsResolver Component",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "config",
+ "configuration",
+ "options"
+ ],
+ "time": "2017-07-29T21:54:42+00:00"
+ },
{
"name": "symfony/polyfill-mbstring",
"version": "v1.3.0",
@@ -2293,6 +2640,120 @@
],
"time": "2016-11-14T01:06:16+00:00"
},
+ {
+ "name": "symfony/polyfill-php70",
+ "version": "v1.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php70.git",
+ "reference": "b6482e68974486984f59449ecea1fbbb22ff840f"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/b6482e68974486984f59449ecea1fbbb22ff840f",
+ "reference": "b6482e68974486984f59449ecea1fbbb22ff840f",
+ "shasum": ""
+ },
+ "require": {
+ "paragonie/random_compat": "~1.0|~2.0",
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Php70\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ],
+ "classmap": [
+ "Resources/stubs"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "time": "2017-06-14T15:44:48+00:00"
+ },
+ {
+ "name": "symfony/polyfill-php72",
+ "version": "v1.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php72.git",
+ "reference": "8abc9097f5001d310f0edba727469c988acc6ea7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/8abc9097f5001d310f0edba727469c988acc6ea7",
+ "reference": "8abc9097f5001d310f0edba727469c988acc6ea7",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Php72\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "time": "2017-07-11T13:25:55+00:00"
+ },
{
"name": "symfony/polyfill-xml",
"version": "v1.3.0",
diff --git a/samples/Basic/13_Calculation.php b/samples/Basic/13_Calculation.php
index 4bbc296d..e06477d3 100644
--- a/samples/Basic/13_Calculation.php
+++ b/samples/Basic/13_Calculation.php
@@ -157,7 +157,7 @@ $spreadsheet->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:')
$helper->log('Calculated data');
for ($col = 'B'; $col != 'G'; ++$col) {
for ($row = 14; $row <= 41; ++$row) {
- if ((!is_null($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue())) &&
+ if ((($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) &&
($formula[0] == '=')) {
$helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue());
}
diff --git a/samples/Basic/13_CalculationCyclicFormulae.php b/samples/Basic/13_CalculationCyclicFormulae.php
index 006151bb..6366bcd5 100644
--- a/samples/Basic/13_CalculationCyclicFormulae.php
+++ b/samples/Basic/13_CalculationCyclicFormulae.php
@@ -22,7 +22,7 @@ Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 100;
$helper->log('Calculated data');
for ($row = 1; $row <= 2; ++$row) {
for ($col = 'A'; $col != 'C'; ++$col) {
- if ((!is_null($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue())) &&
+ if ((($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) &&
($formula[0] == '=')) {
$helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue());
}
diff --git a/samples/Basic/26_Utf8.php b/samples/Basic/26_Utf8.php
index 02b60801..89be2c94 100644
--- a/samples/Basic/26_Utf8.php
+++ b/samples/Basic/26_Utf8.php
@@ -16,7 +16,7 @@ $helper->log('Load Xlsx template file');
$reader = IOFactory::createReader('Xlsx');
$spreadsheet = $reader->load(__DIR__ . '/../templates/26template.xlsx');
-/* at this point, we could do some manipulations with the template, but we skip this step */
+// at this point, we could do some manipulations with the template, but we skip this step
$helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']);
// Export to PDF (.pdf)
diff --git a/samples/Basic/28_Iterator.php b/samples/Basic/28_Iterator.php
index 64981c5c..4aec7a92 100644
--- a/samples/Basic/28_Iterator.php
+++ b/samples/Basic/28_Iterator.php
@@ -26,7 +26,7 @@ foreach ($spreadsheet->getWorksheetIterator() as $worksheet) {
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
foreach ($cellIterator as $cell) {
- if (!is_null($cell)) {
+ if ($cell !== null) {
$helper->log(' Cell - ' . $cell->getCoordinate() . ' - ' . $cell->getCalculatedValue());
}
}
diff --git a/samples/Basic/45_Quadratic_equation_solver.php b/samples/Basic/45_Quadratic_equation_solver.php
index 11edb856..68efa824 100644
--- a/samples/Basic/45_Quadratic_equation_solver.php
+++ b/samples/Basic/45_Quadratic_equation_solver.php
@@ -26,7 +26,7 @@ if (isset($_POST['submit'])) {
if ($_POST['A'] == 0) {
$helper->log('The equation is not quadratic');
} else {
- /* Calculate and Display the results * */
+ // Calculate and Display the results
$helper->log('
Roots:
');
$discriminantFormula = '=POWER(' . $_POST['B'] . ',2) - (4 * ' . $_POST['A'] . ' * ' . $_POST['C'] . ')';
diff --git a/samples/Chart/32_Chart_read_write.php b/samples/Chart/32_Chart_read_write.php
index 38169720..ba711c06 100644
--- a/samples/Chart/32_Chart_read_write.php
+++ b/samples/Chart/32_Chart_read_write.php
@@ -20,6 +20,7 @@ foreach ($inputFileNames as $inputFileName) {
if (!file_exists($inputFileName)) {
$helper->log('File ' . $inputFileNameShort . ' does not exist');
+
continue;
}
$reader = IOFactory::createReader($inputFileType);
@@ -40,7 +41,7 @@ foreach ($inputFileNames as $inputFileName) {
natsort($chartNames);
foreach ($chartNames as $i => $chartName) {
$chart = $worksheet->getChartByName($chartName);
- if (!is_null($chart->getTitle())) {
+ if ($chart->getTitle() !== null) {
$caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"';
} else {
$caption = 'Untitled';
diff --git a/samples/Chart/32_Chart_read_write_HTML.php b/samples/Chart/32_Chart_read_write_HTML.php
index df859058..fb2ead68 100644
--- a/samples/Chart/32_Chart_read_write_HTML.php
+++ b/samples/Chart/32_Chart_read_write_HTML.php
@@ -33,6 +33,7 @@ foreach ($inputFileNames as $inputFileName) {
if (!file_exists($inputFileName)) {
$helper->log('File ' . $inputFileNameShort . ' does not exist');
+
continue;
}
@@ -54,7 +55,7 @@ foreach ($inputFileNames as $inputFileName) {
natsort($chartNames);
foreach ($chartNames as $i => $chartName) {
$chart = $worksheet->getChartByName($chartName);
- if (!is_null($chart->getTitle())) {
+ if ($chart->getTitle() !== null) {
$caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"';
} else {
$caption = 'Untitled';
diff --git a/samples/Chart/32_Chart_read_write_PDF.php b/samples/Chart/32_Chart_read_write_PDF.php
index 446c67ac..c18ab872 100644
--- a/samples/Chart/32_Chart_read_write_PDF.php
+++ b/samples/Chart/32_Chart_read_write_PDF.php
@@ -41,6 +41,7 @@ foreach ($inputFileNames as $inputFileName) {
if (!file_exists($inputFileName)) {
$helper->log('File ' . $inputFileNameShort . ' does not exist');
+
continue;
}
@@ -62,7 +63,7 @@ foreach ($inputFileNames as $inputFileName) {
natsort($chartNames);
foreach ($chartNames as $i => $chartName) {
$chart = $worksheet->getChartByName($chartName);
- if (!is_null($chart->getTitle())) {
+ if ($chart->getTitle() !== null) {
$caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"';
} else {
$caption = 'Untitled';
diff --git a/samples/Chart/35_Chart_render.php b/samples/Chart/35_Chart_render.php
index 672e8554..4671f21b 100644
--- a/samples/Chart/35_Chart_render.php
+++ b/samples/Chart/35_Chart_render.php
@@ -33,6 +33,7 @@ foreach ($inputFileNames as $inputFileName) {
if (!file_exists($inputFileName)) {
$helper->log('File ' . $inputFileNameShort . ' does not exist');
+
continue;
}
@@ -54,7 +55,7 @@ foreach ($inputFileNames as $inputFileName) {
natsort($chartNames);
foreach ($chartNames as $i => $chartName) {
$chart = $worksheet->getChartByName($chartName);
- if (!is_null($chart->getTitle())) {
+ if ($chart->getTitle() !== null) {
$caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"';
} else {
$caption = 'Untitled';
@@ -65,6 +66,7 @@ foreach ($inputFileNames as $inputFileName) {
if (file_exists($jpegFile)) {
unlink($jpegFile);
}
+
try {
$chart->render($jpegFile);
} catch (Exception $e) {
diff --git a/samples/Header.php b/samples/Header.php
index 0b5a4608..bb14f520 100644
--- a/samples/Header.php
+++ b/samples/Header.php
@@ -49,7 +49,6 @@ if ($helper->isCli()) {
} ?>
diff --git a/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php b/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php
index a71cac70..19961947 100644
--- a/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php
+++ b/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php
@@ -40,20 +40,20 @@ class ChunkReadFilter implements IReadFilter
}
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
-/* Create a new Reader of the type defined in $inputFileType * */
+// Create a new Reader of the type defined in $inputFileType
$reader = IOFactory::createReader($inputFileType);
-/* Define how many rows we want for each "chunk" * */
+// Define how many rows we want for each "chunk"
$chunkSize = 20;
-/* Loop to read our worksheet in "chunk size" blocks * */
+// Loop to read our worksheet in "chunk size" blocks
for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
$helper->log('Loading WorkSheet using configurable filter for headings row 1 and for rows ' . $startRow . ' to ' . ($startRow + $chunkSize - 1));
- /* Create a new Instance of our Read Filter, passing in the limits on which rows we want to read * */
+ // Create a new Instance of our Read Filter, passing in the limits on which rows we want to read
$chunkFilter = new ChunkReadFilter($startRow, $chunkSize);
- /* Tell the Reader that we want to use the new Read Filter that we've just Instantiated * */
+ // Tell the Reader that we want to use the new Read Filter that we've just Instantiated
$reader->setReadFilter($chunkFilter);
- /* Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object * */
+ // Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName);
// Do some processing here
diff --git a/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php b/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php
index a03e15e5..d1b85c76 100644
--- a/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php
+++ b/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php
@@ -40,23 +40,23 @@ class ChunkReadFilter implements IReadFilter
}
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
-/* Create a new Reader of the type defined in $inputFileType * */
+// Create a new Reader of the type defined in $inputFileType
$reader = IOFactory::createReader($inputFileType);
-/* Define how many rows we want to read for each "chunk" * */
+// Define how many rows we want to read for each "chunk"
$chunkSize = 20;
-/* Create a new Instance of our Read Filter * */
+// Create a new Instance of our Read Filter
$chunkFilter = new ChunkReadFilter();
-/* Tell the Reader that we want to use the Read Filter that we've Instantiated * */
+// Tell the Reader that we want to use the Read Filter that we've Instantiated
$reader->setReadFilter($chunkFilter);
-/* Loop to read our worksheet in "chunk size" blocks * */
+// Loop to read our worksheet in "chunk size" blocks
for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
$helper->log('Loading WorkSheet using configurable filter for headings row 1 and for rows ' . $startRow . ' to ' . ($startRow + $chunkSize - 1));
- /* Tell the Read Filter, the limits on which rows we want to read this iteration * */
+ // Tell the Read Filter, the limits on which rows we want to read this iteration
$chunkFilter->setRows($startRow, $chunkSize);
- /* Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object * */
+ // Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName);
// Do some processing here
diff --git a/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php b/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php
index 7ac5a9fd..80ece763 100644
--- a/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php
+++ b/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php
@@ -41,37 +41,37 @@ class ChunkReadFilter implements IReadFilter
}
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
-/* Create a new Reader of the type defined in $inputFileType * */
+// Create a new Reader of the type defined in $inputFileType
$reader = IOFactory::createReader($inputFileType);
-/* Define how many rows we want to read for each "chunk" * */
+// Define how many rows we want to read for each "chunk"
$chunkSize = 100;
-/* Create a new Instance of our Read Filter * */
+// Create a new Instance of our Read Filter
$chunkFilter = new ChunkReadFilter();
-/* Tell the Reader that we want to use the Read Filter that we've Instantiated * */
-/* and that we want to store it in contiguous rows/columns * */
+// Tell the Reader that we want to use the Read Filter that we've Instantiated
+// and that we want to store it in contiguous rows/columns
$reader->setReadFilter($chunkFilter)
->setContiguous(true);
-/* Instantiate a new PhpSpreadsheet object manually * */
+// Instantiate a new PhpSpreadsheet object manually
$spreadsheet = new Spreadsheet();
-/* Set a sheet index * */
+// Set a sheet index
$sheet = 0;
-/* Loop to read our worksheet in "chunk size" blocks * */
+// Loop to read our worksheet in "chunk size" blocks
/** $startRow is set to 2 initially because we always read the headings in row #1 * */
for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
$helper->log('Loading WorkSheet #' . ($sheet + 1) . ' using configurable filter for headings row 1 and for rows ' . $startRow . ' to ' . ($startRow + $chunkSize - 1));
- /* Tell the Read Filter, the limits on which rows we want to read this iteration * */
+ // Tell the Read Filter, the limits on which rows we want to read this iteration
$chunkFilter->setRows($startRow, $chunkSize);
- /* Increment the worksheet index pointer for the Reader * */
+ // Increment the worksheet index pointer for the Reader
$reader->setSheetIndex($sheet);
- /* Load only the rows that match our filter into a new worksheet in the PhpSpreadsheet Object * */
+ // Load only the rows that match our filter into a new worksheet in the PhpSpreadsheet Object
$reader->loadIntoExisting($inputFileName, $spreadsheet);
- /* Set the worksheet title (to reference the "sheet" of data that we've loaded) * */
- /* and increment the sheet index as well * */
+ // Set the worksheet title (to reference the "sheet" of data that we've loaded)
+ // and increment the sheet index as well
$spreadsheet->getActiveSheet()->setTitle('Country Data #' . (++$sheet));
}
diff --git a/samples/Reader/16_Handling_loader_exceptions_using_TryCatch.php b/samples/Reader/16_Handling_loader_exceptions_using_TryCatch.php
index dd5fa273..80bb371d 100644
--- a/samples/Reader/16_Handling_loader_exceptions_using_TryCatch.php
+++ b/samples/Reader/16_Handling_loader_exceptions_using_TryCatch.php
@@ -6,6 +6,7 @@ require __DIR__ . '/../Header.php';
$inputFileName = __DIR__ . '/sampleData/non-existing-file.xls';
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory to identify the format');
+
try {
$spreadsheet = IOFactory::load($inputFileName);
} catch (InvalidArgumentException $e) {
diff --git a/samples/Reader/17_Simple_file_reader_loading_several_named_worksheets.php b/samples/Reader/17_Simple_file_reader_loading_several_named_worksheets.php
index 53941795..db30bff8 100644
--- a/samples/Reader/17_Simple_file_reader_loading_several_named_worksheets.php
+++ b/samples/Reader/17_Simple_file_reader_loading_several_named_worksheets.php
@@ -10,7 +10,7 @@ $inputFileName = __DIR__ . '/sampleData/example1.xls';
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
$reader = IOFactory::createReader($inputFileType);
-/* Read the list of Worksheet Names from the Workbook file * */
+// Read the list of Worksheet Names from the Workbook file
$helper->log('Read the list of Worksheets in the WorkBook');
$worksheetNames = $reader->listWorksheetNames($inputFileName);
diff --git a/samples/Reading_workbook_data/Custom_properties.php b/samples/Reading_workbook_data/Custom_properties.php
index 8413b542..3c40440b 100644
--- a/samples/Reading_workbook_data/Custom_properties.php
+++ b/samples/Reading_workbook_data/Custom_properties.php
@@ -7,40 +7,45 @@ require __DIR__ . '/../Header.php';
$inputFileType = 'Xlsx';
$inputFileName = __DIR__ . '/sampleData/example1.xlsx';
-/* Create a new Reader of the type defined in $inputFileType * */
+// Create a new Reader of the type defined in $inputFileType
$reader = IOFactory::createReader($inputFileType);
-/* Load $inputFileName to a PhpSpreadsheet Object * */
+// Load $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName);
-/* Read an array list of any custom properties for this document * */
+// Read an array list of any custom properties for this document
$customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
-/* Loop through the list of custom properties * */
+// Loop through the list of custom properties
foreach ($customPropertyList as $customPropertyName) {
$helper->log('' . $customPropertyName . ': ');
- /* Retrieve the property value * */
+ // Retrieve the property value
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customPropertyName);
- /* Retrieve the property type * */
+ // Retrieve the property type
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customPropertyName);
- /* Manipulate properties as appropriate for display purposes * */
+ // Manipulate properties as appropriate for display purposes
switch ($propertyType) {
case 'i': // integer
$propertyType = 'integer number';
+
break;
case 'f': // float
$propertyType = 'floating point number';
+
break;
case 's': // string
$propertyType = 'string';
+
break;
case 'd': // date
$propertyValue = date('l, d<\s\up>S\s\up> F Y g:i A', $propertyValue);
$propertyType = 'date';
+
break;
case 'b': // boolean
$propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE';
$propertyType = 'boolean';
+
break;
}
diff --git a/samples/Reading_workbook_data/Custom_property_names.php b/samples/Reading_workbook_data/Custom_property_names.php
index d94f0e4c..0f287f04 100644
--- a/samples/Reading_workbook_data/Custom_property_names.php
+++ b/samples/Reading_workbook_data/Custom_property_names.php
@@ -7,12 +7,12 @@ require __DIR__ . '/../Header.php';
$inputFileType = 'Xlsx';
$inputFileName = __DIR__ . '/sampleData/example1.xlsx';
-/* Create a new Reader of the type defined in $inputFileType * */
+// Create a new Reader of the type defined in $inputFileType
$reader = IOFactory::createReader($inputFileType);
-/* Load $inputFileName to a PhpSpreadsheet Object * */
+// Load $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName);
-/* Read an array list of any custom properties for this document * */
+// Read an array list of any custom properties for this document
$customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
foreach ($customPropertyList as $customPropertyName) {
diff --git a/samples/Reading_workbook_data/Properties.php b/samples/Reading_workbook_data/Properties.php
index 1dc324c0..5bf25b8e 100644
--- a/samples/Reading_workbook_data/Properties.php
+++ b/samples/Reading_workbook_data/Properties.php
@@ -7,58 +7,58 @@ require __DIR__ . '/../Header.php';
$inputFileType = 'Xls';
$inputFileName = __DIR__ . '/sampleData/example1.xls';
-/* Create a new Reader of the type defined in $inputFileType * */
+// Create a new Reader of the type defined in $inputFileType
$reader = IOFactory::createReader($inputFileType);
-/* Load $inputFileName to a PhpSpreadsheet Object * */
+// Load $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName);
-/* Read the document's creator property * */
+// Read the document's creator property
$creator = $spreadsheet->getProperties()->getCreator();
$helper->log('Document Creator: ' . $creator);
-/* Read the Date when the workbook was created (as a PHP timestamp value) * */
+// Read the Date when the workbook was created (as a PHP timestamp value)
$creationDatestamp = $spreadsheet->getProperties()->getCreated();
-/* Format the date and time using the standard PHP date() function * */
+// Format the date and time using the standard PHP date() function
$creationDate = date('l, d<\s\up>S\s\up> F Y', $creationDatestamp);
$creationTime = date('g:i A', $creationDatestamp);
$helper->log('Created On: ' . $creationDate . ' at ' . $creationTime);
-/* Read the name of the last person to modify this workbook * */
+// Read the name of the last person to modify this workbook
$modifiedBy = $spreadsheet->getProperties()->getLastModifiedBy();
$helper->log('Last Modified By: ' . $modifiedBy);
-/* Read the Date when the workbook was last modified (as a PHP timestamp value) * */
+// Read the Date when the workbook was last modified (as a PHP timestamp value)
$modifiedDatestamp = $spreadsheet->getProperties()->getModified();
-/* Format the date and time using the standard PHP date() function * */
+// Format the date and time using the standard PHP date() function
$modifiedDate = date('l, d<\s\up>S\s\up> F Y', $modifiedDatestamp);
$modifiedTime = date('g:i A', $modifiedDatestamp);
$helper->log('Last Modified On: ' . $modifiedDate . ' at ' . $modifiedTime);
-/* Read the workbook title property * */
+// Read the workbook title property
$workbookTitle = $spreadsheet->getProperties()->getTitle();
$helper->log('Title: ' . $workbookTitle);
-/* Read the workbook description property * */
+// Read the workbook description property
$description = $spreadsheet->getProperties()->getDescription();
$helper->log('Description: ' . $description);
-/* Read the workbook subject property * */
+// Read the workbook subject property
$subject = $spreadsheet->getProperties()->getSubject();
$helper->log('Subject: ' . $subject);
-/* Read the workbook keywords property * */
+// Read the workbook keywords property
$keywords = $spreadsheet->getProperties()->getKeywords();
$helper->log('Keywords: ' . $keywords);
-/* Read the workbook category property * */
+// Read the workbook category property
$category = $spreadsheet->getProperties()->getCategory();
$helper->log('Category: ' . $category);
-/* Read the workbook company property * */
+// Read the workbook company property
$company = $spreadsheet->getProperties()->getCompany();
$helper->log('Company: ' . $company);
-/* Read the workbook manager property * */
+// Read the workbook manager property
$manager = $spreadsheet->getProperties()->getManager();
$helper->log('Manager: ' . $manager);
$s = new \PhpOffice\PhpSpreadsheet\Helper\Sample();
diff --git a/samples/Reading_workbook_data/Worksheet_count_and_names.php b/samples/Reading_workbook_data/Worksheet_count_and_names.php
index 03f7508c..630312b7 100644
--- a/samples/Reading_workbook_data/Worksheet_count_and_names.php
+++ b/samples/Reading_workbook_data/Worksheet_count_and_names.php
@@ -7,17 +7,17 @@ require __DIR__ . '/../Header.php';
$inputFileType = 'Xls';
$inputFileName = __DIR__ . '/sampleData/example2.xls';
-/* Create a new Reader of the type defined in $inputFileType * */
+// Create a new Reader of the type defined in $inputFileType
$reader = IOFactory::createReader($inputFileType);
-/* Load $inputFileName to a PhpSpreadsheet Object * */
+// Load $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName);
-/* Use the PhpSpreadsheet object's getSheetCount() method to get a count of the number of WorkSheets in the WorkBook */
+// Use the PhpSpreadsheet object's getSheetCount() method to get a count of the number of WorkSheets in the WorkBook
$sheetCount = $spreadsheet->getSheetCount();
$helper->log('There ' . (($sheetCount == 1) ? 'is' : 'are') . ' ' . $sheetCount . ' WorkSheet' . (($sheetCount == 1) ? '' : 's') . ' in the WorkBook');
$helper->log('Reading the names of Worksheets in the WorkBook');
-/* Use the PhpSpreadsheet object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook */
+// Use the PhpSpreadsheet object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook
$sheetNames = $spreadsheet->getSheetNames();
foreach ($sheetNames as $sheetIndex => $sheetName) {
$helper->log('WorkSheet #' . $sheetIndex . ' is named "' . $sheetName . '"');
diff --git a/samples/index.php b/samples/index.php
index 9ff53f51..ec100cf4 100644
--- a/samples/index.php
+++ b/samples/index.php
@@ -3,7 +3,7 @@
require_once 'Header.php';
$requirements = [
- 'PHP 5.6.0' => version_compare(phpversion(), '5.6.0', '>='),
+ 'PHP 5.6.0' => version_compare(PHP_VERSION, '5.6.0', '>='),
'PHP extension XML' => extension_loaded('xml'),
'PHP extension xmlwriter' => extension_loaded('xmlwriter'),
'PHP extension mbstring' => extension_loaded('mbstring'),
diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php
index dc17f751..f8239371 100644
--- a/src/PhpSpreadsheet/Calculation.php
+++ b/src/PhpSpreadsheet/Calculation.php
@@ -115,7 +115,7 @@ class Calculation
*
* @var string
*/
- public $formulaError = null;
+ public $formulaError;
/**
* An array of the nested cell references accessed by the calculation engine, used for the debug log.
@@ -2217,7 +2217,7 @@ class Calculation
// Identify our locale and language
$language = $locale = strtolower($locale);
if (strpos($locale, '_') !== false) {
- list($language) = explode('_', $locale);
+ [$language] = explode('_', $locale);
}
if (count(self::$validLocaleLanguages) == 1) {
@@ -2243,9 +2243,9 @@ class Calculation
// Retrieve the list of locale or language specific function names
$localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($localeFunctions as $localeFunction) {
- list($localeFunction) = explode('##', $localeFunction); // Strip out comments
+ [$localeFunction] = explode('##', $localeFunction); // Strip out comments
if (strpos($localeFunction, '=') !== false) {
- list($fName, $lfName) = explode('=', $localeFunction);
+ [$fName, $lfName] = explode('=', $localeFunction);
$fName = trim($fName);
$lfName = trim($lfName);
if ((isset(self::$phpSpreadsheetFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {
@@ -2268,13 +2268,14 @@ class Calculation
if (file_exists($configFile)) {
$localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($localeSettings as $localeSetting) {
- list($localeSetting) = explode('##', $localeSetting); // Strip out comments
+ [$localeSetting] = explode('##', $localeSetting); // Strip out comments
if (strpos($localeSetting, '=') !== false) {
- list($settingName, $settingValue) = explode('=', $localeSetting);
+ [$settingName, $settingValue] = explode('=', $localeSetting);
$settingName = strtoupper(trim($settingName));
switch ($settingName) {
case 'ARGUMENTSEPARATOR':
self::$localeArgumentSeparator = trim($settingValue);
+
break;
}
}
@@ -2308,9 +2309,11 @@ class Calculation
switch ($chr) {
case '{':
$inBraces = true;
+
break;
case '}':
$inBraces = false;
+
break;
case $fromSeparator:
if (!$inBraces) {
@@ -2449,7 +2452,7 @@ class Calculation
}
// Return strings wrapped in quotes
return '"' . $value . '"';
- // Convert numeric errors to NaN error
+ // Convert numeric errors to NaN error
} elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
return Calculation\Functions::NAN();
}
@@ -2470,7 +2473,7 @@ class Calculation
if ((isset($value[0])) && ($value[0] == '"') && (substr($value, -1) == '"')) {
return substr($value, 1, -1);
}
- // Convert numeric errors to NAN error
+ // Convert numeric errors to NAN error
} elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
return Calculation\Functions::NAN();
}
@@ -2529,6 +2532,7 @@ class Calculation
'sheet' => $pCell->getWorksheet()->getTitle(),
'cell' => $pCell->getCoordinate(),
];
+
try {
$result = self::unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));
$cellAddress = array_pop($this->cellStack);
@@ -2536,6 +2540,7 @@ class Calculation
} catch (Exception $e) {
$cellAddress = array_pop($this->cellStack);
$this->spreadsheet->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
+
throw new Calculation\Exception($e->getMessage());
}
@@ -2761,17 +2766,17 @@ class Calculation
// Examine each of the two operands, and turn them into an array if they aren't one already
// Note that this function should only be called if one or both of the operand is already an array
if (!is_array($operand1)) {
- list($matrixRows, $matrixColumns) = self::getMatrixDimensions($operand2);
+ [$matrixRows, $matrixColumns] = self::getMatrixDimensions($operand2);
$operand1 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand1));
$resize = 0;
} elseif (!is_array($operand2)) {
- list($matrixRows, $matrixColumns) = self::getMatrixDimensions($operand1);
+ [$matrixRows, $matrixColumns] = self::getMatrixDimensions($operand1);
$operand2 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand2));
$resize = 0;
}
- list($matrix1Rows, $matrix1Columns) = self::getMatrixDimensions($operand1);
- list($matrix2Rows, $matrix2Columns) = self::getMatrixDimensions($operand2);
+ [$matrix1Rows, $matrix1Columns] = self::getMatrixDimensions($operand1);
+ [$matrix2Rows, $matrix2Columns] = self::getMatrixDimensions($operand2);
if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) {
$resize = 1;
}
@@ -2944,7 +2949,7 @@ class Calculation
*
* @param mixed $value First matrix operand
*
- * @return string|null
+ * @return null|string
*/
private function showTypeDetails($value)
{
@@ -3073,7 +3078,7 @@ class Calculation
/**
* @param string $formula
- * @param Cell|null $pCell
+ * @param null|Cell $pCell
*
* @return bool
*/
@@ -3181,18 +3186,21 @@ class Calculation
$argumentCountError = true;
$expectedArgumentCountString = $argMatch[1] . ' or more ';
}
+
break;
case '-':
if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) {
$argumentCountError = true;
$expectedArgumentCountString = 'between ' . $argMatch[1] . ' and ' . $argMatch[3];
}
+
break;
case ',':
if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) {
$argumentCountError = true;
$expectedArgumentCountString = 'either ' . $argMatch[1] . ' or ' . $argMatch[3];
}
+
break;
}
}
@@ -3278,14 +3286,14 @@ class Calculation
$startRowColRef = $output[count($output) - 1]['value'];
$rangeWS1 = '';
if (strpos('!', $startRowColRef) !== false) {
- list($rangeWS1, $startRowColRef) = explode('!', $startRowColRef);
+ [$rangeWS1, $startRowColRef] = explode('!', $startRowColRef);
}
if ($rangeWS1 != '') {
$rangeWS1 .= '!';
}
$rangeWS2 = $rangeWS1;
if (strpos('!', $val) !== false) {
- list($rangeWS2, $val) = explode('!', $val);
+ [$rangeWS2, $val] = explode('!', $val);
}
if ($rangeWS2 != '') {
$rangeWS2 .= '!';
@@ -3350,6 +3358,7 @@ class Calculation
if ((isset(self::$operators[$opCharacter])) && ($opCharacter != '%')) {
return $this->raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands");
}
+
break;
}
// Ignore white space
@@ -3406,8 +3415,8 @@ class Calculation
/**
* @param mixed $tokens
- * @param string|null $cellID
- * @param Cell|null $pCell
+ * @param null|string $cellID
+ * @param null|Cell $pCell
*
* @return bool
*/
@@ -3456,17 +3465,18 @@ class Calculation
case '=': // Equality
case '<>': // Inequality
$this->executeBinaryComparisonOperation($cellID, $operand1, $operand2, $token, $stack);
+
break;
// Binary Operators
case ':': // Range
$sheet1 = $sheet2 = '';
if (strpos($operand1Data['reference'], '!') !== false) {
- list($sheet1, $operand1Data['reference']) = explode('!', $operand1Data['reference']);
+ [$sheet1, $operand1Data['reference']] = explode('!', $operand1Data['reference']);
} else {
$sheet1 = ($pCellParent !== null) ? $pCellWorksheet->getTitle() : '';
}
if (strpos($operand2Data['reference'], '!') !== false) {
- list($sheet2, $operand2Data['reference']) = explode('!', $operand2Data['reference']);
+ [$sheet2, $operand2Data['reference']] = explode('!', $operand2Data['reference']);
} else {
$sheet2 = $sheet1;
}
@@ -3507,21 +3517,27 @@ class Calculation
} else {
$stack->push('Error', Calculation\Functions::REF(), null);
}
+
break;
case '+': // Addition
$this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'plusEquals', $stack);
+
break;
case '-': // Subtraction
$this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'minusEquals', $stack);
+
break;
case '*': // Multiplication
$this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'arrayTimesEquals', $stack);
+
break;
case '/': // Division
$this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'arrayRightDivide', $stack);
+
break;
case '^': // Exponential
$this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'power', $stack);
+
break;
case '&': // Concatenation
// If either of the operands is a matrix, we need to treat them both as matrices
@@ -3536,6 +3552,7 @@ class Calculation
if ((is_array($operand1)) || (is_array($operand2))) {
// Ensure that both operands are arrays/matrices
self::checkMatrixOperands($operand1, $operand2, 2);
+
try {
// Convert operand 1 from a PHP array to a matrix
$matrix = new Shared\JAMA\Matrix($operand1);
@@ -3551,6 +3568,7 @@ class Calculation
}
$this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result));
$stack->push('Value', $result);
+
break;
case '|': // Intersect
$rowIntersect = array_intersect_key($operand1, $operand2);
@@ -3565,10 +3583,11 @@ class Calculation
$cellRef = Cell::stringFromColumnIndex(min($oCol)) . min($oRow) . ':' . Cell::stringFromColumnIndex(max($oCol)) . max($oRow);
$this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($cellIntersect));
$stack->push('Value', $cellIntersect, $cellRef);
+
break;
}
- // if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
+ // if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
} elseif (($token === '~') || ($token === '%')) {
if (($arg = $stack->pop()) === null) {
return $this->raiseFormulaError('Internal error - Operand value missing from stack');
@@ -3583,6 +3602,7 @@ class Calculation
}
if (is_array($arg)) {
self::checkMatrixOperands($arg, $multiplier, 2);
+
try {
$matrix1 = new Shared\JAMA\Matrix($arg);
$matrixResult = $matrix1->arrayTimesEquals($multiplier);
@@ -3667,7 +3687,7 @@ class Calculation
}
$stack->push('Value', $cellValue, $cellRef);
- // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
+ // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $token, $matches)) {
$functionName = $matches[1];
$argCount = $stack->pop();
@@ -3752,7 +3772,7 @@ class Calculation
$this->debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->showTypeDetails(self::$excelConstants[$excelConstant]));
} elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token[0] == '"') || ($token[0] == '#')) {
$stack->push('Value', $token);
- // if the token is a named range, push the named range name onto the stack
+ // if the token is a named range, push the named range name onto the stack
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $token, $matches)) {
$namedRange = $matches[6];
$this->debugLog->writeDebugLog('Evaluating Named Range ', $namedRange);
@@ -3819,7 +3839,7 @@ class Calculation
}
/**
- * @param string|null $cellID
+ * @param null|string $cellID
* @param mixed $operand1
* @param mixed $operand2
* @param string $operation
@@ -3895,6 +3915,7 @@ class Calculation
} else {
$result = ($operand1 > $operand2);
}
+
break;
// Less than
case '<':
@@ -3903,6 +3924,7 @@ class Calculation
} else {
$result = ($operand1 < $operand2);
}
+
break;
// Equality
case '=':
@@ -3911,6 +3933,7 @@ class Calculation
} else {
$result = strcmp($operand1, $operand2) == 0;
}
+
break;
// Greater than or equal
case '>=':
@@ -3921,6 +3944,7 @@ class Calculation
} else {
$result = strcmp($operand1, $operand2) >= 0;
}
+
break;
// Less than or equal
case '<=':
@@ -3931,6 +3955,7 @@ class Calculation
} else {
$result = strcmp($operand1, $operand2) <= 0;
}
+
break;
// Inequality
case '<>':
@@ -3939,6 +3964,7 @@ class Calculation
} else {
$result = strcmp($operand1, $operand2) != 0;
}
+
break;
}
@@ -3968,7 +3994,7 @@ class Calculation
/**
* @param string $matrixFunction
- * @param string|null $cellID
+ * @param null|string $cellID
* @param mixed $operand1
* @param mixed $operand2
* @param mixed $operation
@@ -4011,14 +4037,17 @@ class Calculation
// Addition
case '+':
$result = $operand1 + $operand2;
+
break;
// Subtraction
case '-':
$result = $operand1 - $operand2;
+
break;
// Multiplication
case '*':
$result = $operand1 * $operand2;
+
break;
// Division
case '/':
@@ -4035,6 +4064,7 @@ class Calculation
// Power
case '^':
$result = pow($operand1, $operand2);
+
break;
}
}
@@ -4078,7 +4108,7 @@ class Calculation
if ($pSheet !== null) {
$pSheetName = $pSheet->getTitle();
if (strpos($pRange, '!') !== false) {
- list($pSheetName, $pRange) = Worksheet::extractSheetTitle($pRange, true);
+ [$pSheetName, $pRange] = Worksheet::extractSheetTitle($pRange, true);
$pSheet = $this->spreadsheet->getSheetByName($pSheetName);
}
@@ -4129,7 +4159,7 @@ class Calculation
if ($pSheet !== null) {
$pSheetName = $pSheet->getTitle();
if (strpos($pRange, '!') !== false) {
- list($pSheetName, $pRange) = Worksheet::extractSheetTitle($pRange, true);
+ [$pSheetName, $pRange] = Worksheet::extractSheetTitle($pRange, true);
$pSheet = $this->spreadsheet->getSheetByName($pSheetName);
}
@@ -4153,7 +4183,7 @@ class Calculation
$aReferences = Cell::extractAllCellReferencesInRange($pRange);
if (!isset($aReferences[1])) {
// Single cell (or single column or row) in range
- list($currentCol, $currentRow) = Cell::coordinateFromString($aReferences[0]);
+ [$currentCol, $currentRow] = Cell::coordinateFromString($aReferences[0]);
if ($pSheet->cellExists($aReferences[0])) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
} else {
@@ -4163,7 +4193,7 @@ class Calculation
// Extract cell data for all cells in the range
foreach ($aReferences as $reference) {
// Extract range
- list($currentCol, $currentRow) = Cell::coordinateFromString($reference);
+ [$currentCol, $currentRow] = Cell::coordinateFromString($reference);
if ($pSheet->cellExists($reference)) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
} else {
diff --git a/src/PhpSpreadsheet/Calculation/Category.php b/src/PhpSpreadsheet/Calculation/Category.php
index a7953fc3..7574cb47 100644
--- a/src/PhpSpreadsheet/Calculation/Category.php
+++ b/src/PhpSpreadsheet/Calculation/Category.php
@@ -4,7 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
abstract class Category
{
- /* Function categories */
+ // Function categories
const CATEGORY_CUBE = 'Cube';
const CATEGORY_DATABASE = 'Database';
const CATEGORY_DATE_AND_TIME = 'Date and Time';
diff --git a/src/PhpSpreadsheet/Calculation/Database.php b/src/PhpSpreadsheet/Calculation/Database.php
index bc08d63f..a322d0f5 100644
--- a/src/PhpSpreadsheet/Calculation/Database.php
+++ b/src/PhpSpreadsheet/Calculation/Database.php
@@ -21,7 +21,7 @@ class Database
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
*
- * @return string|null
+ * @return null|string
*/
private static function fieldExtract($database, $field)
{
@@ -138,7 +138,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -154,7 +154,7 @@ class Database
public static function DAVERAGE($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -182,7 +182,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -201,7 +201,7 @@ class Database
public static function DCOUNT($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -225,7 +225,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -244,7 +244,7 @@ class Database
public static function DCOUNTA($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -277,7 +277,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -293,7 +293,7 @@ class Database
public static function DGET($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -321,7 +321,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -337,7 +337,7 @@ class Database
public static function DMAX($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -362,7 +362,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -378,7 +378,7 @@ class Database
public static function DMIN($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -402,7 +402,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -418,7 +418,7 @@ class Database
public static function DPRODUCT($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -443,7 +443,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -459,7 +459,7 @@ class Database
public static function DSTDEV($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -484,7 +484,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -500,7 +500,7 @@ class Database
public static function DSTDEVP($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -524,7 +524,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -540,7 +540,7 @@ class Database
public static function DSUM($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -565,7 +565,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -581,7 +581,7 @@ class Database
public static function DVAR($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
@@ -606,7 +606,7 @@ class Database
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
- * @param string|int $field Indicates which column is used in the function. Enter the
+ * @param int|string $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
@@ -622,7 +622,7 @@ class Database
public static function DVARP($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
- if (is_null($field)) {
+ if ($field === null) {
return null;
}
diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php
index 200bd374..117f2779 100644
--- a/src/PhpSpreadsheet/Calculation/DateTime.php
+++ b/src/PhpSpreadsheet/Calculation/DateTime.php
@@ -154,12 +154,15 @@ class DateTime
switch (Functions::getReturnDateType()) {
case Functions::RETURNDATE_EXCEL:
$retValue = (float) Date::PHPToExcel(time());
+
break;
case Functions::RETURNDATE_PHP_NUMERIC:
$retValue = (int) time();
+
break;
case Functions::RETURNDATE_PHP_OBJECT:
$retValue = new \DateTime();
+
break;
}
date_default_timezone_set($saveTimeZone);
@@ -195,12 +198,15 @@ class DateTime
switch (Functions::getReturnDateType()) {
case Functions::RETURNDATE_EXCEL:
$retValue = (float) $excelDateTime;
+
break;
case Functions::RETURNDATE_PHP_NUMERIC:
$retValue = (int) Date::excelToTimestamp($excelDateTime);
+
break;
case Functions::RETURNDATE_PHP_OBJECT:
$retValue = Date::excelToDateTimeObject($excelDateTime);
+
break;
}
date_default_timezone_set($saveTimeZone);
@@ -681,6 +687,7 @@ class DateTime
switch ($unit) {
case 'D':
$retVal = (int) $difference;
+
break;
case 'M':
$retVal = (int) ($endMonths - $startMonths) + ((int) ($endYears - $startYears) * 12);
@@ -688,6 +695,7 @@ class DateTime
if ($endDays < $startDays) {
--$retVal;
}
+
break;
case 'Y':
$retVal = (int) ($endYears - $startYears);
@@ -700,6 +708,7 @@ class DateTime
// Remove end month
--$retVal;
}
+
break;
case 'MD':
if ($endDays < $startDays) {
@@ -710,6 +719,7 @@ class DateTime
} else {
$retVal = $endDays - $startDays;
}
+
break;
case 'YM':
$retVal = (int) ($endMonths - $startMonths);
@@ -720,6 +730,7 @@ class DateTime
if ($endDays < $startDays) {
--$retVal;
}
+
break;
case 'YD':
$retVal = (int) $difference;
@@ -744,6 +755,7 @@ class DateTime
--$retVal;
}
}
+
break;
default:
$retVal = Functions::VALUE();
@@ -1183,11 +1195,13 @@ class DateTime
switch ($style) {
case 1:
++$DoW;
+
break;
case 2:
if ($DoW == 0) {
$DoW = 7;
}
+
break;
case 3:
if ($DoW == 0) {
@@ -1195,6 +1209,7 @@ class DateTime
}
$firstDay = 0;
--$DoW;
+
break;
}
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_EXCEL) {
diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php
index 0b448233..6f1fd2a5 100644
--- a/src/PhpSpreadsheet/Calculation/Engineering.php
+++ b/src/PhpSpreadsheet/Calculation/Engineering.php
@@ -805,7 +805,7 @@ class Engineering
*/
private static function nbrConversionFormat($xVal, $places)
{
- if (!is_null($places)) {
+ if ($places !== null) {
if (is_numeric($places)) {
$places = (int) $places;
} else {
@@ -846,8 +846,8 @@ class Engineering
*/
public static function BESSELI($x, $ord)
{
- $x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x);
- $ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord);
+ $x = ($x === null) ? 0.0 : Functions::flattenSingleValue($x);
+ $ord = ($ord === null) ? 0.0 : Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) {
$ord = floor($ord);
@@ -900,8 +900,8 @@ class Engineering
*/
public static function BESSELJ($x, $ord)
{
- $x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x);
- $ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord);
+ $x = ($x === null) ? 0.0 : Functions::flattenSingleValue($x);
+ $ord = ($ord === null) ? 0.0 : Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) {
$ord = floor($ord);
@@ -993,8 +993,8 @@ class Engineering
*/
public static function BESSELK($x, $ord)
{
- $x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x);
- $ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord);
+ $x = ($x === null) ? 0.0 : Functions::flattenSingleValue($x);
+ $ord = ($ord === null) ? 0.0 : Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) {
if (($ord < 0) || ($x == 0.0)) {
@@ -1004,9 +1004,11 @@ class Engineering
switch (floor($ord)) {
case 0:
$fBk = self::besselK0($x);
+
break;
case 1:
$fBk = self::besselK1($x);
+
break;
default:
$fTox = 2 / $x;
@@ -1080,8 +1082,8 @@ class Engineering
*/
public static function BESSELY($x, $ord)
{
- $x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x);
- $ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord);
+ $x = ($x === null) ? 0.0 : Functions::flattenSingleValue($x);
+ $ord = ($ord === null) ? 0.0 : Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) {
if (($ord < 0) || ($x == 0.0)) {
@@ -1091,9 +1093,11 @@ class Engineering
switch (floor($ord)) {
case 0:
$fBy = self::besselY0($x);
+
break;
case 1:
$fBy = self::besselY1($x);
+
break;
default:
$fTox = 2 / $x;
@@ -1757,9 +1761,9 @@ class Engineering
*/
public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i')
{
- $realNumber = (is_null($realNumber)) ? 0.0 : Functions::flattenSingleValue($realNumber);
- $imaginary = (is_null($imaginary)) ? 0.0 : Functions::flattenSingleValue($imaginary);
- $suffix = (is_null($suffix)) ? 'i' : Functions::flattenSingleValue($suffix);
+ $realNumber = ($realNumber === null) ? 0.0 : Functions::flattenSingleValue($realNumber);
+ $imaginary = ($imaginary === null) ? 0.0 : Functions::flattenSingleValue($imaginary);
+ $suffix = ($suffix === null) ? 'i' : Functions::flattenSingleValue($suffix);
if (((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
(($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))
@@ -1943,7 +1947,7 @@ class Engineering
*
* @param string $complexNumber the complex number for which you want the cosine
*
- * @return string|float
+ * @return float|string
*/
public static function IMCOS($complexNumber)
{
@@ -1974,7 +1978,7 @@ class Engineering
*
* @param string $complexNumber the complex number for which you want the sine
*
- * @return string|float
+ * @return float|string
*/
public static function IMSIN($complexNumber)
{
@@ -2444,7 +2448,7 @@ class Engineering
$upper = Functions::flattenSingleValue($upper);
if (is_numeric($lower)) {
- if (is_null($upper)) {
+ if ($upper === null) {
return self::erfVal($lower);
}
if (is_numeric($upper)) {
@@ -2544,7 +2548,7 @@ class Engineering
{
$conversionGroups = [];
foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) {
- if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
+ if (($group === null) || ($conversionGroup['Group'] == $group)) {
$conversionGroups[$conversionGroup['Group']][] = $conversionUnit;
}
}
@@ -2563,7 +2567,7 @@ class Engineering
{
$conversionGroups = [];
foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) {
- if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
+ if (($group === null) || ($conversionGroup['Group'] == $group)) {
$conversionGroups[$conversionGroup['Group']][] = [
'unit' => $conversionUnit,
'description' => $conversionGroup['Unit Name'],
diff --git a/src/PhpSpreadsheet/Calculation/Exception.php b/src/PhpSpreadsheet/Calculation/Exception.php
index 25bd8ef7..fccf0af7 100644
--- a/src/PhpSpreadsheet/Calculation/Exception.php
+++ b/src/PhpSpreadsheet/Calculation/Exception.php
@@ -20,6 +20,7 @@ class Exception extends PhpSpreadsheetException
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
+
throw $e;
}
}
diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php
index e3cc7fbb..91890c22 100644
--- a/src/PhpSpreadsheet/Calculation/Financial.php
+++ b/src/PhpSpreadsheet/Calculation/Financial.php
@@ -94,12 +94,15 @@ class Financial
case 2:
case 4:
$daysPerYear = 360;
+
break;
case 3:
$daysPerYear = 365;
+
break;
case 1:
$daysPerYear = (DateTime::isLeapYear($year)) ? 366 : 365;
+
break;
default:
return Functions::NAN();
@@ -163,9 +166,9 @@ class Financial
$firstinterest = Functions::flattenSingleValue($firstinterest);
$settlement = Functions::flattenSingleValue($settlement);
$rate = Functions::flattenSingleValue($rate);
- $par = (is_null($par)) ? 1000 : Functions::flattenSingleValue($par);
- $frequency = (is_null($frequency)) ? 1 : Functions::flattenSingleValue($frequency);
- $basis = (is_null($basis)) ? 0 : Functions::flattenSingleValue($basis);
+ $par = ($par === null) ? 1000 : Functions::flattenSingleValue($par);
+ $frequency = ($frequency === null) ? 1 : Functions::flattenSingleValue($frequency);
+ $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($rate)) && (is_numeric($par))) {
@@ -220,8 +223,8 @@ class Financial
$issue = Functions::flattenSingleValue($issue);
$settlement = Functions::flattenSingleValue($settlement);
$rate = Functions::flattenSingleValue($rate);
- $par = (is_null($par)) ? 1000 : Functions::flattenSingleValue($par);
- $basis = (is_null($basis)) ? 0 : Functions::flattenSingleValue($basis);
+ $par = ($par === null) ? 1000 : Functions::flattenSingleValue($par);
+ $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($rate)) && (is_numeric($par))) {
@@ -289,7 +292,7 @@ class Financial
$salvage = Functions::flattenSingleValue($salvage);
$period = floor(Functions::flattenSingleValue($period));
$rate = Functions::flattenSingleValue($rate);
- $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
+ $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
// The depreciation coefficients are:
// Life of assets (1/rate) Depreciation coefficient
@@ -374,7 +377,7 @@ class Financial
$salvage = Functions::flattenSingleValue($salvage);
$period = Functions::flattenSingleValue($period);
$rate = Functions::flattenSingleValue($rate);
- $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
+ $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
$fOneRate = $cost * $rate;
$fCostDelta = $cost - $salvage;
@@ -442,7 +445,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency);
- $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
+ $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE();
@@ -505,7 +508,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency);
- $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
+ $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE();
@@ -585,7 +588,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency);
- $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
+ $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE();
@@ -649,7 +652,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency);
- $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
+ $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE();
@@ -710,7 +713,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency);
- $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
+ $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE();
@@ -787,7 +790,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency);
- $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
+ $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE();
@@ -1128,7 +1131,7 @@ class Financial
$fraction = (int) Functions::flattenSingleValue($fraction);
// Validate parameters
- if (is_null($fractional_dollar) || $fraction < 0) {
+ if ($fractional_dollar === null || $fraction < 0) {
return Functions::NAN();
}
if ($fraction == 0) {
@@ -1166,7 +1169,7 @@ class Financial
$fraction = (int) Functions::flattenSingleValue($fraction);
// Validate parameters
- if (is_null($decimal_dollar) || $fraction < 0) {
+ if ($decimal_dollar === null || $fraction < 0) {
return Functions::NAN();
}
if ($fraction == 0) {
@@ -1247,7 +1250,7 @@ class Financial
}
// Calculate
- if (!is_null($rate) && $rate != 0) {
+ if ($rate !== null && $rate != 0) {
return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate;
}
@@ -1584,7 +1587,7 @@ class Financial
}
// Calculate
- if (!is_null($rate) && $rate != 0) {
+ if ($rate !== null && $rate != 0) {
if ($pmt == 0 && $pv == 0) {
return Functions::NAN();
}
@@ -1653,7 +1656,7 @@ class Financial
}
// Calculate
- if (!is_null($rate) && $rate != 0) {
+ if ($rate !== null && $rate != 0) {
return (-$fv - $pv * pow(1 + $rate, $nper)) / (1 + $rate * $type) / ((pow(1 + $rate, $nper) - 1) / $rate);
}
@@ -1705,7 +1708,7 @@ class Financial
$yield = (float) Functions::flattenSingleValue($yield);
$redemption = (float) Functions::flattenSingleValue($redemption);
$frequency = (int) Functions::flattenSingleValue($frequency);
- $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
+ $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE();
@@ -1887,7 +1890,7 @@ class Financial
}
// Calculate
- if (!is_null($rate) && $rate != 0) {
+ if ($rate !== null && $rate != 0) {
return (-$pmt * (1 + $rate * $type) * ((pow(1 + $rate, $nper) - 1) / $rate) - $fv) / pow(1 + $rate, $nper);
}
@@ -1936,9 +1939,9 @@ class Financial
$nper = (int) Functions::flattenSingleValue($nper);
$pmt = Functions::flattenSingleValue($pmt);
$pv = Functions::flattenSingleValue($pv);
- $fv = (is_null($fv)) ? 0.0 : Functions::flattenSingleValue($fv);
- $type = (is_null($type)) ? 0 : (int) Functions::flattenSingleValue($type);
- $guess = (is_null($guess)) ? 0.1 : Functions::flattenSingleValue($guess);
+ $fv = ($fv === null) ? 0.0 : Functions::flattenSingleValue($fv);
+ $type = ($type === null) ? 0 : (int) Functions::flattenSingleValue($type);
+ $guess = ($guess === null) ? 0.1 : Functions::flattenSingleValue($guess);
$rate = $guess;
if (abs($rate) < self::FINANCIAL_PRECISION) {
diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php
index 827663f9..46b600db 100644
--- a/src/PhpSpreadsheet/Calculation/FormulaParser.php
+++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php
@@ -26,7 +26,7 @@ PARTLY BASED ON:
*/
class FormulaParser
{
- /* Character constants */
+ // Character constants
const QUOTE_DOUBLE = '"';
const QUOTE_SINGLE = '\'';
const BRACKET_CLOSE = ']';
@@ -68,7 +68,7 @@ class FormulaParser
public function __construct($pFormula = '')
{
// Check parameters
- if (is_null($pFormula)) {
+ if ($pFormula === null) {
throw new Exception('Invalid parameter passed: formula');
}
@@ -102,6 +102,7 @@ class FormulaParser
if (isset($this->tokens[$pId])) {
return $this->tokens[$pId];
}
+
throw new Exception("Token with id $pId does not exist.");
}
@@ -170,6 +171,7 @@ class FormulaParser
$value .= $this->formula[$index];
}
++$index;
+
continue;
}
@@ -188,6 +190,7 @@ class FormulaParser
$value .= $this->formula[$index];
}
++$index;
+
continue;
}
@@ -200,6 +203,7 @@ class FormulaParser
}
$value .= $this->formula[$index];
++$index;
+
continue;
}
@@ -213,6 +217,7 @@ class FormulaParser
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND, FormulaToken::TOKEN_SUBTYPE_ERROR);
$value = '';
}
+
continue;
}
@@ -222,6 +227,7 @@ class FormulaParser
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula[$index]) != 0) {
$value .= $this->formula[$index];
++$index;
+
continue;
}
}
@@ -238,6 +244,7 @@ class FormulaParser
}
$inString = true;
++$index;
+
continue;
}
@@ -249,6 +256,7 @@ class FormulaParser
}
$inPath = true;
++$index;
+
continue;
}
@@ -256,6 +264,7 @@ class FormulaParser
$inRange = true;
$value .= self::BRACKET_OPEN;
++$index;
+
continue;
}
@@ -268,6 +277,7 @@ class FormulaParser
$inError = true;
$value .= self::ERROR_START;
++$index;
+
continue;
}
@@ -288,6 +298,7 @@ class FormulaParser
$stack[] = clone $tmp;
++$index;
+
continue;
}
@@ -310,6 +321,7 @@ class FormulaParser
$stack[] = clone $tmp;
++$index;
+
continue;
}
@@ -330,6 +342,7 @@ class FormulaParser
$tokens1[] = $tmp;
++$index;
+
continue;
}
@@ -344,6 +357,7 @@ class FormulaParser
while (($this->formula[$index] == self::WHITESPACE) && ($index < $formulaLength)) {
++$index;
}
+
continue;
}
@@ -356,6 +370,7 @@ class FormulaParser
}
$tokens1[] = new FormulaToken(substr($this->formula, $index, 2), FormulaToken::TOKEN_TYPE_OPERATORINFIX, FormulaToken::TOKEN_SUBTYPE_LOGICAL);
$index += 2;
+
continue;
}
}
@@ -368,6 +383,7 @@ class FormulaParser
}
$tokens1[] = new FormulaToken($this->formula[$index], FormulaToken::TOKEN_TYPE_OPERATORINFIX);
++$index;
+
continue;
}
@@ -379,6 +395,7 @@ class FormulaParser
}
$tokens1[] = new FormulaToken($this->formula[$index], FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
++$index;
+
continue;
}
@@ -395,6 +412,7 @@ class FormulaParser
$stack[] = clone $tmp;
}
++$index;
+
continue;
}
@@ -416,6 +434,7 @@ class FormulaParser
$tokens1[] = new FormulaToken(',', FormulaToken::TOKEN_TYPE_ARGUMENT);
}
++$index;
+
continue;
}
@@ -432,6 +451,7 @@ class FormulaParser
$tokens1[] = $tmp;
++$index;
+
continue;
}
@@ -460,16 +480,17 @@ class FormulaParser
$nextToken = null;
}
- if (is_null($token)) {
+ if ($token === null) {
continue;
}
if ($token->getTokenType() != FormulaToken::TOKEN_TYPE_WHITESPACE) {
$tokens2[] = $token;
+
continue;
}
- if (is_null($previousToken)) {
+ if ($previousToken === null) {
continue;
}
@@ -481,7 +502,7 @@ class FormulaParser
continue;
}
- if (is_null($nextToken)) {
+ if ($nextToken === null) {
continue;
}
@@ -514,7 +535,7 @@ class FormulaParser
$nextToken = null;
}
- if (is_null($token)) {
+ if ($token === null) {
continue;
}
@@ -533,6 +554,7 @@ class FormulaParser
}
$this->tokens[] = $token;
+
continue;
}
@@ -551,6 +573,7 @@ class FormulaParser
}
$this->tokens[] = $token;
+
continue;
}
@@ -565,6 +588,7 @@ class FormulaParser
}
$this->tokens[] = $token;
+
continue;
}
@@ -581,6 +605,7 @@ class FormulaParser
}
$this->tokens[] = $token;
+
continue;
}
diff --git a/src/PhpSpreadsheet/Calculation/FormulaToken.php b/src/PhpSpreadsheet/Calculation/FormulaToken.php
index 56f19916..61c89b90 100644
--- a/src/PhpSpreadsheet/Calculation/FormulaToken.php
+++ b/src/PhpSpreadsheet/Calculation/FormulaToken.php
@@ -27,7 +27,7 @@ PARTLY BASED ON:
class FormulaToken
{
- /* Token types */
+ // Token types
const TOKEN_TYPE_NOOP = 'Noop';
const TOKEN_TYPE_OPERAND = 'Operand';
const TOKEN_TYPE_FUNCTION = 'Function';
@@ -39,7 +39,7 @@ class FormulaToken
const TOKEN_TYPE_WHITESPACE = 'Whitespace';
const TOKEN_TYPE_UNKNOWN = 'Unknown';
- /* Token subtypes */
+ // Token subtypes
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
const TOKEN_SUBTYPE_START = 'Start';
const TOKEN_SUBTYPE_STOP = 'Stop';
diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php
index 97a8cc07..f2539dfa 100644
--- a/src/PhpSpreadsheet/Calculation/Functions.php
+++ b/src/PhpSpreadsheet/Calculation/Functions.php
@@ -278,7 +278,7 @@ class Functions
return '=' . $condition;
}
preg_match('/([<>=]+)(.*)/', $condition, $matches);
- list(, $operator, $operand) = $matches;
+ [, $operator, $operand] = $matches;
if (!is_numeric($operand)) {
$operand = str_replace('"', '""', $operand);
@@ -319,11 +319,11 @@ class Functions
*/
public static function isBlank($value = null)
{
- if (!is_null($value)) {
+ if ($value !== null) {
$value = self::flattenSingleValue($value);
}
- return is_null($value);
+ return $value === null;
}
/**
@@ -377,7 +377,7 @@ class Functions
*
* @param mixed $value Value to check
*
- * @return string|bool
+ * @return bool|string
*/
public static function isEven($value = null)
{
@@ -397,7 +397,7 @@ class Functions
*
* @param mixed $value Value to check
*
- * @return string|bool
+ * @return bool|string
*/
public static function isOdd($value = null)
{
@@ -505,6 +505,7 @@ class Functions
if ((strlen($value) > 0) && ($value[0] == '#')) {
return $value;
}
+
break;
}
diff --git a/src/PhpSpreadsheet/Calculation/Logical.php b/src/PhpSpreadsheet/Calculation/Logical.php
index f13a98d4..ba165974 100644
--- a/src/PhpSpreadsheet/Calculation/Logical.php
+++ b/src/PhpSpreadsheet/Calculation/Logical.php
@@ -60,7 +60,7 @@ class Logical
*
* @param mixed ...$args Data values
*
- * @return string|bool the logical AND of the arguments
+ * @return bool|string the logical AND of the arguments
*/
public static function logicalAnd(...$args)
{
@@ -117,7 +117,7 @@ class Logical
*
* @param mixed $args Data values
*
- * @return string|bool the logical OR of the arguments
+ * @return bool|string the logical OR of the arguments
*/
public static function logicalOr(...$args)
{
@@ -227,9 +227,9 @@ class Logical
*/
public static function statementIf($condition = true, $returnIfTrue = 0, $returnIfFalse = false)
{
- $condition = (is_null($condition)) ? true : (bool) Functions::flattenSingleValue($condition);
- $returnIfTrue = (is_null($returnIfTrue)) ? 0 : Functions::flattenSingleValue($returnIfTrue);
- $returnIfFalse = (is_null($returnIfFalse)) ? false : Functions::flattenSingleValue($returnIfFalse);
+ $condition = ($condition === null) ? true : (bool) Functions::flattenSingleValue($condition);
+ $returnIfTrue = ($returnIfTrue === null) ? 0 : Functions::flattenSingleValue($returnIfTrue);
+ $returnIfFalse = ($returnIfFalse === null) ? false : Functions::flattenSingleValue($returnIfFalse);
return ($condition) ? $returnIfTrue : $returnIfFalse;
}
@@ -249,8 +249,8 @@ class Logical
*/
public static function IFERROR($testValue = '', $errorpart = '')
{
- $testValue = (is_null($testValue)) ? '' : Functions::flattenSingleValue($testValue);
- $errorpart = (is_null($errorpart)) ? '' : Functions::flattenSingleValue($errorpart);
+ $testValue = ($testValue === null) ? '' : Functions::flattenSingleValue($testValue);
+ $errorpart = ($errorpart === null) ? '' : Functions::flattenSingleValue($errorpart);
return self::statementIf(Functions::isError($testValue), $errorpart, $testValue);
}
diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php
index 7ccf4da0..a167b8c8 100644
--- a/src/PhpSpreadsheet/Calculation/LookupRef.php
+++ b/src/PhpSpreadsheet/Calculation/LookupRef.php
@@ -91,7 +91,7 @@ class LookupRef
*/
public static function COLUMN($cellAddress = null)
{
- if (is_null($cellAddress) || trim($cellAddress) === '') {
+ if ($cellAddress === null || trim($cellAddress) === '') {
return 0;
}
@@ -103,10 +103,10 @@ class LookupRef
}
} else {
if (strpos($cellAddress, '!') !== false) {
- list($sheet, $cellAddress) = explode('!', $cellAddress);
+ [$sheet, $cellAddress] = explode('!', $cellAddress);
}
if (strpos($cellAddress, ':') !== false) {
- list($startAddress, $endAddress) = explode(':', $cellAddress);
+ [$startAddress, $endAddress] = explode(':', $cellAddress);
$startAddress = preg_replace('/[^a-z]/i', '', $startAddress);
$endAddress = preg_replace('/[^a-z]/i', '', $endAddress);
$returnValue = [];
@@ -137,7 +137,7 @@ class LookupRef
*/
public static function COLUMNS($cellAddress = null)
{
- if (is_null($cellAddress) || $cellAddress === '') {
+ if ($cellAddress === null || $cellAddress === '') {
return 1;
} elseif (!is_array($cellAddress)) {
return Functions::VALUE();
@@ -145,7 +145,7 @@ class LookupRef
reset($cellAddress);
$isMatrix = (is_numeric(key($cellAddress)));
- list($columns, $rows) = Calculation::_getMatrixDimensions($cellAddress);
+ [$columns, $rows] = Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) {
return $rows;
@@ -172,7 +172,7 @@ class LookupRef
*/
public static function ROW($cellAddress = null)
{
- if (is_null($cellAddress) || trim($cellAddress) === '') {
+ if ($cellAddress === null || trim($cellAddress) === '') {
return 0;
}
@@ -184,10 +184,10 @@ class LookupRef
}
} else {
if (strpos($cellAddress, '!') !== false) {
- list($sheet, $cellAddress) = explode('!', $cellAddress);
+ [$sheet, $cellAddress] = explode('!', $cellAddress);
}
if (strpos($cellAddress, ':') !== false) {
- list($startAddress, $endAddress) = explode(':', $cellAddress);
+ [$startAddress, $endAddress] = explode(':', $cellAddress);
$startAddress = preg_replace('/[^0-9]/', '', $startAddress);
$endAddress = preg_replace('/[^0-9]/', '', $endAddress);
$returnValue = [];
@@ -197,7 +197,7 @@ class LookupRef
return $returnValue;
}
- list($cellAddress) = explode(':', $cellAddress);
+ [$cellAddress] = explode(':', $cellAddress);
return (int) preg_replace('/[^0-9]/', '', $cellAddress);
}
@@ -218,7 +218,7 @@ class LookupRef
*/
public static function ROWS($cellAddress = null)
{
- if (is_null($cellAddress) || $cellAddress === '') {
+ if ($cellAddress === null || $cellAddress === '') {
return 1;
} elseif (!is_array($cellAddress)) {
return Functions::VALUE();
@@ -226,7 +226,7 @@ class LookupRef
reset($cellAddress);
$isMatrix = (is_numeric(key($cellAddress)));
- list($columns, $rows) = Calculation::_getMatrixDimensions($cellAddress);
+ [$columns, $rows] = Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) {
return $columns;
@@ -251,8 +251,8 @@ class LookupRef
*/
public static function HYPERLINK($linkURL = '', $displayName = null, Cell $pCell = null)
{
- $linkURL = (is_null($linkURL)) ? '' : Functions::flattenSingleValue($linkURL);
- $displayName = (is_null($displayName)) ? '' : Functions::flattenSingleValue($displayName);
+ $linkURL = ($linkURL === null) ? '' : Functions::flattenSingleValue($linkURL);
+ $displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName);
if ((!is_object($pCell)) || (trim($linkURL) == '')) {
return Functions::REF();
@@ -289,24 +289,24 @@ class LookupRef
public static function INDIRECT($cellAddress = null, Cell $pCell = null)
{
$cellAddress = Functions::flattenSingleValue($cellAddress);
- if (is_null($cellAddress) || $cellAddress === '') {
+ if ($cellAddress === null || $cellAddress === '') {
return Functions::REF();
}
$cellAddress1 = $cellAddress;
$cellAddress2 = null;
if (strpos($cellAddress, ':') !== false) {
- list($cellAddress1, $cellAddress2) = explode(':', $cellAddress);
+ [$cellAddress1, $cellAddress2] = explode(':', $cellAddress);
}
if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) ||
- ((!is_null($cellAddress2)) && (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches)))) {
+ (($cellAddress2 !== null) && (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches)))) {
if (!preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $cellAddress1, $matches)) {
return Functions::REF();
}
if (strpos($cellAddress, '!') !== false) {
- list($sheetName, $cellAddress) = explode('!', $cellAddress);
+ [$sheetName, $cellAddress] = explode('!', $cellAddress);
$sheetName = trim($sheetName, "'");
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
} else {
@@ -317,7 +317,7 @@ class LookupRef
}
if (strpos($cellAddress, '!') !== false) {
- list($sheetName, $cellAddress) = explode('!', $cellAddress);
+ [$sheetName, $cellAddress] = explode('!', $cellAddress);
$sheetName = trim($sheetName, "'");
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
} else {
@@ -375,16 +375,16 @@ class LookupRef
$sheetName = null;
if (strpos($cellAddress, '!')) {
- list($sheetName, $cellAddress) = explode('!', $cellAddress);
+ [$sheetName, $cellAddress] = explode('!', $cellAddress);
$sheetName = trim($sheetName, "'");
}
if (strpos($cellAddress, ':')) {
- list($startCell, $endCell) = explode(':', $cellAddress);
+ [$startCell, $endCell] = explode(':', $cellAddress);
} else {
$startCell = $endCell = $cellAddress;
}
- list($startCellColumn, $startCellRow) = Cell::coordinateFromString($startCell);
- list($endCellColumn, $endCellRow) = Cell::coordinateFromString($endCell);
+ [$startCellColumn, $startCellRow] = Cell::coordinateFromString($startCell);
+ [$endCellColumn, $endCellRow] = Cell::coordinateFromString($endCell);
$startCellRow += $rows;
$startCellColumn = Cell::columnIndexFromString($startCellColumn) - 1;
@@ -488,7 +488,7 @@ class LookupRef
{
$lookupArray = Functions::flattenArray($lookupArray);
$lookupValue = Functions::flattenSingleValue($lookupValue);
- $matchType = (is_null($matchType)) ? 1 : (int) Functions::flattenSingleValue($matchType);
+ $matchType = ($matchType === null) ? 1 : (int) Functions::flattenSingleValue($matchType);
// MATCH is not case sensitive
$lookupValue = strtolower($lookupValue);
@@ -513,7 +513,7 @@ class LookupRef
foreach ($lookupArray as $i => $lookupArrayValue) {
// check the type of the value
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
- (!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))
+ (!is_bool($lookupArrayValue)) && ($lookupArrayValue !== null)
) {
return Functions::NA();
}
@@ -521,7 +521,7 @@ class LookupRef
if (is_string($lookupArrayValue)) {
$lookupArray[$i] = strtolower($lookupArrayValue);
}
- if ((is_null($lookupArrayValue)) && (($matchType == 1) || ($matchType == -1))) {
+ if (($lookupArrayValue === null) && (($matchType == 1) || ($matchType == -1))) {
$lookupArray = array_slice($lookupArray, 0, $i - 1);
}
}
@@ -747,8 +747,8 @@ class LookupRef
// if an exact match is required, we have what we need to return an appropriate response
return Functions::NA();
}
- // otherwise return the appropriate value
- return $lookup_array[$rowNumber][$returnColumn];
+ // otherwise return the appropriate value
+ return $lookup_array[$rowNumber][$returnColumn];
}
return Functions::NA();
@@ -812,8 +812,8 @@ class LookupRef
// if an exact match is required, we have what we need to return an appropriate response
return Functions::NA();
}
- // otherwise return the appropriate value
- return $lookup_array[$returnColumn][$rowNumber];
+ // otherwise return the appropriate value
+ return $lookup_array[$returnColumn][$rowNumber];
}
return Functions::NA();
@@ -850,7 +850,7 @@ class LookupRef
$lookupColumns = count($lookup_vector[array_shift($l)]);
}
- if (is_null($result_vector)) {
+ if ($result_vector === null) {
$result_vector = $lookup_vector;
}
$resultRows = count($result_vector);
diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php
index d1dd6607..63351930 100644
--- a/src/PhpSpreadsheet/Calculation/MathTrig.php
+++ b/src/PhpSpreadsheet/Calculation/MathTrig.php
@@ -108,7 +108,7 @@ class MathTrig
$number = Functions::flattenSingleValue($number);
$significance = Functions::flattenSingleValue($significance);
- if ((is_null($significance)) &&
+ if (($significance === null) &&
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) {
$significance = $number / abs($number);
}
@@ -182,7 +182,7 @@ class MathTrig
{
$number = Functions::flattenSingleValue($number);
- if (is_null($number)) {
+ if ($number === null) {
return 0;
} elseif (is_bool($number)) {
$number = (int) $number;
@@ -293,7 +293,7 @@ class MathTrig
$number = Functions::flattenSingleValue($number);
$significance = Functions::flattenSingleValue($significance);
- if ((is_null($significance)) &&
+ if (($significance === null) &&
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) {
$significance = $number / abs($number);
}
@@ -409,7 +409,7 @@ class MathTrig
{
$number = Functions::flattenSingleValue($number);
- if (is_null($number)) {
+ if ($number === null) {
return 0;
} elseif (is_bool($number)) {
return (int) $number;
@@ -493,7 +493,7 @@ class MathTrig
public static function logBase($number = null, $base = 10)
{
$number = Functions::flattenSingleValue($number);
- $base = (is_null($base)) ? 10 : (float) Functions::flattenSingleValue($base);
+ $base = ($base === null) ? 10 : (float) Functions::flattenSingleValue($base);
if ((!is_numeric($base)) || (!is_numeric($number))) {
return Functions::VALUE();
@@ -778,7 +778,7 @@ class MathTrig
{
$number = Functions::flattenSingleValue($number);
- if (is_null($number)) {
+ if ($number === null) {
return 1;
} elseif (is_bool($number)) {
return 1;
@@ -850,7 +850,7 @@ class MathTrig
foreach (Functions::flattenArray($args) as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = $arg;
} else {
$returnValue *= $arg;
@@ -859,7 +859,7 @@ class MathTrig
}
// Return
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
return 0;
}
@@ -890,7 +890,7 @@ class MathTrig
foreach (Functions::flattenArray($args) as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = ($arg == 0) ? 0 : $arg;
} else {
if (($returnValue == 0) || ($arg == 0)) {
@@ -929,7 +929,7 @@ class MathTrig
public static function ROMAN($aValue, $style = 0)
{
$aValue = Functions::flattenSingleValue($aValue);
- $style = (is_null($style)) ? 0 : (int) Functions::flattenSingleValue($style);
+ $style = ($style === null) ? 0 : (int) Functions::flattenSingleValue($style);
if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) {
return Functions::VALUE();
}
@@ -1110,7 +1110,7 @@ class MathTrig
return array_filter(
$args,
function ($index) use ($cellReference) {
- list(, $row, $column) = explode('.', $index);
+ [, $row, $column] = explode('.', $index);
return $cellReference->getWorksheet()->getRowDimension($row)->getVisible() &&
$cellReference->getWorksheet()->getColumnDimension($column)->getVisible();
diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php
index 0638c954..50631b5c 100644
--- a/src/PhpSpreadsheet/Calculation/Statistical.php
+++ b/src/PhpSpreadsheet/Calculation/Statistical.php
@@ -26,12 +26,12 @@ class Statistical
$array1 = Functions::flattenArray($array1);
$array2 = Functions::flattenArray($array2);
foreach ($array1 as $key => $value) {
- if ((is_bool($value)) || (is_string($value)) || (is_null($value))) {
+ if ((is_bool($value)) || (is_string($value)) || ($value === null)) {
unset($array1[$key], $array2[$key]);
}
}
foreach ($array2 as $key => $value) {
- if ((is_bool($value)) || (is_string($value)) || (is_null($value))) {
+ if ((is_bool($value)) || (is_string($value)) || ($value === null)) {
unset($array1[$key], $array2[$key]);
}
}
@@ -719,7 +719,7 @@ class Statistical
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = abs($arg - $aMean);
} else {
$returnValue += abs($arg - $aMean);
@@ -765,7 +765,7 @@ class Statistical
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = $arg;
} else {
$returnValue += $arg;
@@ -812,7 +812,7 @@ class Statistical
} elseif (is_string($arg)) {
$arg = 0;
}
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = $arg;
} else {
$returnValue += $arg;
@@ -863,7 +863,7 @@ class Statistical
}
$testCondition = '=' . $arg . $condition;
if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
- if ((is_null($returnValue)) || ($arg > $returnValue)) {
+ if (($returnValue === null) || ($arg > $returnValue)) {
$returnValue += $arg;
++$aCount;
}
@@ -1155,7 +1155,7 @@ class Statistical
*/
public static function CORREL($yValues, $xValues = null)
{
- if ((is_null($xValues)) || (!is_array($yValues)) || (!is_array($xValues))) {
+ if (($xValues === null) || (!is_array($yValues)) || (!is_array($xValues))) {
return Functions::VALUE();
}
if (!self::checkTrendArrays($yValues, $xValues)) {
@@ -1261,7 +1261,7 @@ class Statistical
$aArgs = Functions::flattenArray($args);
foreach ($aArgs as $arg) {
// Is it a blank cell?
- if ((is_null($arg)) || ((is_string($arg)) && ($arg == ''))) {
+ if (($arg === null) || ((is_string($arg)) && ($arg == ''))) {
++$returnValue;
}
}
@@ -1491,7 +1491,7 @@ class Statistical
$arg = (int) $arg;
}
if ((is_numeric($arg)) && (!is_string($arg))) {
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2);
} else {
$returnValue += pow(($arg - $aMean), 2);
@@ -1501,7 +1501,7 @@ class Statistical
}
// Return
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
return Functions::NAN();
}
@@ -1803,7 +1803,7 @@ class Statistical
$yValues = Functions::flattenArray($yValues);
$xValues = Functions::flattenArray($xValues);
$newValues = Functions::flattenArray($newValues);
- $const = (is_null($const)) ? true : (bool) Functions::flattenSingleValue($const);
+ $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const);
$bestFitExponential = Trend::calculate(Trend::TREND_EXPONENTIAL, $yValues, $xValues, $const);
if (empty($newValues)) {
@@ -1850,7 +1850,7 @@ class Statistical
if ($arg <= 0) {
return Functions::NAN();
}
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = (1 / $arg);
} else {
$returnValue += (1 / $arg);
@@ -2042,9 +2042,9 @@ class Statistical
*/
public static function LINEST($yValues, $xValues = null, $const = true, $stats = false)
{
- $const = (is_null($const)) ? true : (bool) Functions::flattenSingleValue($const);
- $stats = (is_null($stats)) ? false : (bool) Functions::flattenSingleValue($stats);
- if (is_null($xValues)) {
+ $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const);
+ $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats);
+ if ($xValues === null) {
$xValues = range(1, count(Functions::flattenArray($yValues)));
}
@@ -2105,9 +2105,9 @@ class Statistical
*/
public static function LOGEST($yValues, $xValues = null, $const = true, $stats = false)
{
- $const = (is_null($const)) ? true : (bool) Functions::flattenSingleValue($const);
- $stats = (is_null($stats)) ? false : (bool) Functions::flattenSingleValue($stats);
- if (is_null($xValues)) {
+ $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const);
+ $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats);
+ if ($xValues === null) {
$xValues = range(1, count(Functions::flattenArray($yValues)));
}
@@ -2240,13 +2240,13 @@ class Statistical
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
- if ((is_null($returnValue)) || ($arg > $returnValue)) {
+ if (($returnValue === null) || ($arg > $returnValue)) {
$returnValue = $arg;
}
}
}
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
return 0;
}
@@ -2281,13 +2281,13 @@ class Statistical
} elseif (is_string($arg)) {
$arg = 0;
}
- if ((is_null($returnValue)) || ($arg > $returnValue)) {
+ if (($returnValue === null) || ($arg > $returnValue)) {
$returnValue = $arg;
}
}
}
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
return 0;
}
@@ -2327,7 +2327,7 @@ class Statistical
}
$testCondition = '=' . $arg . $condition;
if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
- if ((is_null($returnValue)) || ($arg > $returnValue)) {
+ if (($returnValue === null) || ($arg > $returnValue)) {
$returnValue = $arg;
}
}
@@ -2403,13 +2403,13 @@ class Statistical
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
- if ((is_null($returnValue)) || ($arg < $returnValue)) {
+ if (($returnValue === null) || ($arg < $returnValue)) {
$returnValue = $arg;
}
}
}
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
return 0;
}
@@ -2444,13 +2444,13 @@ class Statistical
} elseif (is_string($arg)) {
$arg = 0;
}
- if ((is_null($returnValue)) || ($arg < $returnValue)) {
+ if (($returnValue === null) || ($arg < $returnValue)) {
$returnValue = $arg;
}
}
}
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
return 0;
}
@@ -2490,7 +2490,7 @@ class Statistical
}
$testCondition = '=' . $arg . $condition;
if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
- if ((is_null($returnValue)) || ($arg < $returnValue)) {
+ if (($returnValue === null) || ($arg < $returnValue)) {
$returnValue = $arg;
}
}
@@ -2512,6 +2512,7 @@ class Statistical
if ((string) $value['value'] == (string) $datum) {
++$frequencyArray[$key]['frequency'];
$found = true;
+
break;
}
}
@@ -2780,7 +2781,7 @@ class Statistical
{
$valueSet = Functions::flattenArray($valueSet);
$value = Functions::flattenSingleValue($value);
- $significance = (is_null($significance)) ? 3 : (int) Functions::flattenSingleValue($significance);
+ $significance = ($significance === null) ? 3 : (int) Functions::flattenSingleValue($significance);
foreach ($valueSet as $key => $valueEntry) {
if (!is_numeric($valueEntry)) {
@@ -2934,7 +2935,7 @@ class Statistical
{
$value = Functions::flattenSingleValue($value);
$valueSet = Functions::flattenArray($valueSet);
- $order = (is_null($order)) ? 0 : (int) Functions::flattenSingleValue($order);
+ $order = ($order === null) ? 0 : (int) Functions::flattenSingleValue($order);
foreach ($valueSet as $key => $valueEntry) {
if (!is_numeric($valueEntry)) {
@@ -3151,7 +3152,7 @@ class Statistical
$returnValue = null;
$aMean = self::AVERAGE($aArgs);
- if (!is_null($aMean)) {
+ if ($aMean !== null) {
$aCount = -1;
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
@@ -3160,7 +3161,7 @@ class Statistical
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2);
} else {
$returnValue += pow(($arg - $aMean), 2);
@@ -3199,7 +3200,7 @@ class Statistical
$returnValue = null;
$aMean = self::AVERAGEA($aArgs);
- if (!is_null($aMean)) {
+ if ($aMean !== null) {
$aCount = -1;
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
@@ -3212,7 +3213,7 @@ class Statistical
} elseif (is_string($arg)) {
$arg = 0;
}
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2);
} else {
$returnValue += pow(($arg - $aMean), 2);
@@ -3251,7 +3252,7 @@ class Statistical
$returnValue = null;
$aMean = self::AVERAGE($aArgs);
- if (!is_null($aMean)) {
+ if ($aMean !== null) {
$aCount = 0;
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
@@ -3260,7 +3261,7 @@ class Statistical
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2);
} else {
$returnValue += pow(($arg - $aMean), 2);
@@ -3298,7 +3299,7 @@ class Statistical
$returnValue = null;
$aMean = self::AVERAGEA($aArgs);
- if (!is_null($aMean)) {
+ if ($aMean !== null) {
$aCount = 0;
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
@@ -3311,7 +3312,7 @@ class Statistical
} elseif (is_string($arg)) {
$arg = 0;
}
- if (is_null($returnValue)) {
+ if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2);
} else {
$returnValue += pow(($arg - $aMean), 2);
@@ -3504,7 +3505,7 @@ class Statistical
$yValues = Functions::flattenArray($yValues);
$xValues = Functions::flattenArray($xValues);
$newValues = Functions::flattenArray($newValues);
- $const = (is_null($const)) ? true : (bool) Functions::flattenSingleValue($const);
+ $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const);
$bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues, $const);
if (empty($newValues)) {
@@ -3815,7 +3816,7 @@ class Statistical
$m0 = Functions::flattenSingleValue($m0);
$sigma = Functions::flattenSingleValue($sigma);
- if (is_null($sigma)) {
+ if ($sigma === null) {
$sigma = self::STDEV($dataSet);
}
$n = count($dataSet);
diff --git a/src/PhpSpreadsheet/Calculation/TextData.php b/src/PhpSpreadsheet/Calculation/TextData.php
index 26001040..891c28a1 100644
--- a/src/PhpSpreadsheet/Calculation/TextData.php
+++ b/src/PhpSpreadsheet/Calculation/TextData.php
@@ -155,7 +155,7 @@ class TextData
public static function DOLLAR($value = 0, $decimals = 2)
{
$value = Functions::flattenSingleValue($value);
- $decimals = is_null($decimals) ? 0 : Functions::flattenSingleValue($decimals);
+ $decimals = $decimals === null ? 0 : Functions::flattenSingleValue($decimals);
// Validate parameters
if (!is_numeric($value) || !is_numeric($decimals)) {
@@ -500,7 +500,7 @@ class TextData
*
* @param mixed $testValue Value to check
*
- * @return string|null
+ * @return null|string
*/
public static function RETURNSTRING($testValue = '')
{
diff --git a/src/PhpSpreadsheet/Cell.php b/src/PhpSpreadsheet/Cell.php
index 12542557..c6fd30ff 100644
--- a/src/PhpSpreadsheet/Cell.php
+++ b/src/PhpSpreadsheet/Cell.php
@@ -205,6 +205,7 @@ class Cell
switch ($pDataType) {
case Cell\DataType::TYPE_NULL:
$this->value = $pValue;
+
break;
case Cell\DataType::TYPE_STRING2:
$pDataType = Cell\DataType::TYPE_STRING;
@@ -214,18 +215,23 @@ class Cell
case Cell\DataType::TYPE_INLINE:
// Rich text
$this->value = Cell\DataType::checkString($pValue);
+
break;
case Cell\DataType::TYPE_NUMERIC:
$this->value = (float) $pValue;
+
break;
case Cell\DataType::TYPE_FORMULA:
$this->value = (string) $pValue;
+
break;
case Cell\DataType::TYPE_BOOL:
$this->value = (bool) $pValue;
+
break;
case Cell\DataType::TYPE_ERROR:
$this->value = Cell\DataType::checkErrorCode($pValue);
+
break;
default:
throw new Exception('Invalid datatype: ' . $pDataType);
@@ -265,6 +271,7 @@ class Cell
return $this->calculatedValue; // Fallback for calculations referencing external files.
}
$result = '#N/A';
+
throw new Calculation\Exception(
$this->getWorksheet()->getTitle() . '!' . $this->getCoordinate() . ' -> ' . $ex->getMessage()
);
@@ -493,7 +500,7 @@ class Cell
{
if ($mergeRange = $this->getMergeRange()) {
$mergeRange = self::splitRange($mergeRange);
- list($startCell) = $mergeRange[0];
+ [$startCell] = $mergeRange[0];
if ($this->getCoordinate() === $startCell) {
return true;
}
@@ -551,7 +558,7 @@ class Cell
*/
public function isInRange($pRange)
{
- list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange);
+ [$rangeStart, $rangeEnd] = self::rangeBoundaries($pRange);
// Translate properties
$myColumn = self::columnIndexFromString($this->getColumn());
@@ -601,7 +608,7 @@ class Cell
$worksheet = '';
$cellAddress = explode('!', $pCoordinateString);
if (count($cellAddress) > 1) {
- list($worksheet, $pCoordinateString) = $cellAddress;
+ [$worksheet, $pCoordinateString] = $cellAddress;
}
if ($worksheet > '') {
$worksheet .= '!';
@@ -636,14 +643,14 @@ class Cell
$worksheet = '';
$cellAddress = explode('!', $pCoordinateString);
if (count($cellAddress) > 1) {
- list($worksheet, $pCoordinateString) = $cellAddress;
+ [$worksheet, $pCoordinateString] = $cellAddress;
}
if ($worksheet > '') {
$worksheet .= '!';
}
// Create absolute coordinate
- list($column, $row) = self::coordinateFromString($pCoordinateString);
+ [$column, $row] = self::coordinateFromString($pCoordinateString);
$column = ltrim($column, '$');
$row = ltrim($row, '$');
@@ -727,7 +734,7 @@ class Cell
if (strpos($pRange, ':') === false) {
$rangeA = $rangeB = $pRange;
} else {
- list($rangeA, $rangeB) = explode(':', $pRange);
+ [$rangeA, $rangeB] = explode(':', $pRange);
}
// Calculate range outer borders
@@ -751,7 +758,7 @@ class Cell
public static function rangeDimension($pRange)
{
// Calculate range outer borders
- list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange);
+ [$rangeStart, $rangeEnd] = self::rangeBoundaries($pRange);
return [($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1)];
}
@@ -778,7 +785,7 @@ class Cell
if (strpos($pRange, ':') === false) {
$rangeA = $rangeB = $pRange;
} else {
- list($rangeA, $rangeB) = explode(':', $pRange);
+ [$rangeA, $rangeB] = explode(':', $pRange);
}
return [self::coordinateFromString($rangeA), self::coordinateFromString($rangeB)];
@@ -828,6 +835,7 @@ class Cell
return $_indexCache[$pString];
}
}
+
throw new Exception('Column string index can not be ' . ((isset($pString[0])) ? 'longer than 3 characters' : 'empty'));
}
@@ -874,6 +882,7 @@ class Cell
// Single cell?
if (strpos($cellBlock, ':') === false && strpos($cellBlock, ',') === false) {
$returnValue[] = $cellBlock;
+
continue;
}
@@ -883,11 +892,12 @@ class Cell
// Single cell?
if (!isset($range[1])) {
$returnValue[] = $range[0];
+
continue;
}
// Range...
- list($rangeStart, $rangeEnd) = $range;
+ [$rangeStart, $rangeEnd] = $range;
sscanf($rangeStart, '%[A-Z]%d', $startCol, $startRow);
sscanf($rangeEnd, '%[A-Z]%d', $endCol, $endRow);
++$endCol;
@@ -942,7 +952,7 @@ class Cell
$hashedValues = [];
foreach ($pCoordCollection as $coord => $value) {
- list($column, $row) = self::coordinateFromString($coord);
+ [$column, $row] = self::coordinateFromString($coord);
$row = (int) (ltrim($row, '$'));
$hashCode = $column . '-' . (is_object($value) ? $value->getHashCode() : $value);
diff --git a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php
index 3a40bf90..87cc9266 100644
--- a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php
+++ b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php
@@ -117,7 +117,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
// Check for time without seconds e.g. '9:45', '09:45'
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
// Convert value to number
- list($h, $m) = explode(':', $value);
+ [$h, $m] = explode(':', $value);
$days = $h / 24 + $m / 1440;
$cell->setValueExplicit($days, DataType::TYPE_NUMERIC);
// Set style
@@ -130,7 +130,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
// Check for time with seconds '9:45:59', '09:45:59'
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) {
// Convert value to number
- list($h, $m, $s) = explode(':', $value);
+ [$h, $m, $s] = explode(':', $value);
$days = $h / 24 + $m / 1440 + $s / 86400;
// Convert value to number
$cell->setValueExplicit($days, DataType::TYPE_NUMERIC);
diff --git a/src/PhpSpreadsheet/Cell/DataType.php b/src/PhpSpreadsheet/Cell/DataType.php
index 58900666..f0374edb 100644
--- a/src/PhpSpreadsheet/Cell/DataType.php
+++ b/src/PhpSpreadsheet/Cell/DataType.php
@@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
class DataType
{
- /* Data types */
+ // Data types
const TYPE_STRING2 = 'str';
const TYPE_STRING = 's';
const TYPE_FORMULA = 'f';
diff --git a/src/PhpSpreadsheet/Cell/DataValidation.php b/src/PhpSpreadsheet/Cell/DataValidation.php
index 7f712263..216383a4 100644
--- a/src/PhpSpreadsheet/Cell/DataValidation.php
+++ b/src/PhpSpreadsheet/Cell/DataValidation.php
@@ -4,7 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Cell;
class DataValidation
{
- /* Data validation types */
+ // Data validation types
const TYPE_NONE = 'none';
const TYPE_CUSTOM = 'custom';
const TYPE_DATE = 'date';
@@ -14,12 +14,12 @@ class DataValidation
const TYPE_TIME = 'time';
const TYPE_WHOLE = 'whole';
- /* Data validation error styles */
+ // Data validation error styles
const STYLE_STOP = 'stop';
const STYLE_WARNING = 'warning';
const STYLE_INFORMATION = 'information';
- /* Data validation operators */
+ // Data validation operators
const OPERATOR_BETWEEN = 'between';
const OPERATOR_EQUAL = 'equal';
const OPERATOR_GREATERTHAN = 'greaterThan';
diff --git a/src/PhpSpreadsheet/Chart.php b/src/PhpSpreadsheet/Chart.php
index e0e1ab60..01323642 100644
--- a/src/PhpSpreadsheet/Chart.php
+++ b/src/PhpSpreadsheet/Chart.php
@@ -416,10 +416,10 @@ class Chart
public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null)
{
$this->topLeftCellRef = $cell;
- if (!is_null($xOffset)) {
+ if ($xOffset !== null) {
$this->setTopLeftXOffset($xOffset);
}
- if (!is_null($yOffset)) {
+ if ($yOffset !== null) {
$this->setTopLeftYOffset($yOffset);
}
@@ -474,11 +474,11 @@ class Chart
*/
public function setTopLeftOffset($xOffset, $yOffset)
{
- if (!is_null($xOffset)) {
+ if ($xOffset !== null) {
$this->setTopLeftXOffset($xOffset);
}
- if (!is_null($yOffset)) {
+ if ($yOffset !== null) {
$this->setTopLeftYOffset($yOffset);
}
@@ -534,10 +534,10 @@ class Chart
public function setBottomRightPosition($cell, $xOffset = null, $yOffset = null)
{
$this->bottomRightCellRef = $cell;
- if (!is_null($xOffset)) {
+ if ($xOffset !== null) {
$this->setBottomRightXOffset($xOffset);
}
- if (!is_null($yOffset)) {
+ if ($yOffset !== null) {
$this->setBottomRightYOffset($yOffset);
}
@@ -585,11 +585,11 @@ class Chart
*/
public function setBottomRightOffset($xOffset, $yOffset)
{
- if (!is_null($xOffset)) {
+ if ($xOffset !== null) {
$this->setBottomRightXOffset($xOffset);
}
- if (!is_null($yOffset)) {
+ if ($yOffset !== null) {
$this->setBottomRightYOffset($yOffset);
}
@@ -643,7 +643,7 @@ class Chart
public function render($outputDestination = null)
{
$libraryName = Settings::getChartRendererName();
- if (is_null($libraryName)) {
+ if ($libraryName === null) {
return false;
}
// Ensure that data series values are up-to-date before we render
diff --git a/src/PhpSpreadsheet/Chart/Axis.php b/src/PhpSpreadsheet/Chart/Axis.php
index 40170957..236d40e2 100644
--- a/src/PhpSpreadsheet/Chart/Axis.php
+++ b/src/PhpSpreadsheet/Chart/Axis.php
@@ -278,15 +278,15 @@ class Axis extends Properties
*/
public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null)
{
- (!is_null($line_width)) ? $this->lineStyleProperties['width'] = $this->getExcelPointsWidth((float) $line_width) : null;
- (!is_null($compound_type)) ? $this->lineStyleProperties['compound'] = (string) $compound_type : null;
- (!is_null($dash_type)) ? $this->lineStyleProperties['dash'] = (string) $dash_type : null;
- (!is_null($cap_type)) ? $this->lineStyleProperties['cap'] = (string) $cap_type : null;
- (!is_null($join_type)) ? $this->lineStyleProperties['join'] = (string) $join_type : null;
- (!is_null($head_arrow_type)) ? $this->lineStyleProperties['arrow']['head']['type'] = (string) $head_arrow_type : null;
- (!is_null($head_arrow_size)) ? $this->lineStyleProperties['arrow']['head']['size'] = (string) $head_arrow_size : null;
- (!is_null($end_arrow_type)) ? $this->lineStyleProperties['arrow']['end']['type'] = (string) $end_arrow_type : null;
- (!is_null($end_arrow_size)) ? $this->lineStyleProperties['arrow']['end']['size'] = (string) $end_arrow_size : null;
+ ($line_width !== null) ? $this->lineStyleProperties['width'] = $this->getExcelPointsWidth((float) $line_width) : null;
+ ($compound_type !== null) ? $this->lineStyleProperties['compound'] = (string) $compound_type : null;
+ ($dash_type !== null) ? $this->lineStyleProperties['dash'] = (string) $dash_type : null;
+ ($cap_type !== null) ? $this->lineStyleProperties['cap'] = (string) $cap_type : null;
+ ($join_type !== null) ? $this->lineStyleProperties['join'] = (string) $join_type : null;
+ ($head_arrow_type !== null) ? $this->lineStyleProperties['arrow']['head']['type'] = (string) $head_arrow_type : null;
+ ($head_arrow_size !== null) ? $this->lineStyleProperties['arrow']['head']['size'] = (string) $head_arrow_size : null;
+ ($end_arrow_type !== null) ? $this->lineStyleProperties['arrow']['end']['type'] = (string) $end_arrow_type : null;
+ ($end_arrow_size !== null) ? $this->lineStyleProperties['arrow']['end']['size'] = (string) $end_arrow_size : null;
}
/**
@@ -340,9 +340,9 @@ class Axis extends Properties
{
$this->setShadowPresetsProperties((int) $sh_presets)
->setShadowColor(
- is_null($sh_color_value) ? $this->shadowProperties['color']['value'] : $sh_color_value,
- is_null($sh_color_alpha) ? (int) $this->shadowProperties['color']['alpha'] : $sh_color_alpha,
- is_null($sh_color_type) ? $this->shadowProperties['color']['type'] : $sh_color_type
+ $sh_color_value === null ? $this->shadowProperties['color']['value'] : $sh_color_value,
+ $sh_color_alpha === null ? (int) $this->shadowProperties['color']['alpha'] : $sh_color_alpha,
+ $sh_color_type === null ? $this->shadowProperties['color']['type'] : $sh_color_type
)
->setShadowBlur($sh_blur)
->setShadowAngle($sh_angle)
@@ -481,9 +481,9 @@ class Axis extends Properties
{
$this->setGlowSize($size)
->setGlowColor(
- is_null($color_value) ? $this->glowProperties['color']['value'] : $color_value,
- is_null($color_alpha) ? (int) $this->glowProperties['color']['alpha'] : $color_alpha,
- is_null($color_type) ? $this->glowProperties['color']['type'] : $color_type
+ $color_value === null ? $this->glowProperties['color']['value'] : $color_value,
+ $color_alpha === null ? (int) $this->glowProperties['color']['alpha'] : $color_alpha,
+ $color_type === null ? $this->glowProperties['color']['type'] : $color_type
);
}
@@ -508,7 +508,7 @@ class Axis extends Properties
*/
private function setGlowSize($size)
{
- if (!is_null($size)) {
+ if ($size !== null) {
$this->glowProperties['size'] = $this->getExcelPointsWidth($size);
}
@@ -538,7 +538,7 @@ class Axis extends Properties
*/
public function setSoftEdges($size)
{
- if (!is_null($size)) {
+ if ($size !== null) {
$softEdges['size'] = (string) $this->getExcelPointsWidth($size);
}
}
diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php
index e2057e4b..11aaefcd 100644
--- a/src/PhpSpreadsheet/Chart/DataSeries.php
+++ b/src/PhpSpreadsheet/Chart/DataSeries.php
@@ -123,19 +123,19 @@ class DataSeries
$this->plotOrder = $plotOrder;
$keys = array_keys($plotValues);
$this->plotValues = $plotValues;
- if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
+ if ((count($plotLabel) == 0) || ($plotLabel[$keys[0]] === null)) {
$plotLabel[$keys[0]] = new DataSeriesValues();
}
$this->plotLabel = $plotLabel;
- if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
+ if ((count($plotCategory) == 0) || ($plotCategory[$keys[0]] === null)) {
$plotCategory[$keys[0]] = new DataSeriesValues();
}
$this->plotCategory = $plotCategory;
$this->smoothLine = $smoothLine;
$this->plotStyle = $plotStyle;
- if (is_null($plotDirection)) {
+ if ($plotDirection === null) {
$plotDirection = self::DIRECTION_COL;
}
$this->plotDirection = $plotDirection;
diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php
index 4a880650..ac179762 100644
--- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php
+++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php
@@ -234,7 +234,7 @@ class DataSeriesValues
/**
* Identify if the Data Series is a multi-level or a simple series.
*
- * @return bool|null
+ * @return null|bool
*/
public function isMultiLevelSeries()
{
@@ -324,7 +324,7 @@ class DataSeriesValues
} else {
$cellRange = explode('!', $this->dataSource);
if (count($cellRange) > 1) {
- list(, $cellRange) = $cellRange;
+ [, $cellRange] = $cellRange;
}
$dimensions = Cell::rangeDimension(str_replace('$', '', $cellRange));
diff --git a/src/PhpSpreadsheet/Chart/Exception.php b/src/PhpSpreadsheet/Chart/Exception.php
index 9d2e3ffa..8947b728 100644
--- a/src/PhpSpreadsheet/Chart/Exception.php
+++ b/src/PhpSpreadsheet/Chart/Exception.php
@@ -20,6 +20,7 @@ class Exception extends PhpSpreadsheetException
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
+
throw $e;
}
}
diff --git a/src/PhpSpreadsheet/Chart/GridLines.php b/src/PhpSpreadsheet/Chart/GridLines.php
index 63bbf4dd..eed05d48 100644
--- a/src/PhpSpreadsheet/Chart/GridLines.php
+++ b/src/PhpSpreadsheet/Chart/GridLines.php
@@ -133,31 +133,31 @@ class GridLines extends Properties
public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null)
{
$this->activateObject();
- (!is_null($line_width))
+ ($line_width !== null)
? $this->lineProperties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
: null;
- (!is_null($compound_type))
+ ($compound_type !== null)
? $this->lineProperties['style']['compound'] = (string) $compound_type
: null;
- (!is_null($dash_type))
+ ($dash_type !== null)
? $this->lineProperties['style']['dash'] = (string) $dash_type
: null;
- (!is_null($cap_type))
+ ($cap_type !== null)
? $this->lineProperties['style']['cap'] = (string) $cap_type
: null;
- (!is_null($join_type))
+ ($join_type !== null)
? $this->lineProperties['style']['join'] = (string) $join_type
: null;
- (!is_null($head_arrow_type))
+ ($head_arrow_type !== null)
? $this->lineProperties['style']['arrow']['head']['type'] = (string) $head_arrow_type
: null;
- (!is_null($head_arrow_size))
+ ($head_arrow_size !== null)
? $this->lineProperties['style']['arrow']['head']['size'] = (string) $head_arrow_size
: null;
- (!is_null($end_arrow_type))
+ ($end_arrow_type !== null)
? $this->lineProperties['style']['arrow']['end']['type'] = (string) $end_arrow_type
: null;
- (!is_null($end_arrow_size))
+ ($end_arrow_size !== null)
? $this->lineProperties['style']['arrow']['end']['size'] = (string) $end_arrow_size
: null;
}
@@ -249,13 +249,13 @@ class GridLines extends Properties
*/
private function setGlowColor($color, $alpha, $type)
{
- if (!is_null($color)) {
+ if ($color !== null) {
$this->glowProperties['color']['value'] = (string) $color;
}
- if (!is_null($alpha)) {
+ if ($alpha !== null) {
$this->glowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
- if (!is_null($type)) {
+ if ($type !== null) {
$this->glowProperties['color']['type'] = (string) $type;
}
@@ -291,9 +291,9 @@ class GridLines extends Properties
$this->activateObject()
->setShadowPresetsProperties((int) $sh_presets)
->setShadowColor(
- is_null($sh_color_value) ? $this->shadowProperties['color']['value'] : $sh_color_value,
- is_null($sh_color_alpha) ? (int) $this->shadowProperties['color']['alpha'] : $this->getTrueAlpha($sh_color_alpha),
- is_null($sh_color_type) ? $this->shadowProperties['color']['type'] : $sh_color_type
+ $sh_color_value === null ? $this->shadowProperties['color']['value'] : $sh_color_value,
+ $sh_color_alpha === null ? (int) $this->shadowProperties['color']['alpha'] : $this->getTrueAlpha($sh_color_alpha),
+ $sh_color_type === null ? $this->shadowProperties['color']['type'] : $sh_color_type
)
->setShadowBlur($sh_blur)
->setShadowAngle($sh_angle)
@@ -357,13 +357,13 @@ class GridLines extends Properties
*/
private function setShadowColor($color, $alpha, $type)
{
- if (!is_null($color)) {
+ if ($color !== null) {
$this->shadowProperties['color']['value'] = (string) $color;
}
- if (!is_null($alpha)) {
+ if ($alpha !== null) {
$this->shadowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
- if (!is_null($type)) {
+ if ($type !== null) {
$this->shadowProperties['color']['type'] = (string) $type;
}
@@ -438,7 +438,7 @@ class GridLines extends Properties
*/
public function setSoftEdgesSize($size)
{
- if (!is_null($size)) {
+ if ($size !== null) {
$this->activateObject();
$softEdges['size'] = (string) $this->getExcelPointsWidth($size);
}
diff --git a/src/PhpSpreadsheet/Chart/Legend.php b/src/PhpSpreadsheet/Chart/Legend.php
index e98f96bf..7a817dd1 100644
--- a/src/PhpSpreadsheet/Chart/Legend.php
+++ b/src/PhpSpreadsheet/Chart/Legend.php
@@ -46,13 +46,13 @@ class Legend
*
* @var Layout
*/
- private $layout = null;
+ private $layout;
/**
* Create a new Legend.
*
* @param string $position
- * @param Layout|null $layout
+ * @param null|Layout $layout
* @param bool $overlay
*/
public function __construct($position = self::POSITION_RIGHT, Layout $layout = null, $overlay = false)
diff --git a/src/PhpSpreadsheet/Chart/PlotArea.php b/src/PhpSpreadsheet/Chart/PlotArea.php
index 89f24056..49adfcb2 100644
--- a/src/PhpSpreadsheet/Chart/PlotArea.php
+++ b/src/PhpSpreadsheet/Chart/PlotArea.php
@@ -11,7 +11,7 @@ class PlotArea
*
* @var Layout
*/
- private $layout = null;
+ private $layout;
/**
* Plot Series.
@@ -23,7 +23,7 @@ class PlotArea
/**
* Create a new PlotArea.
*
- * @param Layout|null $layout
+ * @param null|Layout $layout
* @param array $plotSeries
*/
public function __construct(Layout $layout = null, array $plotSeries = [])
diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php
index 624f25a0..8b999e64 100644
--- a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php
+++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php
@@ -42,7 +42,7 @@ class JpGraph
private function formatPointMarker($seriesPlot, $markerID)
{
$plotMarkKeys = array_keys(self::$markSet);
- if (is_null($markerID)) {
+ if ($markerID === null) {
// Use default plot marker (next marker in the series)
self::$plotMark %= count(self::$markSet);
$seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$plotMark++]]);
@@ -69,7 +69,7 @@ class JpGraph
private function formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '')
{
$datasetLabelFormatCode = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode();
- if (!is_null($datasetLabelFormatCode)) {
+ if ($datasetLabelFormatCode !== null) {
// Retrieve any label formatting code
$datasetLabelFormatCode = stripslashes($datasetLabelFormatCode);
}
@@ -85,7 +85,7 @@ class JpGraph
}
} else {
// Format labels according to any formatting code
- if (!is_null($datasetLabelFormatCode)) {
+ if ($datasetLabelFormatCode !== null) {
$datasetLabels[$i] = NumberFormat::toFormattedString($datasetLabel, $datasetLabelFormatCode);
}
}
@@ -128,9 +128,9 @@ class JpGraph
private function getCaption($captionElement)
{
// Read any caption
- $caption = (!is_null($captionElement)) ? $captionElement->getCaption() : null;
+ $caption = ($captionElement !== null) ? $captionElement->getCaption() : null;
// Test if we have a title caption to display
- if (!is_null($caption)) {
+ if ($caption !== null) {
// If we do, it could be a plain string or an array
if (is_array($caption)) {
// Implode an array to a plain string
@@ -144,7 +144,7 @@ class JpGraph
private function renderTitle()
{
$title = $this->getCaption($this->chart->getTitle());
- if (!is_null($title)) {
+ if ($title !== null) {
$this->graph->title->Set($title);
}
}
@@ -152,17 +152,19 @@ class JpGraph
private function renderLegend()
{
$legend = $this->chart->getLegend();
- if (!is_null($legend)) {
+ if ($legend !== null) {
$legendPosition = $legend->getPosition();
$legendOverlay = $legend->getOverlay();
switch ($legendPosition) {
case 'r':
$this->graph->legend->SetPos(0.01, 0.5, 'right', 'center'); // right
$this->graph->legend->SetColumns(1);
+
break;
case 'l':
$this->graph->legend->SetPos(0.01, 0.5, 'left', 'center'); // left
$this->graph->legend->SetColumns(1);
+
break;
case 't':
$this->graph->legend->SetPos(0.5, 0.01, 'center', 'top'); // top
@@ -173,6 +175,7 @@ class JpGraph
default:
$this->graph->legend->SetPos(0.01, 0.01, 'right', 'top'); // top-right
$this->graph->legend->SetColumns(1);
+
break;
}
} else {
@@ -192,9 +195,9 @@ class JpGraph
$reverse = ($rotation == 'bar') ? true : false;
$xAxisLabel = $this->chart->getXAxisLabel();
- if (!is_null($xAxisLabel)) {
+ if ($xAxisLabel !== null) {
$title = $this->getCaption($xAxisLabel);
- if (!is_null($title)) {
+ if ($title !== null) {
$this->graph->xaxis->SetTitle($title, 'center');
$this->graph->xaxis->title->SetMargin(35);
if ($reverse) {
@@ -205,9 +208,9 @@ class JpGraph
}
$yAxisLabel = $this->chart->getYAxisLabel();
- if (!is_null($yAxisLabel)) {
+ if ($yAxisLabel !== null) {
$title = $this->getCaption($yAxisLabel);
- if (!is_null($title)) {
+ if ($title !== null) {
$this->graph->yaxis->SetTitle($title, 'center');
if ($reverse) {
$this->graph->yaxis->title->SetAngle(0);
@@ -402,7 +405,7 @@ class JpGraph
$seriesPlot->link->SetColor(self::$colourSet[self::$plotColour]);
} elseif ($scatterStyle == 'smoothMarker') {
$spline = new Spline($dataValuesY, $dataValuesX);
- list($splineDataY, $splineDataX) = $spline->Get(count($dataValuesX) * self::$width / 20);
+ [$splineDataY, $splineDataX] = $spline->Get(count($dataValuesX) * self::$width / 20);
$lplot = new LinePlot($splineDataX, $splineDataY);
$lplot->SetColor(self::$colourSet[self::$plotColour]);
@@ -706,24 +709,29 @@ class JpGraph
// no break
case 'areaChart':
$this->renderPlotLine($i, true, true, $dimensions);
+
break;
case 'bar3DChart':
$dimensions = '3d';
// no break
case 'barChart':
$this->renderPlotBar($i, $dimensions);
+
break;
case 'line3DChart':
$dimensions = '3d';
// no break
case 'lineChart':
$this->renderPlotLine($i, false, true, $dimensions);
+
break;
case 'scatterChart':
$this->renderPlotScatter($i, false);
+
break;
case 'bubbleChart':
$this->renderPlotScatter($i, true);
+
break;
default:
$this->graph = null;
@@ -771,48 +779,58 @@ class JpGraph
// no break
case 'areaChart':
$this->renderAreaChart($groupCount, $dimensions);
+
break;
case 'bar3DChart':
$dimensions = '3d';
// no break
case 'barChart':
$this->renderBarChart($groupCount, $dimensions);
+
break;
case 'line3DChart':
$dimensions = '3d';
// no break
case 'lineChart':
$this->renderLineChart($groupCount, $dimensions);
+
break;
case 'pie3DChart':
$dimensions = '3d';
// no break
case 'pieChart':
$this->renderPieChart($groupCount, $dimensions, false, false);
+
break;
case 'doughnut3DChart':
$dimensions = '3d';
// no break
case 'doughnutChart':
$this->renderPieChart($groupCount, $dimensions, true, true);
+
break;
case 'scatterChart':
$this->renderScatterChart($groupCount);
+
break;
case 'bubbleChart':
$this->renderBubbleChart($groupCount);
+
break;
case 'radarChart':
$this->renderRadarChart($groupCount);
+
break;
case 'surface3DChart':
$dimensions = '3d';
// no break
case 'surfaceChart':
$this->renderContourChart($groupCount, $dimensions);
+
break;
case 'stockChart':
$this->renderStockChart($groupCount);
+
break;
default:
echo $chartType . ' is not yet implemented
';
diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php
index a49c3203..f53c6b37 100644
--- a/src/PhpSpreadsheet/Chart/Title.php
+++ b/src/PhpSpreadsheet/Chart/Title.php
@@ -9,14 +9,14 @@ class Title
*
* @var string
*/
- private $caption = null;
+ private $caption;
/**
* Title Layout.
*
* @var Layout
*/
- private $layout = null;
+ private $layout;
/**
* Create a new Title.
diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php
index 6a94b893..583eaa8e 100644
--- a/src/PhpSpreadsheet/Collection/Cells.php
+++ b/src/PhpSpreadsheet/Collection/Cells.php
@@ -26,14 +26,14 @@ class Cells
*
* @var Cell
*/
- private $currentCell = null;
+ private $currentCell;
/**
* Coordinate of the currently active Cell.
*
* @var string
*/
- private $currentCoordinate = null;
+ private $currentCoordinate;
/**
* Flag indicating whether the currently active Cell requires saving.
@@ -54,7 +54,7 @@ class Cells
*
* @var string
*/
- private $cachePrefix = null;
+ private $cachePrefix;
/**
* Initialise this new cell collection.
@@ -121,7 +121,7 @@ class Cells
*/
public function delete($pCoord)
{
- if ($pCoord === $this->currentCoordinate && !is_null($this->currentCell)) {
+ if ($pCoord === $this->currentCoordinate && $this->currentCell !== null) {
$this->currentCell->detach();
$this->currentCoordinate = null;
$this->currentCell = null;
@@ -321,6 +321,7 @@ class Cells
$stored = $newCollection->cache->setMultiple($newValues);
if (!$stored) {
$newCollection->__destruct();
+
throw new PhpSpreadsheetException('Failed to copy cells in cache');
}
@@ -371,6 +372,7 @@ class Cells
$stored = $this->cache->set($this->cachePrefix . $this->currentCoordinate, $this->currentCell);
if (!$stored) {
$this->__destruct();
+
throw new PhpSpreadsheetException("Failed to store cell {$this->currentCoordinate} in cache");
}
$this->currentCellIsDirty = false;
@@ -446,7 +448,7 @@ class Cells
*/
public function unsetWorksheetCells()
{
- if (!is_null($this->currentCell)) {
+ if ($this->currentCell !== null) {
$this->currentCell->detach();
$this->currentCell = null;
$this->currentCoordinate = null;
diff --git a/src/PhpSpreadsheet/Exception.php b/src/PhpSpreadsheet/Exception.php
index b8e85cff..1c8be172 100644
--- a/src/PhpSpreadsheet/Exception.php
+++ b/src/PhpSpreadsheet/Exception.php
@@ -18,6 +18,7 @@ class Exception extends \Exception
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
+
throw $e;
}
}
diff --git a/src/PhpSpreadsheet/IOFactory.php b/src/PhpSpreadsheet/IOFactory.php
index d3c01631..9b3a0f2d 100644
--- a/src/PhpSpreadsheet/IOFactory.php
+++ b/src/PhpSpreadsheet/IOFactory.php
@@ -211,27 +211,34 @@ class IOFactory
case 'xltx': // Excel (OfficeOpenXML) Template
case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
$extensionType = 'Xlsx';
+
break;
case 'xls': // Excel (BIFF) Spreadsheet
case 'xlt': // Excel (BIFF) Template
$extensionType = 'Xls';
+
break;
case 'ods': // Open/Libre Offic Calc
case 'ots': // Open/Libre Offic Calc Template
$extensionType = 'Ods';
+
break;
case 'slk':
$extensionType = 'Slk';
+
break;
case 'xml': // Excel 2003 SpreadSheetML
$extensionType = 'Xml';
+
break;
case 'gnumeric':
$extensionType = 'Gnumeric';
+
break;
case 'htm':
case 'html':
$extensionType = 'Html';
+
break;
case 'csv':
// Do nothing
diff --git a/src/PhpSpreadsheet/NamedRange.php b/src/PhpSpreadsheet/NamedRange.php
index 688069d8..4443e8cf 100644
--- a/src/PhpSpreadsheet/NamedRange.php
+++ b/src/PhpSpreadsheet/NamedRange.php
@@ -46,7 +46,7 @@ class NamedRange
* @param Worksheet $pWorksheet
* @param string $pRange
* @param bool $pLocalOnly
- * @param Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
+ * @param null|Worksheet $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
*
* @throws Exception
*/
@@ -186,7 +186,7 @@ class NamedRange
/**
* Get scope.
*
- * @return Worksheet|null
+ * @return null|Worksheet
*/
public function getScope()
{
@@ -196,7 +196,7 @@ class NamedRange
/**
* Set scope.
*
- * @param Worksheet|null $value
+ * @param null|Worksheet $value
*
* @return NamedRange
*/
@@ -212,7 +212,7 @@ class NamedRange
* Resolve a named range to a regular cell range.
*
* @param string $pNamedRange Named range
- * @param Worksheet|null $pSheet Scope. Use null for global scope
+ * @param null|Worksheet $pSheet Scope. Use null for global scope
*
* @return NamedRange
*/
diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php
index ebd644c0..6c2cfa49 100644
--- a/src/PhpSpreadsheet/Reader/BaseReader.php
+++ b/src/PhpSpreadsheet/Reader/BaseReader.php
@@ -47,7 +47,7 @@ abstract class BaseReader implements IReader
*/
protected $readFilter;
- protected $fileHandle = null;
+ protected $fileHandle;
/**
* Read data only?
diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php
index 0789bb87..405c1c82 100644
--- a/src/PhpSpreadsheet/Reader/Csv.php
+++ b/src/PhpSpreadsheet/Reader/Csv.php
@@ -20,7 +20,7 @@ class Csv extends BaseReader implements IReader
*
* @var string
*/
- private $delimiter = null;
+ private $delimiter;
/**
* Enclosure.
@@ -91,22 +91,27 @@ class Csv extends BaseReader implements IReader
case 'UTF-8':
fgets($this->fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($this->fileHandle, 3) : fseek($this->fileHandle, 0);
+
break;
case 'UTF-16LE':
fgets($this->fileHandle, 3) == "\xFF\xFE" ?
fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0);
+
break;
case 'UTF-16BE':
fgets($this->fileHandle, 3) == "\xFE\xFF" ?
fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0);
+
break;
case 'UTF-32LE':
fgets($this->fileHandle, 5) == "\xFF\xFE\x00\x00" ?
fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0);
+
break;
case 'UTF-32BE':
fgets($this->fileHandle, 5) == "\x00\x00\xFE\xFF" ?
fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0);
+
break;
default:
break;
diff --git a/src/PhpSpreadsheet/Reader/Exception.php b/src/PhpSpreadsheet/Reader/Exception.php
index e67e906b..54004132 100644
--- a/src/PhpSpreadsheet/Reader/Exception.php
+++ b/src/PhpSpreadsheet/Reader/Exception.php
@@ -20,6 +20,7 @@ class Exception extends PhpSpreadsheetException
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
+
throw $e;
}
}
diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php
index e6891775..17547d29 100644
--- a/src/PhpSpreadsheet/Reader/Gnumeric.php
+++ b/src/PhpSpreadsheet/Reader/Gnumeric.php
@@ -34,7 +34,7 @@ class Gnumeric extends BaseReader implements IReader
*/
private $expressions = [];
- private $referenceHelper = null;
+ private $referenceHelper;
/**
* Create a new Gnumeric.
@@ -141,6 +141,7 @@ class Gnumeric extends BaseReader implements IReader
} elseif ($xml->name == 'gnm:MaxRow' && $xml->nodeType == XMLReader::ELEMENT) {
$xml->read(); // Move onto the value node
$tmpInfo['totalRows'] = (int) $xml->value + 1;
+
break;
}
}
@@ -228,21 +229,26 @@ class Gnumeric extends BaseReader implements IReader
switch ($propertyName) {
case 'title':
$docProps->setTitle(trim($propertyValue));
+
break;
case 'subject':
$docProps->setSubject(trim($propertyValue));
+
break;
case 'creator':
$docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue));
+
break;
case 'date':
$creationDate = strtotime(trim($propertyValue));
$docProps->setCreated($creationDate);
$docProps->setModified($creationDate);
+
break;
case 'description':
$docProps->setDescription(trim($propertyValue));
+
break;
}
}
@@ -256,29 +262,36 @@ class Gnumeric extends BaseReader implements IReader
switch ($propertyName) {
case 'keyword':
$docProps->setKeywords(trim($propertyValue));
+
break;
case 'initial-creator':
$docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue));
+
break;
case 'creation-date':
$creationDate = strtotime(trim($propertyValue));
$docProps->setCreated($creationDate);
$docProps->setModified($creationDate);
+
break;
case 'user-defined':
- list(, $attrName) = explode(':', $attributes['name']);
+ [, $attrName] = explode(':', $attributes['name']);
switch ($attrName) {
case 'publisher':
$docProps->setCompany(trim($propertyValue));
+
break;
case 'category':
$docProps->setCategory(trim($propertyValue));
+
break;
case 'manager':
$docProps->setManager(trim($propertyValue));
+
break;
}
+
break;
}
}
@@ -290,25 +303,32 @@ class Gnumeric extends BaseReader implements IReader
switch ($propertyName) {
case 'title':
$docProps->setTitle(trim($propertyValue));
+
break;
case 'comments':
$docProps->setDescription(trim($propertyValue));
+
break;
case 'keywords':
$docProps->setKeywords(trim($propertyValue));
+
break;
case 'category':
$docProps->setCategory(trim($propertyValue));
+
break;
case 'manager':
$docProps->setManager(trim($propertyValue));
+
break;
case 'author':
$docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue));
+
break;
case 'company':
$docProps->setCompany(trim($propertyValue));
+
break;
}
}
@@ -339,26 +359,33 @@ class Gnumeric extends BaseReader implements IReader
switch ($marginAttributes['PrefUnit']) {
case 'mm':
$marginSize = (int) ($marginAttributes['Points']) / 100;
+
break;
}
switch ($key) {
case 'top':
$spreadsheet->getActiveSheet()->getPageMargins()->setTop($marginSize);
+
break;
case 'bottom':
$spreadsheet->getActiveSheet()->getPageMargins()->setBottom($marginSize);
+
break;
case 'left':
$spreadsheet->getActiveSheet()->getPageMargins()->setLeft($marginSize);
+
break;
case 'right':
$spreadsheet->getActiveSheet()->getPageMargins()->setRight($marginSize);
+
break;
case 'header':
$spreadsheet->getActiveSheet()->getPageMargins()->setHeader($marginSize);
+
break;
case 'footer':
$spreadsheet->getActiveSheet()->getPageMargins()->setFooter($marginSize);
+
break;
}
}
@@ -412,22 +439,28 @@ class Gnumeric extends BaseReader implements IReader
switch ($ValueType) {
case '10': // NULL
$type = Cell\DataType::TYPE_NULL;
+
break;
case '20': // Boolean
$type = Cell\DataType::TYPE_BOOL;
$cell = ($cell == 'TRUE') ? true : false;
+
break;
case '30': // Integer
$cell = (int) $cell;
// Excel 2007+ doesn't differentiate between integer and float, so set the value and dropthru to the next (numeric) case
+ // no break
case '40': // Float
$type = Cell\DataType::TYPE_NUMERIC;
+
break;
case '50': // Error
$type = Cell\DataType::TYPE_ERROR;
+
break;
case '60': // String
$type = Cell\DataType::TYPE_STRING;
+
break;
case '70': // Cell Range
case '80': // Array
@@ -470,37 +503,47 @@ class Gnumeric extends BaseReader implements IReader
switch ($styleAttributes['HAlign']) {
case '1':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_GENERAL;
+
break;
case '2':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_LEFT;
+
break;
case '4':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_RIGHT;
+
break;
case '8':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER;
+
break;
case '16':
case '64':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER_CONTINUOUS;
+
break;
case '32':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_JUSTIFY;
+
break;
}
switch ($styleAttributes['VAlign']) {
case '1':
$styleArray['alignment']['vertical'] = Alignment::VERTICAL_TOP;
+
break;
case '2':
$styleArray['alignment']['vertical'] = Alignment::VERTICAL_BOTTOM;
+
break;
case '4':
$styleArray['alignment']['vertical'] = Alignment::VERTICAL_CENTER;
+
break;
case '8':
$styleArray['alignment']['vertical'] = Alignment::VERTICAL_JUSTIFY;
+
break;
}
@@ -519,63 +562,83 @@ class Gnumeric extends BaseReader implements IReader
switch ($shade) {
case '1':
$styleArray['fill']['fillType'] = Fill::FILL_SOLID;
+
break;
case '2':
$styleArray['fill']['fillType'] = Fill::FILL_GRADIENT_LINEAR;
+
break;
case '3':
$styleArray['fill']['fillType'] = Fill::FILL_GRADIENT_PATH;
+
break;
case '4':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKDOWN;
+
break;
case '5':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKGRAY;
+
break;
case '6':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKGRID;
+
break;
case '7':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKHORIZONTAL;
+
break;
case '8':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKTRELLIS;
+
break;
case '9':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKUP;
+
break;
case '10':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKVERTICAL;
+
break;
case '11':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_GRAY0625;
+
break;
case '12':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_GRAY125;
+
break;
case '13':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTDOWN;
+
break;
case '14':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTGRAY;
+
break;
case '15':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTGRID;
+
break;
case '16':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTHORIZONTAL;
+
break;
case '17':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTTRELLIS;
+
break;
case '18':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTUP;
+
break;
case '19':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTVERTICAL;
+
break;
case '20':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_MEDIUMGRAY;
+
break;
}
}
@@ -589,26 +652,33 @@ class Gnumeric extends BaseReader implements IReader
switch ($fontAttributes['Underline']) {
case '1':
$styleArray['font']['underline'] = Font::UNDERLINE_SINGLE;
+
break;
case '2':
$styleArray['font']['underline'] = Font::UNDERLINE_DOUBLE;
+
break;
case '3':
$styleArray['font']['underline'] = Font::UNDERLINE_SINGLEACCOUNTING;
+
break;
case '4':
$styleArray['font']['underline'] = Font::UNDERLINE_DOUBLEACCOUNTING;
+
break;
default:
$styleArray['font']['underline'] = Font::UNDERLINE_NONE;
+
break;
}
switch ($fontAttributes['Script']) {
case '1':
$styleArray['font']['superscript'] = true;
+
break;
case '-1':
$styleArray['font']['subscript'] = true;
+
break;
}
@@ -749,45 +819,59 @@ class Gnumeric extends BaseReader implements IReader
switch ($borderAttributes['Style']) {
case '0':
$styleArray['borderStyle'] = Border::BORDER_NONE;
+
break;
case '1':
$styleArray['borderStyle'] = Border::BORDER_THIN;
+
break;
case '2':
$styleArray['borderStyle'] = Border::BORDER_MEDIUM;
+
break;
case '3':
$styleArray['borderStyle'] = Border::BORDER_SLANTDASHDOT;
+
break;
case '4':
$styleArray['borderStyle'] = Border::BORDER_DASHED;
+
break;
case '5':
$styleArray['borderStyle'] = Border::BORDER_THICK;
+
break;
case '6':
$styleArray['borderStyle'] = Border::BORDER_DOUBLE;
+
break;
case '7':
$styleArray['borderStyle'] = Border::BORDER_DOTTED;
+
break;
case '8':
$styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHED;
+
break;
case '9':
$styleArray['borderStyle'] = Border::BORDER_DASHDOT;
+
break;
case '10':
$styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOT;
+
break;
case '11':
$styleArray['borderStyle'] = Border::BORDER_DASHDOTDOT;
+
break;
case '12':
$styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOTDOT;
+
break;
case '13':
$styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOTDOT;
+
break;
}
@@ -804,7 +888,7 @@ class Gnumeric extends BaseReader implements IReader
private static function parseGnumericColour($gnmColour)
{
- list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour);
+ [$gnmR, $gnmG, $gnmB] = explode(':', $gnmColour);
$gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2);
$gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2);
$gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2);
diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php
index 55a874fb..d1e05ade 100644
--- a/src/PhpSpreadsheet/Reader/Html.php
+++ b/src/PhpSpreadsheet/Reader/Html.php
@@ -273,7 +273,7 @@ class Html extends BaseReader implements IReader
// simply append the text if the cell content is a plain text string
$cellContent .= $domText;
}
- // but if we have a rich text run instead, we need to append it correctly
+ // but if we have a rich text run instead, we need to append it correctly
// TODO
} elseif ($child instanceof DOMElement) {
$attributeArray = [];
@@ -292,11 +292,13 @@ class Html extends BaseReader implements IReader
}
}
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
+
break;
case 'title':
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
$sheet->setTitle($cellContent, true, false);
$cellContent = '';
+
break;
case 'span':
case 'div':
@@ -312,6 +314,7 @@ class Html extends BaseReader implements IReader
if ($cellContent > '') {
$cellContent .= ' ';
}
+
break;
case 'hr':
$this->flushCell($sheet, $column, $row, $cellContent);
@@ -324,6 +327,7 @@ class Html extends BaseReader implements IReader
}
++$row;
// Add a break after a horizontal rule, simply by allowing the code to dropthru
+ // no break
case 'br':
if ($this->tableLevel > 0) {
// If we're inside a table, replace with a \n
@@ -333,6 +337,7 @@ class Html extends BaseReader implements IReader
$this->flushCell($sheet, $column, $row, $cellContent);
++$row;
}
+
break;
case 'a':
foreach ($attributeArray as $attributeName => $attributeValue) {
@@ -342,11 +347,13 @@ class Html extends BaseReader implements IReader
if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
}
+
break;
}
}
$cellContent .= ' ';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
+
break;
case 'h1':
case 'h2':
@@ -376,6 +383,7 @@ class Html extends BaseReader implements IReader
++$row;
$column = 'A';
}
+
break;
case 'li':
if ($this->tableLevel > 0) {
@@ -391,6 +399,7 @@ class Html extends BaseReader implements IReader
$this->flushCell($sheet, $column, $row, $cellContent);
$column = 'A';
}
+
break;
case 'table':
$this->flushCell($sheet, $column, $row, $cellContent);
@@ -405,16 +414,19 @@ class Html extends BaseReader implements IReader
} else {
++$row;
}
+
break;
case 'thead':
case 'tbody':
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
+
break;
case 'tr':
$column = $this->getTableStartColumn();
$cellContent = '';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
++$row;
+
break;
case 'th':
case 'td':
@@ -429,7 +441,7 @@ class Html extends BaseReader implements IReader
$this->flushCell($sheet, $column, $row, $cellContent);
- if (isset($attributeArray['rowspan']) && isset($attributeArray['colspan'])) {
+ if (isset($attributeArray['rowspan'], $attributeArray['colspan'])) {
//create merging rowspan and colspan
$columnTo = $column;
for ($i = 0; $i < $attributeArray['colspan'] - 1; ++$i) {
@@ -467,6 +479,7 @@ class Html extends BaseReader implements IReader
);
}
++$column;
+
break;
case 'body':
$row = 1;
@@ -474,6 +487,7 @@ class Html extends BaseReader implements IReader
$content = '';
$this->tableLevel = 0;
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
+
break;
default:
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
@@ -610,9 +624,11 @@ class Html extends BaseReader implements IReader
switch (trim($value[0])) {
case 'background-color':
$sheet->getStyle($column . $row)->applyFromArray(['fill' => ['fillType' => Fill::FILL_SOLID, 'color' => ['rgb' => "{$style_color}"]]]);
+
break;
case 'color':
$sheet->getStyle($column . $row)->applyFromArray(['font' => ['color' => ['rgb' => "$style_color}"]]]);
+
break;
}
}
diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php
index 25ac66fc..3994606d 100644
--- a/src/PhpSpreadsheet/Reader/Ods.php
+++ b/src/PhpSpreadsheet/Reader/Ods.php
@@ -70,6 +70,7 @@ class Ods extends BaseReader implements IReader
$manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']);
if ($manifestAttributes->{'full-path'} == '/') {
$mimeType = (string) $manifestAttributes->{'media-type'};
+
break;
}
}
@@ -177,7 +178,7 @@ class Ods extends BaseReader implements IReader
$xml->next();
}
}
- // Now read each node until we find our first table:table node
+ // Now read each node until we find our first table:table node
while ($xml->read()) {
if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) {
$worksheetNames[] = $xml->getAttribute('table:name');
@@ -284,9 +285,7 @@ class Ods extends BaseReader implements IReader
throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.');
}
- /*
- * Meta
- */
+ // Meta
$xml = simplexml_load_string(
$this->securityScan($zip->getFromName('meta.xml')),
@@ -307,21 +306,26 @@ class Ods extends BaseReader implements IReader
switch ($propertyName) {
case 'title':
$docProps->setTitle($propertyValue);
+
break;
case 'subject':
$docProps->setSubject($propertyValue);
+
break;
case 'creator':
$docProps->setCreator($propertyValue);
$docProps->setLastModifiedBy($propertyValue);
+
break;
case 'date':
$creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate);
$docProps->setModified($creationDate);
+
break;
case 'description':
$docProps->setDescription($propertyValue);
+
break;
}
}
@@ -335,13 +339,16 @@ class Ods extends BaseReader implements IReader
switch ($propertyName) {
case 'initial-creator':
$docProps->setCreator($propertyValue);
+
break;
case 'keyword':
$docProps->setKeywords($propertyValue);
+
break;
case 'creation-date':
$creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate);
+
break;
case 'user-defined':
$propertyValueType = Properties::PROPERTY_TYPE_STRING;
@@ -353,14 +360,17 @@ class Ods extends BaseReader implements IReader
case 'date':
$propertyValue = Properties::convertProperty($propertyValue, 'date');
$propertyValueType = Properties::PROPERTY_TYPE_DATE;
+
break;
case 'boolean':
$propertyValue = Properties::convertProperty($propertyValue, 'bool');
$propertyValueType = Properties::PROPERTY_TYPE_BOOLEAN;
+
break;
case 'float':
$propertyValue = Properties::convertProperty($propertyValue, 'r4');
$propertyValueType = Properties::PROPERTY_TYPE_FLOAT;
+
break;
default:
$propertyValueType = Properties::PROPERTY_TYPE_STRING;
@@ -368,14 +378,13 @@ class Ods extends BaseReader implements IReader
}
}
$docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType);
+
break;
}
}
}
- /*
- * Content
- */
+ // Content
$dom = new \DOMDocument('1.01', 'UTF-8');
$dom->loadXML(
@@ -459,11 +468,12 @@ class Ods extends BaseReader implements IReader
$columnID = 'A';
foreach ($childNode->childNodes as $key => $cellData) {
- /* @var \DOMElement $cellData */
+ // @var \DOMElement $cellData
if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
++$columnID;
+
continue;
}
}
@@ -540,6 +550,7 @@ class Ods extends BaseReader implements IReader
case 'boolean':
$type = DataType::TYPE_BOOL;
$dataValue = ($allCellDataText == 'TRUE') ? true : false;
+
break;
case 'percentage':
$type = DataType::TYPE_NUMERIC;
@@ -549,6 +560,7 @@ class Ods extends BaseReader implements IReader
$dataValue = (int) $dataValue;
}
$formatting = NumberFormat::FORMAT_PERCENTAGE_00;
+
break;
case 'currency':
$type = DataType::TYPE_NUMERIC;
@@ -558,6 +570,7 @@ class Ods extends BaseReader implements IReader
$dataValue = (int) $dataValue;
}
$formatting = NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
+
break;
case 'float':
$type = DataType::TYPE_NUMERIC;
@@ -570,6 +583,7 @@ class Ods extends BaseReader implements IReader
$dataValue = (float) $dataValue;
}
}
+
break;
case 'date':
$type = DataType::TYPE_NUMERIC;
@@ -577,7 +591,7 @@ class Ods extends BaseReader implements IReader
$dateObj = new DateTime($value, $GMT);
$dateObj->setTimeZone($timezoneObj);
- list($year, $month, $day, $hour, $minute, $second) = explode(
+ [$year, $month, $day, $hour, $minute, $second] = explode(
' ',
$dateObj->format('Y m d H i s')
);
@@ -598,6 +612,7 @@ class Ods extends BaseReader implements IReader
} else {
$formatting = NumberFormat::FORMAT_DATE_XLSX15;
}
+
break;
case 'time':
$type = DataType::TYPE_NUMERIC;
@@ -610,6 +625,7 @@ class Ods extends BaseReader implements IReader
)
);
$formatting = NumberFormat::FORMAT_DATE_TIME4;
+
break;
default:
$dataValue = null;
@@ -729,6 +745,7 @@ class Ods extends BaseReader implements IReader
++$columnID;
}
$rowID += $rowRepeats;
+
break;
}
}
diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php
index 147e7097..ec73496a 100644
--- a/src/PhpSpreadsheet/Reader/Slk.php
+++ b/src/PhpSpreadsheet/Reader/Slk.php
@@ -149,10 +149,12 @@ class Slk extends BaseReader implements IReader
case 'C':
case 'X':
$columnIndex = substr($rowDatum, 1) - 1;
+
break;
case 'R':
case 'Y':
$rowIndex = substr($rowDatum, 1);
+
break;
}
@@ -239,13 +241,16 @@ class Slk extends BaseReader implements IReader
switch ($rowDatum[0]) {
case 'P':
$formatArray['numberFormat']['formatCode'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1));
+
break;
case 'E':
case 'F':
$formatArray['font']['name'] = substr($rowDatum, 1);
+
break;
case 'L':
$formatArray['font']['size'] = substr($rowDatum, 1);
+
break;
case 'S':
$styleSettings = substr($rowDatum, 1);
@@ -253,29 +258,36 @@ class Slk extends BaseReader implements IReader
switch ($styleSettings[$i]) {
case 'I':
$formatArray['font']['italic'] = true;
+
break;
case 'D':
$formatArray['font']['bold'] = true;
+
break;
case 'T':
$formatArray['borders']['top']['borderStyle'] = Border::BORDER_THIN;
+
break;
case 'B':
$formatArray['borders']['bottom']['borderStyle'] = Border::BORDER_THIN;
+
break;
case 'L':
$formatArray['borders']['left']['borderStyle'] = Border::BORDER_THIN;
+
break;
case 'R':
$formatArray['borders']['right']['borderStyle'] = Border::BORDER_THIN;
+
break;
}
}
+
break;
}
}
$this->formats['P' . $this->format++] = $formatArray;
- // Read cell value data
+ // Read cell value data
} elseif ($dataType == 'C') {
$hasCalculatedValue = false;
$cellData = $cellDataFormula = '';
@@ -284,13 +296,16 @@ class Slk extends BaseReader implements IReader
case 'C':
case 'X':
$column = substr($rowDatum, 1);
+
break;
case 'R':
case 'Y':
$row = substr($rowDatum, 1);
+
break;
case 'K':
$cellData = substr($rowDatum, 1);
+
break;
case 'E':
$cellDataFormula = '=' . substr($rowDatum, 1);
@@ -336,6 +351,7 @@ class Slk extends BaseReader implements IReader
// Then rebuild the formula string
$cellDataFormula = implode('"', $temp);
$hasCalculatedValue = true;
+
break;
}
}
@@ -348,7 +364,7 @@ class Slk extends BaseReader implements IReader
$cellData = Calculation::unwrapResult($cellData);
$spreadsheet->getActiveSheet()->getCell($columnLetter . $row)->setCalculatedValue($cellData);
}
- // Read cell formatting
+ // Read cell formatting
} elseif ($dataType == 'F') {
$formatStyle = $columnWidth = $styleSettings = '';
$styleData = [];
@@ -357,16 +373,20 @@ class Slk extends BaseReader implements IReader
case 'C':
case 'X':
$column = substr($rowDatum, 1);
+
break;
case 'R':
case 'Y':
$row = substr($rowDatum, 1);
+
break;
case 'P':
$formatStyle = $rowDatum;
+
break;
case 'W':
- list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1));
+ [$startCol, $endCol, $columnWidth] = explode(' ', substr($rowDatum, 1));
+
break;
case 'S':
$styleSettings = substr($rowDatum, 1);
@@ -374,24 +394,31 @@ class Slk extends BaseReader implements IReader
switch ($styleSettings[$i]) {
case 'I':
$styleData['font']['italic'] = true;
+
break;
case 'D':
$styleData['font']['bold'] = true;
+
break;
case 'T':
$styleData['borders']['top']['borderStyle'] = Border::BORDER_THIN;
+
break;
case 'B':
$styleData['borders']['bottom']['borderStyle'] = Border::BORDER_THIN;
+
break;
case 'L':
$styleData['borders']['left']['borderStyle'] = Border::BORDER_THIN;
+
break;
case 'R':
$styleData['borders']['right']['borderStyle'] = Border::BORDER_THIN;
+
break;
}
}
+
break;
}
}
@@ -424,10 +451,12 @@ class Slk extends BaseReader implements IReader
case 'C':
case 'X':
$column = substr($rowDatum, 1);
+
break;
case 'R':
case 'Y':
$row = substr($rowDatum, 1);
+
break;
}
}
diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php
index 02efa6ea..4b345a9b 100644
--- a/src/PhpSpreadsheet/Reader/Xls.php
+++ b/src/PhpSpreadsheet/Reader/Xls.php
@@ -388,7 +388,7 @@ class Xls extends BaseReader implements IReader
*
* @var Xls\RC4
*/
- private $rc4Key = null;
+ private $rc4Key;
/**
* The position in the stream that the RC4 decryption object was left at.
@@ -402,7 +402,7 @@ class Xls extends BaseReader implements IReader
*
* @var string
*/
- private $md5Ctxt = null;
+ private $md5Ctxt;
/**
* Create a new Xls Reader instance.
@@ -467,15 +467,19 @@ class Xls extends BaseReader implements IReader
switch ($code) {
case self::XLS_TYPE_BOF:
$this->readBof();
+
break;
case self::XLS_TYPE_SHEET:
$this->readSheet();
+
break;
case self::XLS_TYPE_EOF:
$this->readDefault();
+
break 2;
default:
$this->readDefault();
+
break;
}
}
@@ -522,15 +526,19 @@ class Xls extends BaseReader implements IReader
switch ($code) {
case self::XLS_TYPE_BOF:
$this->readBof();
+
break;
case self::XLS_TYPE_SHEET:
$this->readSheet();
+
break;
case self::XLS_TYPE_EOF:
$this->readDefault();
+
break 2;
default:
$this->readDefault();
+
break;
}
}
@@ -574,15 +582,19 @@ class Xls extends BaseReader implements IReader
$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
+
break;
case self::XLS_TYPE_BOF:
$this->readBof();
+
break;
case self::XLS_TYPE_EOF:
$this->readDefault();
+
break 2;
default:
$this->readDefault();
+
break;
}
}
@@ -650,60 +662,79 @@ class Xls extends BaseReader implements IReader
switch ($code) {
case self::XLS_TYPE_BOF:
$this->readBof();
+
break;
case self::XLS_TYPE_FILEPASS:
$this->readFilepass();
+
break;
case self::XLS_TYPE_CODEPAGE:
$this->readCodepage();
+
break;
case self::XLS_TYPE_DATEMODE:
$this->readDateMode();
+
break;
case self::XLS_TYPE_FONT:
$this->readFont();
+
break;
case self::XLS_TYPE_FORMAT:
$this->readFormat();
+
break;
case self::XLS_TYPE_XF:
$this->readXf();
+
break;
case self::XLS_TYPE_XFEXT:
$this->readXfExt();
+
break;
case self::XLS_TYPE_STYLE:
$this->readStyle();
+
break;
case self::XLS_TYPE_PALETTE:
$this->readPalette();
+
break;
case self::XLS_TYPE_SHEET:
$this->readSheet();
+
break;
case self::XLS_TYPE_EXTERNALBOOK:
$this->readExternalBook();
+
break;
case self::XLS_TYPE_EXTERNNAME:
$this->readExternName();
+
break;
case self::XLS_TYPE_EXTERNSHEET:
$this->readExternSheet();
+
break;
case self::XLS_TYPE_DEFINEDNAME:
$this->readDefinedName();
+
break;
case self::XLS_TYPE_MSODRAWINGGROUP:
$this->readMsoDrawingGroup();
+
break;
case self::XLS_TYPE_SST:
$this->readSst();
+
break;
case self::XLS_TYPE_EOF:
$this->readDefault();
+
break 2;
default:
$this->readDefault();
+
break;
}
}
@@ -818,163 +849,216 @@ class Xls extends BaseReader implements IReader
switch ($code) {
case self::XLS_TYPE_BOF:
$this->readBof();
+
break;
case self::XLS_TYPE_PRINTGRIDLINES:
$this->readPrintGridlines();
+
break;
case self::XLS_TYPE_DEFAULTROWHEIGHT:
$this->readDefaultRowHeight();
+
break;
case self::XLS_TYPE_SHEETPR:
$this->readSheetPr();
+
break;
case self::XLS_TYPE_HORIZONTALPAGEBREAKS:
$this->readHorizontalPageBreaks();
+
break;
case self::XLS_TYPE_VERTICALPAGEBREAKS:
$this->readVerticalPageBreaks();
+
break;
case self::XLS_TYPE_HEADER:
$this->readHeader();
+
break;
case self::XLS_TYPE_FOOTER:
$this->readFooter();
+
break;
case self::XLS_TYPE_HCENTER:
$this->readHcenter();
+
break;
case self::XLS_TYPE_VCENTER:
$this->readVcenter();
+
break;
case self::XLS_TYPE_LEFTMARGIN:
$this->readLeftMargin();
+
break;
case self::XLS_TYPE_RIGHTMARGIN:
$this->readRightMargin();
+
break;
case self::XLS_TYPE_TOPMARGIN:
$this->readTopMargin();
+
break;
case self::XLS_TYPE_BOTTOMMARGIN:
$this->readBottomMargin();
+
break;
case self::XLS_TYPE_PAGESETUP:
$this->readPageSetup();
+
break;
case self::XLS_TYPE_PROTECT:
$this->readProtect();
+
break;
case self::XLS_TYPE_SCENPROTECT:
$this->readScenProtect();
+
break;
case self::XLS_TYPE_OBJECTPROTECT:
$this->readObjectProtect();
+
break;
case self::XLS_TYPE_PASSWORD:
$this->readPassword();
+
break;
case self::XLS_TYPE_DEFCOLWIDTH:
$this->readDefColWidth();
+
break;
case self::XLS_TYPE_COLINFO:
$this->readColInfo();
+
break;
case self::XLS_TYPE_DIMENSION:
$this->readDefault();
+
break;
case self::XLS_TYPE_ROW:
$this->readRow();
+
break;
case self::XLS_TYPE_DBCELL:
$this->readDefault();
+
break;
case self::XLS_TYPE_RK:
$this->readRk();
+
break;
case self::XLS_TYPE_LABELSST:
$this->readLabelSst();
+
break;
case self::XLS_TYPE_MULRK:
$this->readMulRk();
+
break;
case self::XLS_TYPE_NUMBER:
$this->readNumber();
+
break;
case self::XLS_TYPE_FORMULA:
$this->readFormula();
+
break;
case self::XLS_TYPE_SHAREDFMLA:
$this->readSharedFmla();
+
break;
case self::XLS_TYPE_BOOLERR:
$this->readBoolErr();
+
break;
case self::XLS_TYPE_MULBLANK:
$this->readMulBlank();
+
break;
case self::XLS_TYPE_LABEL:
$this->readLabel();
+
break;
case self::XLS_TYPE_BLANK:
$this->readBlank();
+
break;
case self::XLS_TYPE_MSODRAWING:
$this->readMsoDrawing();
+
break;
case self::XLS_TYPE_OBJ:
$this->readObj();
+
break;
case self::XLS_TYPE_WINDOW2:
$this->readWindow2();
+
break;
case self::XLS_TYPE_PAGELAYOUTVIEW:
$this->readPageLayoutView();
+
break;
case self::XLS_TYPE_SCL:
$this->readScl();
+
break;
case self::XLS_TYPE_PANE:
$this->readPane();
+
break;
case self::XLS_TYPE_SELECTION:
$this->readSelection();
+
break;
case self::XLS_TYPE_MERGEDCELLS:
$this->readMergedCells();
+
break;
case self::XLS_TYPE_HYPERLINK:
$this->readHyperLink();
+
break;
case self::XLS_TYPE_DATAVALIDATIONS:
$this->readDataValidations();
+
break;
case self::XLS_TYPE_DATAVALIDATION:
$this->readDataValidation();
+
break;
case self::XLS_TYPE_SHEETLAYOUT:
$this->readSheetLayout();
+
break;
case self::XLS_TYPE_SHEETPROTECTION:
$this->readSheetProtection();
+
break;
case self::XLS_TYPE_RANGEPROTECTION:
$this->readRangeProtection();
+
break;
case self::XLS_TYPE_NOTE:
$this->readNote();
+
break;
//case self::XLS_TYPE_IMDATA: $this->readImData(); break;
case self::XLS_TYPE_TXO:
$this->readTextObject();
+
break;
case self::XLS_TYPE_CONTINUE:
$this->readContinue();
+
break;
case self::XLS_TYPE_EOF:
$this->readDefault();
+
break 2;
default:
$this->readDefault();
+
break;
}
}
@@ -1001,8 +1085,8 @@ class Xls extends BaseReader implements IReader
}
// calculate the width and height of the shape
- list($startColumn, $startRow) = Cell::coordinateFromString($spContainer->getStartCoordinates());
- list($endColumn, $endRow) = Cell::coordinateFromString($spContainer->getEndCoordinates());
+ [$startColumn, $startRow] = Cell::coordinateFromString($spContainer->getStartCoordinates());
+ [$endColumn, $endRow] = Cell::coordinateFromString($spContainer->getEndCoordinates());
$startOffsetX = $spContainer->getStartOffsetX();
$startOffsetY = $spContainer->getStartOffsetY();
@@ -1027,6 +1111,7 @@ class Xls extends BaseReader implements IReader
$this->cellNotes[$obj['idObjID']]['objTextData'] = $textObject;
}
}
+
break;
case 0x08:
// picture
@@ -1062,16 +1147,19 @@ class Xls extends BaseReader implements IReader
case BSE::BLIPTYPE_JPEG:
$drawing->setRenderingFunction(MemoryDrawing::RENDERING_JPEG);
$drawing->setMimeType(MemoryDrawing::MIMETYPE_JPEG);
+
break;
case BSE::BLIPTYPE_PNG:
$drawing->setRenderingFunction(MemoryDrawing::RENDERING_PNG);
$drawing->setMimeType(MemoryDrawing::MIMETYPE_PNG);
+
break;
}
$drawing->setWorksheet($this->phpSheet);
$drawing->setCoordinates($spContainer->getStartCoordinates());
}
+
break;
default:
// other object type
@@ -1083,7 +1171,7 @@ class Xls extends BaseReader implements IReader
// treat SHAREDFMLA records
if ($this->version == self::XLS_BIFF8) {
foreach ($this->sharedFormulaParts as $cell => $baseCell) {
- list($column, $row) = Cell::coordinateFromString($cell);
+ [$column, $row] = Cell::coordinateFromString($cell);
if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($column, $row, $this->phpSheet->getTitle())) {
$formula = $this->getFormulaFromStructure($this->sharedFormulas[$baseCell], $cell);
$this->phpSheet->getCell($cell)->setValueExplicit('=' . $formula, Cell\DataType::TYPE_FORMULA);
@@ -1133,6 +1221,7 @@ class Xls extends BaseReader implements IReader
if ($docSheet = $this->spreadsheet->getSheetByName($sheetName)) {
$docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges)); // C7:J66,A1:IV2
}
+
break;
case pack('C', 0x07):
// print titles (repeating rows)
@@ -1158,8 +1247,8 @@ class Xls extends BaseReader implements IReader
$coordinateStrings = explode(':', $extractedRange);
if (count($coordinateStrings) == 2) {
- list($firstColumn, $firstRow) = Cell::coordinateFromString($coordinateStrings[0]);
- list($lastColumn, $lastRow) = Cell::coordinateFromString($coordinateStrings[1]);
+ [$firstColumn, $firstRow] = Cell::coordinateFromString($coordinateStrings[0]);
+ [$lastColumn, $lastRow] = Cell::coordinateFromString($coordinateStrings[1]);
if ($firstColumn == 'A' and $lastColumn == 'IV') {
// then we have repeating rows
@@ -1172,6 +1261,7 @@ class Xls extends BaseReader implements IReader
}
}
}
+
break;
}
} else {
@@ -1191,7 +1281,7 @@ class Xls extends BaseReader implements IReader
$this->spreadsheet->addNamedRange(new NamedRange((string) $definedName['name'], $docSheet, $extractedRange, $localOnly, $scope));
}
}
- // Named Value
+ // Named Value
// TODO Provide support for named values
}
}
@@ -1325,9 +1415,11 @@ class Xls extends BaseReader implements IReader
switch ($type) {
case 0x02: // 2 byte signed integer
$value = self::getUInt2d($this->summaryInformation, $secOffset + 4 + $offset);
+
break;
case 0x03: // 4 byte signed integer
$value = self::getInt4d($this->summaryInformation, $secOffset + 4 + $offset);
+
break;
case 0x13: // 4 byte unsigned integer
// not needed yet, fix later if necessary
@@ -1337,10 +1429,12 @@ class Xls extends BaseReader implements IReader
$value = substr($this->summaryInformation, $secOffset + 8 + $offset, $byteLength);
$value = StringHelper::convertEncoding($value, 'UTF-8', $codePage);
$value = rtrim($value);
+
break;
case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
// PHP-time
$value = OLE::OLE2LocalDate(substr($this->summaryInformation, $secOffset + 4 + $offset, 8));
+
break;
case 0x47: // Clipboard format
// not needed yet, fix later if necessary
@@ -1350,27 +1444,34 @@ class Xls extends BaseReader implements IReader
switch ($id) {
case 0x01: // Code Page
$codePage = CodePage::numberToName($value);
+
break;
case 0x02: // Title
$this->spreadsheet->getProperties()->setTitle($value);
+
break;
case 0x03: // Subject
$this->spreadsheet->getProperties()->setSubject($value);
+
break;
case 0x04: // Author (Creator)
$this->spreadsheet->getProperties()->setCreator($value);
+
break;
case 0x05: // Keywords
$this->spreadsheet->getProperties()->setKeywords($value);
+
break;
case 0x06: // Comments (Description)
$this->spreadsheet->getProperties()->setDescription($value);
+
break;
case 0x07: // Template
// Not supported by PhpSpreadsheet
break;
case 0x08: // Last Saved By (LastModifiedBy)
$this->spreadsheet->getProperties()->setLastModifiedBy($value);
+
break;
case 0x09: // Revision
// Not supported by PhpSpreadsheet
@@ -1383,9 +1484,11 @@ class Xls extends BaseReader implements IReader
break;
case 0x0C: // Created Date/Time
$this->spreadsheet->getProperties()->setCreated($value);
+
break;
case 0x0D: // Modified Date/Time
$this->spreadsheet->getProperties()->setModified($value);
+
break;
case 0x0E: // Number of Pages
// Not supported by PhpSpreadsheet
@@ -1459,13 +1562,16 @@ class Xls extends BaseReader implements IReader
switch ($type) {
case 0x02: // 2 byte signed integer
$value = self::getUInt2d($this->documentSummaryInformation, $secOffset + 4 + $offset);
+
break;
case 0x03: // 4 byte signed integer
$value = self::getInt4d($this->documentSummaryInformation, $secOffset + 4 + $offset);
+
break;
case 0x0B: // Boolean
$value = self::getUInt2d($this->documentSummaryInformation, $secOffset + 4 + $offset);
$value = ($value == 0 ? false : true);
+
break;
case 0x13: // 4 byte unsigned integer
// not needed yet, fix later if necessary
@@ -1475,10 +1581,12 @@ class Xls extends BaseReader implements IReader
$value = substr($this->documentSummaryInformation, $secOffset + 8 + $offset, $byteLength);
$value = StringHelper::convertEncoding($value, 'UTF-8', $codePage);
$value = rtrim($value);
+
break;
case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
// PHP-Time
$value = OLE::OLE2LocalDate(substr($this->documentSummaryInformation, $secOffset + 4 + $offset, 8));
+
break;
case 0x47: // Clipboard format
// not needed yet, fix later if necessary
@@ -1488,9 +1596,11 @@ class Xls extends BaseReader implements IReader
switch ($id) {
case 0x01: // Code Page
$codePage = CodePage::numberToName($value);
+
break;
case 0x02: // Category
$this->spreadsheet->getProperties()->setCategory($value);
+
break;
case 0x03: // Presentation Target
// Not supported by PhpSpreadsheet
@@ -1527,9 +1637,11 @@ class Xls extends BaseReader implements IReader
break;
case 0x0E: // Manager
$this->spreadsheet->getProperties()->setManager($value);
+
break;
case 0x0F: // Company
$this->spreadsheet->getProperties()->setCompany($value);
+
break;
case 0x10: // Links up-to-date
// Not supported by PhpSpreadsheet
@@ -1671,6 +1783,7 @@ class Xls extends BaseReader implements IReader
throw new Exception('Cannot read this Excel file. Version is too old.');
}
$this->version = $version;
+
break;
case self::XLS_WORKSHEET:
// do not use this version information for anything
@@ -1683,6 +1796,7 @@ class Xls extends BaseReader implements IReader
$code = self::getUInt2d($this->data, $this->pos);
$this->readDefault();
} while ($code != self::XLS_TYPE_EOF && $this->pos < $this->dataSize);
+
break;
}
}
@@ -1806,6 +1920,7 @@ class Xls extends BaseReader implements IReader
$keyoffset = $tocopy;
$tocopy = 5 - $tocopy;
$offset = 0;
+
continue;
}
@@ -1934,6 +2049,7 @@ class Xls extends BaseReader implements IReader
switch ($weight) {
case 0x02BC:
$objFont->setBold(true);
+
break;
}
@@ -1942,9 +2058,11 @@ class Xls extends BaseReader implements IReader
switch ($escapement) {
case 0x0001:
$objFont->setSuperscript(true);
+
break;
case 0x0002:
$objFont->setSubscript(true);
+
break;
}
@@ -1955,15 +2073,19 @@ class Xls extends BaseReader implements IReader
break; // no underline
case 0x01:
$objFont->setUnderline(Font::UNDERLINE_SINGLE);
+
break;
case 0x02:
$objFont->setUnderline(Font::UNDERLINE_DOUBLE);
+
break;
case 0x21:
$objFont->setUnderline(Font::UNDERLINE_SINGLEACCOUNTING);
+
break;
case 0x22:
$objFont->setUnderline(Font::UNDERLINE_DOUBLEACCOUNTING);
+
break;
}
@@ -2088,24 +2210,31 @@ class Xls extends BaseReader implements IReader
switch ($horAlign) {
case 0:
$objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_GENERAL);
+
break;
case 1:
$objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
+
break;
case 2:
$objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
+
break;
case 3:
$objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT);
+
break;
case 4:
$objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_FILL);
+
break;
case 5:
$objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_JUSTIFY);
+
break;
case 6:
$objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER_CONTINUOUS);
+
break;
}
// bit 3, mask 0x08; wrap text
@@ -2113,9 +2242,11 @@ class Xls extends BaseReader implements IReader
switch ($wrapText) {
case 0:
$objStyle->getAlignment()->setWrapText(false);
+
break;
case 1:
$objStyle->getAlignment()->setWrapText(true);
+
break;
}
// bit 6-4, mask 0x70; vertical alignment
@@ -2123,15 +2254,19 @@ class Xls extends BaseReader implements IReader
switch ($vertAlign) {
case 0:
$objStyle->getAlignment()->setVertical(Alignment::VERTICAL_TOP);
+
break;
case 1:
$objStyle->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
+
break;
case 2:
$objStyle->getAlignment()->setVertical(Alignment::VERTICAL_BOTTOM);
+
break;
case 3:
$objStyle->getAlignment()->setVertical(Alignment::VERTICAL_JUSTIFY);
+
break;
}
@@ -2158,9 +2293,11 @@ class Xls extends BaseReader implements IReader
switch ($shrinkToFit) {
case 0:
$objStyle->getAlignment()->setShrinkToFit(false);
+
break;
case 1:
$objStyle->getAlignment()->setShrinkToFit(true);
+
break;
}
@@ -2241,15 +2378,19 @@ class Xls extends BaseReader implements IReader
switch ($xfOrientation) {
case 0:
$objStyle->getAlignment()->setTextRotation(0);
+
break;
case 1:
$objStyle->getAlignment()->setTextRotation(-165);
+
break;
case 2:
$objStyle->getAlignment()->setTextRotation(90);
+
break;
case 3:
$objStyle->getAlignment()->setTextRotation(-90);
+
break;
}
@@ -2363,6 +2504,7 @@ class Xls extends BaseReader implements IReader
unset($fill->startcolorIndex); // normal color index does not apply, discard
}
}
+
break;
case 5: // fill end color
$xclfType = self::getUInt2d($extData, 0); // color type
@@ -2378,6 +2520,7 @@ class Xls extends BaseReader implements IReader
unset($fill->endcolorIndex); // normal color index does not apply, discard
}
}
+
break;
case 7: // border color top
$xclfType = self::getUInt2d($extData, 0); // color type
@@ -2393,6 +2536,7 @@ class Xls extends BaseReader implements IReader
unset($top->colorIndex); // normal color index does not apply, discard
}
}
+
break;
case 8: // border color bottom
$xclfType = self::getUInt2d($extData, 0); // color type
@@ -2408,6 +2552,7 @@ class Xls extends BaseReader implements IReader
unset($bottom->colorIndex); // normal color index does not apply, discard
}
}
+
break;
case 9: // border color left
$xclfType = self::getUInt2d($extData, 0); // color type
@@ -2423,6 +2568,7 @@ class Xls extends BaseReader implements IReader
unset($left->colorIndex); // normal color index does not apply, discard
}
}
+
break;
case 10: // border color right
$xclfType = self::getUInt2d($extData, 0); // color type
@@ -2438,6 +2584,7 @@ class Xls extends BaseReader implements IReader
unset($right->colorIndex); // normal color index does not apply, discard
}
}
+
break;
case 11: // border color diagonal
$xclfType = self::getUInt2d($extData, 0); // color type
@@ -2453,6 +2600,7 @@ class Xls extends BaseReader implements IReader
unset($diagonal->colorIndex); // normal color index does not apply, discard
}
}
+
break;
case 13: // font color
$xclfType = self::getUInt2d($extData, 0); // color type
@@ -2468,6 +2616,7 @@ class Xls extends BaseReader implements IReader
unset($font->colorIndex); // normal color index does not apply, discard
}
}
+
break;
}
@@ -2509,7 +2658,7 @@ class Xls extends BaseReader implements IReader
break;
}
}
- // user-defined; not supported by PhpSpreadsheet
+ // user-defined; not supported by PhpSpreadsheet
}
}
@@ -2564,15 +2713,19 @@ class Xls extends BaseReader implements IReader
switch (ord($recordData[4])) {
case 0x00:
$sheetState = Worksheet::SHEETSTATE_VISIBLE;
+
break;
case 0x01:
$sheetState = Worksheet::SHEETSTATE_HIDDEN;
+
break;
case 0x02:
$sheetState = Worksheet::SHEETSTATE_VERYHIDDEN;
+
break;
default:
$sheetState = Worksheet::SHEETSTATE_VISIBLE;
+
break;
}
@@ -2865,6 +3018,7 @@ class Xls extends BaseReader implements IReader
// <= and not just <
if ($pos <= $spliceOffset) {
$limitpos = $spliceOffset;
+
break;
}
}
@@ -2893,6 +3047,7 @@ class Xls extends BaseReader implements IReader
foreach ($spliceOffsets as $spliceOffset) {
if ($pos < $spliceOffset) {
$limitpos = $spliceOffset;
+
break;
}
}
@@ -3294,9 +3449,11 @@ class Xls extends BaseReader implements IReader
switch ($isPortrait) {
case 0:
$this->phpSheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
+
break;
case 1:
$this->phpSheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_PORTRAIT);
+
break;
}
@@ -3460,6 +3617,7 @@ class Xls extends BaseReader implements IReader
for ($i = $fc; $i <= $lc; ++$i) {
if ($lc == 255 || $lc == 256) {
$this->phpSheet->getDefaultColumnDimension()->setWidth($width / 256);
+
break;
}
$this->phpSheet->getColumnDimensionByColumn($i)->setWidth($width / 256);
@@ -3989,12 +4147,14 @@ class Xls extends BaseReader implements IReader
// add cell value
$cell->setValueExplicit($value, Cell\DataType::TYPE_BOOL);
+
break;
case 1: // error type
$value = Xls\ErrorCode::lookup($boolErr);
// add cell value
$cell->setValueExplicit($value, Cell\DataType::TYPE_ERROR);
+
break;
}
@@ -4330,7 +4490,7 @@ class Xls extends BaseReader implements IReader
// frozen panes
$this->phpSheet->freezePane(Cell::stringFromColumnIndex($px) . ($py + 1));
}
- // unfrozen panes; split windows; not supported by PhpSpreadsheet core
+ // unfrozen panes; split windows; not supported by PhpSpreadsheet core
}
}
@@ -4395,6 +4555,7 @@ class Xls extends BaseReader implements IReader
for ($column = $rangeBoundaries[0][0]; $column != $rangeBoundaries[1][0]; ++$column) {
if ($this->getReadFilter()->readCell($column, $row, $this->phpSheet->getTitle())) {
$includeCellRange = true;
+
break 2;
}
}
@@ -4520,6 +4681,7 @@ class Xls extends BaseReader implements IReader
}
$url .= $hasText ? '#' : '';
$offset += $us;
+
break;
case 'local':
// section 5.58.3: Hyperlink to local file
@@ -4582,6 +4744,7 @@ class Xls extends BaseReader implements IReader
// section 5.58.5: Hyperlink to the Current Workbook
// e.g. Sheet2!B1:C2, stored in text mark field
$url = 'sheet://';
+
break;
default:
return;
@@ -4638,27 +4801,35 @@ class Xls extends BaseReader implements IReader
switch ($type) {
case 0x00:
$type = DataValidation::TYPE_NONE;
+
break;
case 0x01:
$type = DataValidation::TYPE_WHOLE;
+
break;
case 0x02:
$type = DataValidation::TYPE_DECIMAL;
+
break;
case 0x03:
$type = DataValidation::TYPE_LIST;
+
break;
case 0x04:
$type = DataValidation::TYPE_DATE;
+
break;
case 0x05:
$type = DataValidation::TYPE_TIME;
+
break;
case 0x06:
$type = DataValidation::TYPE_TEXTLENGTH;
+
break;
case 0x07:
$type = DataValidation::TYPE_CUSTOM;
+
break;
}
@@ -4667,12 +4838,15 @@ class Xls extends BaseReader implements IReader
switch ($errorStyle) {
case 0x00:
$errorStyle = DataValidation::STYLE_STOP;
+
break;
case 0x01:
$errorStyle = DataValidation::STYLE_WARNING;
+
break;
case 0x02:
$errorStyle = DataValidation::STYLE_INFORMATION;
+
break;
}
@@ -4697,27 +4871,35 @@ class Xls extends BaseReader implements IReader
switch ($operator) {
case 0x00:
$operator = DataValidation::OPERATOR_BETWEEN;
+
break;
case 0x01:
$operator = DataValidation::OPERATOR_NOTBETWEEN;
+
break;
case 0x02:
$operator = DataValidation::OPERATOR_EQUAL;
+
break;
case 0x03:
$operator = DataValidation::OPERATOR_NOTEQUAL;
+
break;
case 0x04:
$operator = DataValidation::OPERATOR_GREATERTHAN;
+
break;
case 0x05:
$operator = DataValidation::OPERATOR_LESSTHAN;
+
break;
case 0x06:
$operator = DataValidation::OPERATOR_GREATERTHANOREQUAL;
+
break;
case 0x07:
$operator = DataValidation::OPERATOR_LESSTHANOREQUAL;
+
break;
}
@@ -4835,6 +5017,7 @@ class Xls extends BaseReader implements IReader
$colorIndex = self::getUInt2d($recordData, 16);
$color = Xls\Color::map($colorIndex, $this->palette, $this->version);
$this->phpSheet->getTabColor()->setRGB($color['rgb']);
+
break;
case 0x28:
// TODO: Investigate structure for .xls SHEETLAYOUT record as saved by MS Office Excel 2007
@@ -5067,6 +5250,7 @@ class Xls extends BaseReader implements IReader
$drawing = new Drawing();
$drawing->setPath($filename);
$drawing->setWorksheet($this->phpSheet);
+
break;
case 0x02: // Windows metafile or Macintosh PICT format
case 0x0e: // native format
@@ -5259,17 +5443,20 @@ class Xls extends BaseReader implements IReader
$op1 = array_pop($formulaStrings);
$formulaStrings[] = "$op1$space1$space0{$token['data']}$op2";
unset($space0, $space1);
+
break;
case 'tUplus': // unary plus
case 'tUminus': // unary minus
$op = array_pop($formulaStrings);
$formulaStrings[] = "$space1$space0{$token['data']}$op";
unset($space0, $space1);
+
break;
case 'tPercent': // percent sign
$op = array_pop($formulaStrings);
$formulaStrings[] = "$op$space1$space0{$token['data']}";
unset($space0, $space1);
+
break;
case 'tAttrVolatile': // indicates volatile function
case 'tAttrIf':
@@ -5283,28 +5470,36 @@ class Xls extends BaseReader implements IReader
switch ($token['data']['spacetype']) {
case 'type0':
$space0 = str_repeat(' ', $token['data']['spacecount']);
+
break;
case 'type1':
$space1 = str_repeat("\n", $token['data']['spacecount']);
+
break;
case 'type2':
$space2 = str_repeat(' ', $token['data']['spacecount']);
+
break;
case 'type3':
$space3 = str_repeat("\n", $token['data']['spacecount']);
+
break;
case 'type4':
$space4 = str_repeat(' ', $token['data']['spacecount']);
+
break;
case 'type5':
$space5 = str_repeat("\n", $token['data']['spacecount']);
+
break;
}
+
break;
case 'tAttrSum': // SUM function with one parameter
$op = array_pop($formulaStrings);
$formulaStrings[] = "{$space1}{$space0}SUM($op)";
unset($space0, $space1);
+
break;
case 'tFunc': // function with fixed number of arguments
case 'tFuncV': // function with variable number of arguments
@@ -5328,17 +5523,20 @@ class Xls extends BaseReader implements IReader
$formulaStrings[] = "$space1$space0$function(" . implode(',', $ops) . ')';
unset($space0, $space1);
}
+
break;
case 'tParen': // parenthesis
$expression = array_pop($formulaStrings);
$formulaStrings[] = "$space3$space2($expression$space5$space4)";
unset($space2, $space3, $space4, $space5);
+
break;
case 'tArray': // array constant
$constantArray = self::readBIFF8ConstantArray($additionalData);
$formulaStrings[] = $space1 . $space0 . $constantArray['value'];
$additionalData = substr($additionalData, $constantArray['size']); // bite of chunk of additional data
unset($space0, $space1);
+
break;
case 'tMemArea':
// bite off chunk of additional data
@@ -5346,6 +5544,7 @@ class Xls extends BaseReader implements IReader
$additionalData = substr($additionalData, $cellRangeAddressList['size']);
$formulaStrings[] = "$space1$space0{$token['data']}";
unset($space0, $space1);
+
break;
case 'tArea': // cell range address
case 'tBool': // boolean
@@ -5365,6 +5564,7 @@ class Xls extends BaseReader implements IReader
case 'tStr': // string
$formulaStrings[] = "$space1$space0{$token['data']}";
unset($space0, $space1);
+
break;
}
}
@@ -5394,101 +5594,121 @@ class Xls extends BaseReader implements IReader
$name = 'tAdd';
$size = 1;
$data = '+';
+
break;
case 0x04:
$name = 'tSub';
$size = 1;
$data = '-';
+
break;
case 0x05:
$name = 'tMul';
$size = 1;
$data = '*';
+
break;
case 0x06:
$name = 'tDiv';
$size = 1;
$data = '/';
+
break;
case 0x07:
$name = 'tPower';
$size = 1;
$data = '^';
+
break;
case 0x08:
$name = 'tConcat';
$size = 1;
$data = '&';
+
break;
case 0x09:
$name = 'tLT';
$size = 1;
$data = '<';
+
break;
case 0x0A:
$name = 'tLE';
$size = 1;
$data = '<=';
+
break;
case 0x0B:
$name = 'tEQ';
$size = 1;
$data = '=';
+
break;
case 0x0C:
$name = 'tGE';
$size = 1;
$data = '>=';
+
break;
case 0x0D:
$name = 'tGT';
$size = 1;
$data = '>';
+
break;
case 0x0E:
$name = 'tNE';
$size = 1;
$data = '<>';
+
break;
case 0x0F:
$name = 'tIsect';
$size = 1;
$data = ' ';
+
break;
case 0x10:
$name = 'tList';
$size = 1;
$data = ',';
+
break;
case 0x11:
$name = 'tRange';
$size = 1;
$data = ':';
+
break;
case 0x12:
$name = 'tUplus';
$size = 1;
$data = '+';
+
break;
case 0x13:
$name = 'tUminus';
$size = 1;
$data = '-';
+
break;
case 0x14:
$name = 'tPercent';
$size = 1;
$data = '%';
+
break;
case 0x15: // parenthesis
$name = 'tParen';
$size = 1;
$data = null;
+
break;
case 0x16: // missing argument
$name = 'tMissArg';
$size = 1;
$data = '';
+
break;
case 0x17: // string
$name = 'tStr';
@@ -5496,6 +5716,7 @@ class Xls extends BaseReader implements IReader
$string = self::readUnicodeStringShort(substr($formulaData, 1));
$size = 1 + $string['size'];
$data = self::UTF8toExcelDoubleQuoted($string['value']);
+
break;
case 0x19: // Special attribute
// offset: 1; size: 1; attribute type flags:
@@ -5504,11 +5725,13 @@ class Xls extends BaseReader implements IReader
$name = 'tAttrVolatile';
$size = 4;
$data = null;
+
break;
case 0x02:
$name = 'tAttrIf';
$size = 4;
$data = null;
+
break;
case 0x04:
$name = 'tAttrChoose';
@@ -5518,16 +5741,19 @@ class Xls extends BaseReader implements IReader
// offset: 4 + 2 * $nc; size: 2
$size = 2 * $nc + 6;
$data = null;
+
break;
case 0x08:
$name = 'tAttrSkip';
$size = 4;
$data = null;
+
break;
case 0x10:
$name = 'tAttrSum';
$size = 4;
$data = null;
+
break;
case 0x40:
case 0x41:
@@ -5537,21 +5763,27 @@ class Xls extends BaseReader implements IReader
switch (ord($formulaData[2])) {
case 0x00:
$spacetype = 'type0';
+
break;
case 0x01:
$spacetype = 'type1';
+
break;
case 0x02:
$spacetype = 'type2';
+
break;
case 0x03:
$spacetype = 'type3';
+
break;
case 0x04:
$spacetype = 'type4';
+
break;
case 0x05:
$spacetype = 'type5';
+
break;
default:
throw new Exception('Unrecognized space type in tAttrSpace token');
@@ -5561,29 +5793,34 @@ class Xls extends BaseReader implements IReader
$spacecount = ord($formulaData[3]);
$data = ['spacetype' => $spacetype, 'spacecount' => $spacecount];
+
break;
default:
throw new Exception('Unrecognized attribute flag in tAttr token');
break;
}
+
break;
case 0x1C: // error code
// offset: 1; size: 1; error code
$name = 'tErr';
$size = 2;
$data = Xls\ErrorCode::lookup(ord($formulaData[1]));
+
break;
case 0x1D: // boolean
// offset: 1; size: 1; 0 = false, 1 = true;
$name = 'tBool';
$size = 2;
$data = ord($formulaData[1]) ? 'TRUE' : 'FALSE';
+
break;
case 0x1E: // integer
// offset: 1; size: 2; unsigned 16-bit integer
$name = 'tInt';
$size = 3;
$data = self::getUInt2d($formulaData, 1);
+
break;
case 0x1F: // number
// offset: 1; size: 8;
@@ -5599,6 +5836,7 @@ class Xls extends BaseReader implements IReader
$name = 'tArray';
$size = 8;
$data = null;
+
break;
case 0x21: // function with fixed number of arguments
case 0x41:
@@ -5610,648 +5848,809 @@ class Xls extends BaseReader implements IReader
case 2:
$function = 'ISNA';
$args = 1;
+
break;
case 3:
$function = 'ISERROR';
$args = 1;
+
break;
case 10:
$function = 'NA';
$args = 0;
+
break;
case 15:
$function = 'SIN';
$args = 1;
+
break;
case 16:
$function = 'COS';
$args = 1;
+
break;
case 17:
$function = 'TAN';
$args = 1;
+
break;
case 18:
$function = 'ATAN';
$args = 1;
+
break;
case 19:
$function = 'PI';
$args = 0;
+
break;
case 20:
$function = 'SQRT';
$args = 1;
+
break;
case 21:
$function = 'EXP';
$args = 1;
+
break;
case 22:
$function = 'LN';
$args = 1;
+
break;
case 23:
$function = 'LOG10';
$args = 1;
+
break;
case 24:
$function = 'ABS';
$args = 1;
+
break;
case 25:
$function = 'INT';
$args = 1;
+
break;
case 26:
$function = 'SIGN';
$args = 1;
+
break;
case 27:
$function = 'ROUND';
$args = 2;
+
break;
case 30:
$function = 'REPT';
$args = 2;
+
break;
case 31:
$function = 'MID';
$args = 3;
+
break;
case 32:
$function = 'LEN';
$args = 1;
+
break;
case 33:
$function = 'VALUE';
$args = 1;
+
break;
case 34:
$function = 'TRUE';
$args = 0;
+
break;
case 35:
$function = 'FALSE';
$args = 0;
+
break;
case 38:
$function = 'NOT';
$args = 1;
+
break;
case 39:
$function = 'MOD';
$args = 2;
+
break;
case 40:
$function = 'DCOUNT';
$args = 3;
+
break;
case 41:
$function = 'DSUM';
$args = 3;
+
break;
case 42:
$function = 'DAVERAGE';
$args = 3;
+
break;
case 43:
$function = 'DMIN';
$args = 3;
+
break;
case 44:
$function = 'DMAX';
$args = 3;
+
break;
case 45:
$function = 'DSTDEV';
$args = 3;
+
break;
case 48:
$function = 'TEXT';
$args = 2;
+
break;
case 61:
$function = 'MIRR';
$args = 3;
+
break;
case 63:
$function = 'RAND';
$args = 0;
+
break;
case 65:
$function = 'DATE';
$args = 3;
+
break;
case 66:
$function = 'TIME';
$args = 3;
+
break;
case 67:
$function = 'DAY';
$args = 1;
+
break;
case 68:
$function = 'MONTH';
$args = 1;
+
break;
case 69:
$function = 'YEAR';
$args = 1;
+
break;
case 71:
$function = 'HOUR';
$args = 1;
+
break;
case 72:
$function = 'MINUTE';
$args = 1;
+
break;
case 73:
$function = 'SECOND';
$args = 1;
+
break;
case 74:
$function = 'NOW';
$args = 0;
+
break;
case 75:
$function = 'AREAS';
$args = 1;
+
break;
case 76:
$function = 'ROWS';
$args = 1;
+
break;
case 77:
$function = 'COLUMNS';
$args = 1;
+
break;
case 83:
$function = 'TRANSPOSE';
$args = 1;
+
break;
case 86:
$function = 'TYPE';
$args = 1;
+
break;
case 97:
$function = 'ATAN2';
$args = 2;
+
break;
case 98:
$function = 'ASIN';
$args = 1;
+
break;
case 99:
$function = 'ACOS';
$args = 1;
+
break;
case 105:
$function = 'ISREF';
$args = 1;
+
break;
case 111:
$function = 'CHAR';
$args = 1;
+
break;
case 112:
$function = 'LOWER';
$args = 1;
+
break;
case 113:
$function = 'UPPER';
$args = 1;
+
break;
case 114:
$function = 'PROPER';
$args = 1;
+
break;
case 117:
$function = 'EXACT';
$args = 2;
+
break;
case 118:
$function = 'TRIM';
$args = 1;
+
break;
case 119:
$function = 'REPLACE';
$args = 4;
+
break;
case 121:
$function = 'CODE';
$args = 1;
+
break;
case 126:
$function = 'ISERR';
$args = 1;
+
break;
case 127:
$function = 'ISTEXT';
$args = 1;
+
break;
case 128:
$function = 'ISNUMBER';
$args = 1;
+
break;
case 129:
$function = 'ISBLANK';
$args = 1;
+
break;
case 130:
$function = 'T';
$args = 1;
+
break;
case 131:
$function = 'N';
$args = 1;
+
break;
case 140:
$function = 'DATEVALUE';
$args = 1;
+
break;
case 141:
$function = 'TIMEVALUE';
$args = 1;
+
break;
case 142:
$function = 'SLN';
$args = 3;
+
break;
case 143:
$function = 'SYD';
$args = 4;
+
break;
case 162:
$function = 'CLEAN';
$args = 1;
+
break;
case 163:
$function = 'MDETERM';
$args = 1;
+
break;
case 164:
$function = 'MINVERSE';
$args = 1;
+
break;
case 165:
$function = 'MMULT';
$args = 2;
+
break;
case 184:
$function = 'FACT';
$args = 1;
+
break;
case 189:
$function = 'DPRODUCT';
$args = 3;
+
break;
case 190:
$function = 'ISNONTEXT';
$args = 1;
+
break;
case 195:
$function = 'DSTDEVP';
$args = 3;
+
break;
case 196:
$function = 'DVARP';
$args = 3;
+
break;
case 198:
$function = 'ISLOGICAL';
$args = 1;
+
break;
case 199:
$function = 'DCOUNTA';
$args = 3;
+
break;
case 207:
$function = 'REPLACEB';
$args = 4;
+
break;
case 210:
$function = 'MIDB';
$args = 3;
+
break;
case 211:
$function = 'LENB';
$args = 1;
+
break;
case 212:
$function = 'ROUNDUP';
$args = 2;
+
break;
case 213:
$function = 'ROUNDDOWN';
$args = 2;
+
break;
case 214:
$function = 'ASC';
$args = 1;
+
break;
case 215:
$function = 'DBCS';
$args = 1;
+
break;
case 221:
$function = 'TODAY';
$args = 0;
+
break;
case 229:
$function = 'SINH';
$args = 1;
+
break;
case 230:
$function = 'COSH';
$args = 1;
+
break;
case 231:
$function = 'TANH';
$args = 1;
+
break;
case 232:
$function = 'ASINH';
$args = 1;
+
break;
case 233:
$function = 'ACOSH';
$args = 1;
+
break;
case 234:
$function = 'ATANH';
$args = 1;
+
break;
case 235:
$function = 'DGET';
$args = 3;
+
break;
case 244:
$function = 'INFO';
$args = 1;
+
break;
case 252:
$function = 'FREQUENCY';
$args = 2;
+
break;
case 261:
$function = 'ERROR.TYPE';
$args = 1;
+
break;
case 271:
$function = 'GAMMALN';
$args = 1;
+
break;
case 273:
$function = 'BINOMDIST';
$args = 4;
+
break;
case 274:
$function = 'CHIDIST';
$args = 2;
+
break;
case 275:
$function = 'CHIINV';
$args = 2;
+
break;
case 276:
$function = 'COMBIN';
$args = 2;
+
break;
case 277:
$function = 'CONFIDENCE';
$args = 3;
+
break;
case 278:
$function = 'CRITBINOM';
$args = 3;
+
break;
case 279:
$function = 'EVEN';
$args = 1;
+
break;
case 280:
$function = 'EXPONDIST';
$args = 3;
+
break;
case 281:
$function = 'FDIST';
$args = 3;
+
break;
case 282:
$function = 'FINV';
$args = 3;
+
break;
case 283:
$function = 'FISHER';
$args = 1;
+
break;
case 284:
$function = 'FISHERINV';
$args = 1;
+
break;
case 285:
$function = 'FLOOR';
$args = 2;
+
break;
case 286:
$function = 'GAMMADIST';
$args = 4;
+
break;
case 287:
$function = 'GAMMAINV';
$args = 3;
+
break;
case 288:
$function = 'CEILING';
$args = 2;
+
break;
case 289:
$function = 'HYPGEOMDIST';
$args = 4;
+
break;
case 290:
$function = 'LOGNORMDIST';
$args = 3;
+
break;
case 291:
$function = 'LOGINV';
$args = 3;
+
break;
case 292:
$function = 'NEGBINOMDIST';
$args = 3;
+
break;
case 293:
$function = 'NORMDIST';
$args = 4;
+
break;
case 294:
$function = 'NORMSDIST';
$args = 1;
+
break;
case 295:
$function = 'NORMINV';
$args = 3;
+
break;
case 296:
$function = 'NORMSINV';
$args = 1;
+
break;
case 297:
$function = 'STANDARDIZE';
$args = 3;
+
break;
case 298:
$function = 'ODD';
$args = 1;
+
break;
case 299:
$function = 'PERMUT';
$args = 2;
+
break;
case 300:
$function = 'POISSON';
$args = 3;
+
break;
case 301:
$function = 'TDIST';
$args = 3;
+
break;
case 302:
$function = 'WEIBULL';
$args = 4;
+
break;
case 303:
$function = 'SUMXMY2';
$args = 2;
+
break;
case 304:
$function = 'SUMX2MY2';
$args = 2;
+
break;
case 305:
$function = 'SUMX2PY2';
$args = 2;
+
break;
case 306:
$function = 'CHITEST';
$args = 2;
+
break;
case 307:
$function = 'CORREL';
$args = 2;
+
break;
case 308:
$function = 'COVAR';
$args = 2;
+
break;
case 309:
$function = 'FORECAST';
$args = 3;
+
break;
case 310:
$function = 'FTEST';
$args = 2;
+
break;
case 311:
$function = 'INTERCEPT';
$args = 2;
+
break;
case 312:
$function = 'PEARSON';
$args = 2;
+
break;
case 313:
$function = 'RSQ';
$args = 2;
+
break;
case 314:
$function = 'STEYX';
$args = 2;
+
break;
case 315:
$function = 'SLOPE';
$args = 2;
+
break;
case 316:
$function = 'TTEST';
$args = 4;
+
break;
case 325:
$function = 'LARGE';
$args = 2;
+
break;
case 326:
$function = 'SMALL';
$args = 2;
+
break;
case 327:
$function = 'QUARTILE';
$args = 2;
+
break;
case 328:
$function = 'PERCENTILE';
$args = 2;
+
break;
case 331:
$function = 'TRIMMEAN';
$args = 2;
+
break;
case 332:
$function = 'TINV';
$args = 2;
+
break;
case 337:
$function = 'POWER';
$args = 2;
+
break;
case 342:
$function = 'RADIANS';
$args = 1;
+
break;
case 343:
$function = 'DEGREES';
$args = 1;
+
break;
case 346:
$function = 'COUNTIF';
$args = 2;
+
break;
case 347:
$function = 'COUNTBLANK';
$args = 1;
+
break;
case 350:
$function = 'ISPMT';
$args = 4;
+
break;
case 351:
$function = 'DATEDIF';
$args = 3;
+
break;
case 352:
$function = 'DATESTRING';
$args = 1;
+
break;
case 353:
$function = 'NUMBERSTRING';
$args = 2;
+
break;
case 360:
$function = 'PHONETIC';
$args = 1;
+
break;
case 368:
$function = 'BAHTTEXT';
$args = 1;
+
break;
default:
throw new Exception('Unrecognized function in formula');
break;
}
$data = ['function' => $function, 'args' => $args];
+
break;
case 0x22: // function with variable number of arguments
case 0x42:
@@ -6265,273 +6664,362 @@ class Xls extends BaseReader implements IReader
switch ($index) {
case 0:
$function = 'COUNT';
+
break;
case 1:
$function = 'IF';
+
break;
case 4:
$function = 'SUM';
+
break;
case 5:
$function = 'AVERAGE';
+
break;
case 6:
$function = 'MIN';
+
break;
case 7:
$function = 'MAX';
+
break;
case 8:
$function = 'ROW';
+
break;
case 9:
$function = 'COLUMN';
+
break;
case 11:
$function = 'NPV';
+
break;
case 12:
$function = 'STDEV';
+
break;
case 13:
$function = 'DOLLAR';
+
break;
case 14:
$function = 'FIXED';
+
break;
case 28:
$function = 'LOOKUP';
+
break;
case 29:
$function = 'INDEX';
+
break;
case 36:
$function = 'AND';
+
break;
case 37:
$function = 'OR';
+
break;
case 46:
$function = 'VAR';
+
break;
case 49:
$function = 'LINEST';
+
break;
case 50:
$function = 'TREND';
+
break;
case 51:
$function = 'LOGEST';
+
break;
case 52:
$function = 'GROWTH';
+
break;
case 56:
$function = 'PV';
+
break;
case 57:
$function = 'FV';
+
break;
case 58:
$function = 'NPER';
+
break;
case 59:
$function = 'PMT';
+
break;
case 60:
$function = 'RATE';
+
break;
case 62:
$function = 'IRR';
+
break;
case 64:
$function = 'MATCH';
+
break;
case 70:
$function = 'WEEKDAY';
+
break;
case 78:
$function = 'OFFSET';
+
break;
case 82:
$function = 'SEARCH';
+
break;
case 100:
$function = 'CHOOSE';
+
break;
case 101:
$function = 'HLOOKUP';
+
break;
case 102:
$function = 'VLOOKUP';
+
break;
case 109:
$function = 'LOG';
+
break;
case 115:
$function = 'LEFT';
+
break;
case 116:
$function = 'RIGHT';
+
break;
case 120:
$function = 'SUBSTITUTE';
+
break;
case 124:
$function = 'FIND';
+
break;
case 125:
$function = 'CELL';
+
break;
case 144:
$function = 'DDB';
+
break;
case 148:
$function = 'INDIRECT';
+
break;
case 167:
$function = 'IPMT';
+
break;
case 168:
$function = 'PPMT';
+
break;
case 169:
$function = 'COUNTA';
+
break;
case 183:
$function = 'PRODUCT';
+
break;
case 193:
$function = 'STDEVP';
+
break;
case 194:
$function = 'VARP';
+
break;
case 197:
$function = 'TRUNC';
+
break;
case 204:
$function = 'USDOLLAR';
+
break;
case 205:
$function = 'FINDB';
+
break;
case 206:
$function = 'SEARCHB';
+
break;
case 208:
$function = 'LEFTB';
+
break;
case 209:
$function = 'RIGHTB';
+
break;
case 216:
$function = 'RANK';
+
break;
case 219:
$function = 'ADDRESS';
+
break;
case 220:
$function = 'DAYS360';
+
break;
case 222:
$function = 'VDB';
+
break;
case 227:
$function = 'MEDIAN';
+
break;
case 228:
$function = 'SUMPRODUCT';
+
break;
case 247:
$function = 'DB';
+
break;
case 255:
$function = '';
+
break;
case 269:
$function = 'AVEDEV';
+
break;
case 270:
$function = 'BETADIST';
+
break;
case 272:
$function = 'BETAINV';
+
break;
case 317:
$function = 'PROB';
+
break;
case 318:
$function = 'DEVSQ';
+
break;
case 319:
$function = 'GEOMEAN';
+
break;
case 320:
$function = 'HARMEAN';
+
break;
case 321:
$function = 'SUMSQ';
+
break;
case 322:
$function = 'KURT';
+
break;
case 323:
$function = 'SKEW';
+
break;
case 324:
$function = 'ZTEST';
+
break;
case 329:
$function = 'PERCENTRANK';
+
break;
case 330:
$function = 'MODE';
+
break;
case 336:
$function = 'CONCATENATE';
+
break;
case 344:
$function = 'SUBTOTAL';
+
break;
case 345:
$function = 'SUMIF';
+
break;
case 354:
$function = 'ROMAN';
+
break;
case 358:
$function = 'GETPIVOTDATA';
+
break;
case 359:
$function = 'HYPERLINK';
+
break;
case 361:
$function = 'AVERAGEA';
+
break;
case 362:
$function = 'MAXA';
+
break;
case 363:
$function = 'MINA';
+
break;
case 364:
$function = 'STDEVPA';
+
break;
case 365:
$function = 'VARPA';
+
break;
case 366:
$function = 'STDEVA';
+
break;
case 367:
$function = 'VARA';
+
break;
default:
throw new Exception('Unrecognized function in formula');
break;
}
$data = ['function' => $function, 'args' => $args];
+
break;
case 0x23: // index to defined name
case 0x43:
@@ -6542,6 +7030,7 @@ class Xls extends BaseReader implements IReader
$definedNameIndex = self::getUInt2d($formulaData, 1) - 1;
// offset: 2; size: 2; not used
$data = $this->definedname[$definedNameIndex]['name'];
+
break;
case 0x24: // single cell reference e.g. A5
case 0x44:
@@ -6549,6 +7038,7 @@ class Xls extends BaseReader implements IReader
$name = 'tRef';
$size = 5;
$data = $this->readBIFF8CellAddress(substr($formulaData, 1, 4));
+
break;
case 0x25: // cell range reference to cells in the same sheet (2d)
case 0x45:
@@ -6556,6 +7046,7 @@ class Xls extends BaseReader implements IReader
$name = 'tArea';
$size = 9;
$data = $this->readBIFF8CellRangeAddress(substr($formulaData, 1, 8));
+
break;
case 0x26: // Constant reference sub-expression
case 0x46:
@@ -6566,6 +7057,7 @@ class Xls extends BaseReader implements IReader
$subSize = self::getUInt2d($formulaData, 5);
$size = 7 + $subSize;
$data = $this->getFormulaFromData(substr($formulaData, 7, $subSize));
+
break;
case 0x27: // Deleted constant reference sub-expression
case 0x47:
@@ -6576,6 +7068,7 @@ class Xls extends BaseReader implements IReader
$subSize = self::getUInt2d($formulaData, 5);
$size = 7 + $subSize;
$data = $this->getFormulaFromData(substr($formulaData, 7, $subSize));
+
break;
case 0x29: // Variable reference sub-expression
case 0x49:
@@ -6585,6 +7078,7 @@ class Xls extends BaseReader implements IReader
$subSize = self::getUInt2d($formulaData, 1);
$size = 3 + $subSize;
$data = $this->getFormulaFromData(substr($formulaData, 3, $subSize));
+
break;
case 0x2C: // Relative 2d cell reference reference, used in shared formulas and some other places
case 0x4C:
@@ -6592,6 +7086,7 @@ class Xls extends BaseReader implements IReader
$name = 'tRefN';
$size = 5;
$data = $this->readBIFF8CellAddressB(substr($formulaData, 1, 4), $baseCell);
+
break;
case 0x2D: // Relative 2d range reference
case 0x4D:
@@ -6599,6 +7094,7 @@ class Xls extends BaseReader implements IReader
$name = 'tAreaN';
$size = 9;
$data = $this->readBIFF8CellRangeAddressB(substr($formulaData, 1, 8), $baseCell);
+
break;
case 0x39: // External name
case 0x59:
@@ -6629,6 +7125,7 @@ class Xls extends BaseReader implements IReader
// deleted sheet reference
$data = '#REF!';
}
+
break;
case 0x3B: // 3d reference to cell range
case 0x5B:
@@ -6647,6 +7144,7 @@ class Xls extends BaseReader implements IReader
// deleted sheet reference
$data = '#REF!';
}
+
break;
// Unknown cases // don't know how to deal with
default:
@@ -6703,7 +7201,7 @@ class Xls extends BaseReader implements IReader
*/
private function readBIFF8CellAddressB($cellAddressStructure, $baseCell = 'A1')
{
- list($baseCol, $baseRow) = Cell::coordinateFromString($baseCell);
+ [$baseCol, $baseRow] = Cell::coordinateFromString($baseCell);
$baseCol = Cell::columnIndexFromString($baseCol) - 1;
// offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767))
@@ -6836,10 +7334,10 @@ class Xls extends BaseReader implements IReader
// not just return e.g. 'A1' and not 'A1:A1' ?
// offset: 0; size: 2; index to first row (0... 65535) (or offset (-32768... 32767))
- $fr = self::getUInt2d($subData, 0) + 1;
+ $fr = self::getUInt2d($subData, 0) + 1;
// offset: 2; size: 2; index to last row (0... 65535) (or offset (-32768... 32767))
- $lr = self::getUInt2d($subData, 2) + 1;
+ $lr = self::getUInt2d($subData, 2) + 1;
// offset: 4; size: 2; index to first column or column offset + relative flags
@@ -6886,7 +7384,7 @@ class Xls extends BaseReader implements IReader
*/
private function readBIFF8CellRangeAddressB($subData, $baseCell = 'A1')
{
- list($baseCol, $baseRow) = Cell::coordinateFromString($baseCell);
+ [$baseCol, $baseRow] = Cell::coordinateFromString($baseCell);
$baseCol = Cell::columnIndexFromString($baseCol) - 1;
// TODO: if cell range is just a single cell, should this funciton
@@ -7027,7 +7525,7 @@ class Xls extends BaseReader implements IReader
*
* @throws Exception
*
- * @return string|false
+ * @return false|string
*/
private function readSheetRangeByRefIndex($index)
{
@@ -7132,17 +7630,20 @@ class Xls extends BaseReader implements IReader
case 0x00: // empty constant (what is this?)
$value = '';
$size = 9;
+
break;
case 0x01: // number
// offset: 1; size: 8; IEEE 754 floating-point value
$value = self::extractNumber(substr($valueData, 1, 8));
$size = 9;
+
break;
case 0x02: // string value
// offset: 1; size: var; Unicode string, 16-bit string length
$string = self::readUnicodeStringLong(substr($valueData, 1));
$value = '"' . $string['value'] . '"';
$size = 1 + $string['size'];
+
break;
case 0x04: // boolean
// offset: 1; size: 1; 0 = FALSE, 1 = TRUE
@@ -7152,11 +7653,13 @@ class Xls extends BaseReader implements IReader
$value = 'FALSE';
}
$size = 9;
+
break;
case 0x10: // error code
// offset: 1; size: 1; error code
$value = Xls\ErrorCode::lookup(ord($valueData[1]));
$size = 9;
+
break;
}
diff --git a/src/PhpSpreadsheet/Reader/Xls/Color.php b/src/PhpSpreadsheet/Reader/Xls/Color.php
index 6d3d6340..4f68a2db 100644
--- a/src/PhpSpreadsheet/Reader/Xls/Color.php
+++ b/src/PhpSpreadsheet/Reader/Xls/Color.php
@@ -20,7 +20,7 @@ class Color
if ($color <= 0x07 || $color >= 0x40) {
// special built-in color
return Color\BuiltIn::lookup($color);
- } elseif (isset($palette) && isset($palette[$color - 8])) {
+ } elseif (isset($palette, $palette[$color - 8])) {
// palette color, color index 0x08 maps to pallete index 0
return $palette[$color - 8];
}
diff --git a/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php b/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php
index 1b1488e3..7daf7230 100644
--- a/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php
+++ b/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php
@@ -19,7 +19,7 @@ class ErrorCode
*
* @param int $code
*
- * @return string|bool
+ * @return bool|string
*/
public static function lookup($code)
{
diff --git a/src/PhpSpreadsheet/Reader/Xls/Escher.php b/src/PhpSpreadsheet/Reader/Xls/Escher.php
index 658ab844..81254eb7 100644
--- a/src/PhpSpreadsheet/Reader/Xls/Escher.php
+++ b/src/PhpSpreadsheet/Reader/Xls/Escher.php
@@ -93,60 +93,79 @@ class Escher
switch ($fbt) {
case self::DGGCONTAINER:
$this->readDggContainer();
+
break;
case self::DGG:
$this->readDgg();
+
break;
case self::BSTORECONTAINER:
$this->readBstoreContainer();
+
break;
case self::BSE:
$this->readBSE();
+
break;
case self::BLIPJPEG:
$this->readBlipJPEG();
+
break;
case self::BLIPPNG:
$this->readBlipPNG();
+
break;
case self::OPT:
$this->readOPT();
+
break;
case self::TERTIARYOPT:
$this->readTertiaryOPT();
+
break;
case self::SPLITMENUCOLORS:
$this->readSplitMenuColors();
+
break;
case self::DGCONTAINER:
$this->readDgContainer();
+
break;
case self::DG:
$this->readDg();
+
break;
case self::SPGRCONTAINER:
$this->readSpgrContainer();
+
break;
case self::SPCONTAINER:
$this->readSpContainer();
+
break;
case self::SPGR:
$this->readSpgr();
+
break;
case self::SP:
$this->readSp();
+
break;
case self::CLIENTTEXTBOX:
$this->readClientTextbox();
+
break;
case self::CLIENTANCHOR:
$this->readClientAnchor();
+
break;
case self::CLIENTDATA:
$this->readClientData();
+
break;
default:
$this->readDefault();
+
break;
}
}
diff --git a/src/PhpSpreadsheet/Reader/Xls/MD5.php b/src/PhpSpreadsheet/Reader/Xls/MD5.php
index d683fc47..f0c31773 100644
--- a/src/PhpSpreadsheet/Reader/Xls/MD5.php
+++ b/src/PhpSpreadsheet/Reader/Xls/MD5.php
@@ -67,7 +67,7 @@ class MD5
$H = ['self', 'h'];
$I = ['self', 'i'];
- /* ROUND 1 */
+ // ROUND 1
self::step($F, $A, $B, $C, $D, $words[0], 7, 0xd76aa478);
self::step($F, $D, $A, $B, $C, $words[1], 12, 0xe8c7b756);
self::step($F, $C, $D, $A, $B, $words[2], 17, 0x242070db);
@@ -85,7 +85,7 @@ class MD5
self::step($F, $C, $D, $A, $B, $words[14], 17, 0xa679438e);
self::step($F, $B, $C, $D, $A, $words[15], 22, 0x49b40821);
- /* ROUND 2 */
+ // ROUND 2
self::step($G, $A, $B, $C, $D, $words[1], 5, 0xf61e2562);
self::step($G, $D, $A, $B, $C, $words[6], 9, 0xc040b340);
self::step($G, $C, $D, $A, $B, $words[11], 14, 0x265e5a51);
@@ -103,7 +103,7 @@ class MD5
self::step($G, $C, $D, $A, $B, $words[7], 14, 0x676f02d9);
self::step($G, $B, $C, $D, $A, $words[12], 20, 0x8d2a4c8a);
- /* ROUND 3 */
+ // ROUND 3
self::step($H, $A, $B, $C, $D, $words[5], 4, 0xfffa3942);
self::step($H, $D, $A, $B, $C, $words[8], 11, 0x8771f681);
self::step($H, $C, $D, $A, $B, $words[11], 16, 0x6d9d6122);
@@ -121,7 +121,7 @@ class MD5
self::step($H, $C, $D, $A, $B, $words[15], 16, 0x1fa27cf8);
self::step($H, $B, $C, $D, $A, $words[2], 23, 0xc4ac5665);
- /* ROUND 4 */
+ // ROUND 4
self::step($I, $A, $B, $C, $D, $words[0], 6, 0xf4292244);
self::step($I, $D, $A, $B, $C, $words[7], 10, 0x432aff97);
self::step($I, $C, $D, $A, $B, $words[14], 15, 0xab9423a7);
diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php
index 22966bfb..000f0424 100644
--- a/src/PhpSpreadsheet/Reader/Xlsx.php
+++ b/src/PhpSpreadsheet/Reader/Xlsx.php
@@ -29,7 +29,7 @@ class Xlsx extends BaseReader implements IReader
*
* @var ReferenceHelper
*/
- private $referenceHelper = null;
+ private $referenceHelper;
/**
* Xlsx\Theme instance.
@@ -79,6 +79,7 @@ class Xlsx extends BaseReader implements IReader
if (basename($rel['Target']) == 'workbook.xml') {
$xl = true;
}
+
break;
}
}
@@ -381,6 +382,7 @@ class Xlsx extends BaseReader implements IReader
}
self::$theme = new Xlsx\Theme($themeName, $colourSchemeName, $themeColours);
}
+
break;
}
}
@@ -414,6 +416,7 @@ class Xlsx extends BaseReader implements IReader
$docProps->setKeywords((string) self::getArrayItem($xmlCore->xpath('cp:keywords')));
$docProps->setCategory((string) self::getArrayItem($xmlCore->xpath('cp:category')));
}
+
break;
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties':
$xmlCore = simplexml_load_string(
@@ -430,6 +433,7 @@ class Xlsx extends BaseReader implements IReader
$docProps->setManager((string) $xmlCore->Manager);
}
}
+
break;
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties':
$xmlCore = simplexml_load_string(
@@ -453,13 +457,15 @@ class Xlsx extends BaseReader implements IReader
}
}
}
+
break;
//Ribbon
case 'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility':
$customUI = $rel['Target'];
- if (!is_null($customUI)) {
+ if ($customUI !== null) {
$this->readRibbon($excel, $customUI, $zip);
}
+
break;
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument':
$dir = dirname($rel['Target']);
@@ -479,7 +485,7 @@ class Xlsx extends BaseReader implements IReader
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
);
- if (isset($xmlStrings) && isset($xmlStrings->si)) {
+ if (isset($xmlStrings, $xmlStrings->si)) {
foreach ($xmlStrings->si as $val) {
if (isset($val->t)) {
$sharedStrings[] = StringHelper::controlCharacterOOXML2PHP((string) $val->t);
@@ -495,15 +501,17 @@ class Xlsx extends BaseReader implements IReader
switch ($ele['Type']) {
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet':
$worksheets[(string) $ele['Id']] = $ele['Target'];
+
break;
// a vbaProject ? (: some macros)
case 'http://schemas.microsoft.com/office/2006/relationships/vbaProject':
$macros = $ele['Target'];
+
break;
}
}
- if (!is_null($macros)) {
+ if ($macros !== null) {
$macrosCode = $this->getFromZipArchive($zip, 'xl/vbaProject.bin'); //vbaProject.bin always in 'xl' dir and always named vbaProject.bin
if ($macrosCode !== false) {
$excel->setMacrosCode($macrosCode);
@@ -662,6 +670,7 @@ class Xlsx extends BaseReader implements IReader
if (isset($this->loadSheetsOnly) && !in_array((string) $eleSheet['name'], $this->loadSheetsOnly)) {
++$countSkippedSheets;
$mapSheetId[$oldSheetId] = null;
+
continue;
}
@@ -690,7 +699,7 @@ class Xlsx extends BaseReader implements IReader
$docSheet->setSheetState((string) $eleSheet['state']);
}
- if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) {
+ if (isset($xmlSheet->sheetViews, $xmlSheet->sheetViews->sheetView)) {
if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) {
$docSheet->getSheetView()->setZoomScale((int) ($xmlSheet->sheetViews->sheetView['zoomScale']));
}
@@ -738,15 +747,15 @@ class Xlsx extends BaseReader implements IReader
}
}
- if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) {
+ if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr->tabColor)) {
if (isset($xmlSheet->sheetPr->tabColor['rgb'])) {
$docSheet->getTabColor()->setARGB((string) $xmlSheet->sheetPr->tabColor['rgb']);
}
}
- if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr['codeName'])) {
+ if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr['codeName'])) {
$docSheet->setCodeName((string) $xmlSheet->sheetPr['codeName'], false);
}
- if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
+ if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr->outlinePr)) {
if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) &&
!self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) {
$docSheet->setShowSummaryRight(false);
@@ -762,7 +771,7 @@ class Xlsx extends BaseReader implements IReader
}
}
- if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) {
+ if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr->pageSetUpPr)) {
if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) &&
!self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) {
$docSheet->getPageSetup()->setFitToPage(false);
@@ -875,6 +884,7 @@ class Xlsx extends BaseReader implements IReader
} else {
$value = '';
}
+
break;
case 'b':
if (!isset($c->f)) {
@@ -887,6 +897,7 @@ class Xlsx extends BaseReader implements IReader
$docSheet->getCell($r)->setFormulaAttributes($att);
}
}
+
break;
case 'inlineStr':
if (isset($c->f)) {
@@ -894,6 +905,7 @@ class Xlsx extends BaseReader implements IReader
} else {
$value = $this->parseRichText($c->is);
}
+
break;
case 'e':
if (!isset($c->f)) {
@@ -902,6 +914,7 @@ class Xlsx extends BaseReader implements IReader
// Formula
$this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError');
}
+
break;
default:
if (!isset($c->f)) {
@@ -910,6 +923,7 @@ class Xlsx extends BaseReader implements IReader
// Formula
$this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToString');
}
+
break;
}
@@ -1147,7 +1161,7 @@ class Xlsx extends BaseReader implements IReader
if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) {
$docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false);
}
- if (isset($xmlSheet->pageSetup['firstPageNumber']) && isset($xmlSheet->pageSetup['useFirstPageNumber']) &&
+ if (isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) &&
self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) {
$docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber']));
}
@@ -1679,6 +1693,7 @@ class Xlsx extends BaseReader implements IReader
}
}
}
+
break;
case '_xlnm.Print_Titles':
// Split $extractedRange
@@ -1697,6 +1712,7 @@ class Xlsx extends BaseReader implements IReader
$docSheet->getPageSetup()->setRowsToRepeatAtTop([$matches[1], $matches[2]]);
}
}
+
break;
case '_xlnm.Print_Area':
$rangeSets = preg_split("/'(.*?)'(?:![A-Z0-9]+:[A-Z0-9]+,?)/", $extractedRange, PREG_SPLIT_NO_EMPTY);
@@ -1710,6 +1726,7 @@ class Xlsx extends BaseReader implements IReader
$newRangeSets[] = str_replace('$', '', $rangeSet);
}
$docSheet->getPageSetup()->setPrintArea(implode(',', $newRangeSets));
+
break;
default:
break;
@@ -1760,6 +1777,7 @@ class Xlsx extends BaseReader implements IReader
}
}
}
+
break;
}
} elseif (!isset($definedName['localSheetId'])) {
@@ -1801,6 +1819,7 @@ class Xlsx extends BaseReader implements IReader
$excel->setActiveSheetIndex(0);
}
}
+
break;
}
}
@@ -1873,7 +1892,7 @@ class Xlsx extends BaseReader implements IReader
/**
* @param Style $docStyle
- * @param \stdClass|\SimpleXMLElement $style
+ * @param \SimpleXMLElement|\stdClass $style
*/
private static function readStyle(Style $docStyle, $style)
{
@@ -1896,11 +1915,11 @@ class Xlsx extends BaseReader implements IReader
if (isset($style->font->u) && !isset($style->font->u['val'])) {
$docStyle->getFont()->setUnderline(Style\Font::UNDERLINE_SINGLE);
- } elseif (isset($style->font->u) && isset($style->font->u['val'])) {
+ } elseif (isset($style->font->u, $style->font->u['val'])) {
$docStyle->getFont()->setUnderline((string) $style->font->u['val']);
}
- if (isset($style->font->vertAlign) && isset($style->font->vertAlign['val'])) {
+ if (isset($style->font->vertAlign, $style->font->vertAlign['val'])) {
$vertAlign = strtolower((string) $style->font->vertAlign['val']);
if ($vertAlign == 'superscript') {
$docStyle->getFont()->setSuperscript(true);
@@ -2051,7 +2070,7 @@ class Xlsx extends BaseReader implements IReader
(isset($run->rPr->i) && !isset($run->rPr->i['val']))) {
$objText->getFont()->setItalic(true);
}
- if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign['val'])) {
+ if (isset($run->rPr->vertAlign, $run->rPr->vertAlign['val'])) {
$vertAlign = strtolower((string) $run->rPr->vertAlign['val']);
if ($vertAlign == 'superscript') {
$objText->getFont()->setSuperscript(true);
@@ -2062,7 +2081,7 @@ class Xlsx extends BaseReader implements IReader
}
if (isset($run->rPr->u) && !isset($run->rPr->u['val'])) {
$objText->getFont()->setUnderline(Style\Font::UNDERLINE_SINGLE);
- } elseif (isset($run->rPr->u) && isset($run->rPr->u['val'])) {
+ } elseif (isset($run->rPr->u, $run->rPr->u['val'])) {
$objText->getFont()->setUnderline((string) $run->rPr->u['val']);
}
if ((isset($run->rPr->strike['val']) && self::boolean((string) $run->rPr->strike['val'])) ||
diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php
index 9ac13715..fd6f2cc3 100644
--- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php
+++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php
@@ -73,21 +73,25 @@ class Chart
switch ($chartDetailKey) {
case 'layout':
$plotAreaLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta);
+
break;
case 'catAx':
if (isset($chartDetail->title)) {
$XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta);
}
+
break;
case 'dateAx':
if (isset($chartDetail->title)) {
$XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta);
}
+
break;
case 'valAx':
if (isset($chartDetail->title)) {
$YaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta);
}
+
break;
case 'barChart':
case 'bar3DChart':
@@ -96,16 +100,19 @@ class Chart
$plotSer->setPlotDirection($barDirection);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
+
break;
case 'lineChart':
case 'line3DChart':
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::readChartAttributes($chartDetail);
+
break;
case 'areaChart':
case 'area3DChart':
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::readChartAttributes($chartDetail);
+
break;
case 'doughnutChart':
case 'pieChart':
@@ -115,6 +122,7 @@ class Chart
$plotSer->setPlotStyle($explosion);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
+
break;
case 'scatterChart':
$scatterStyle = self::getAttribute($chartDetail->scatterStyle, 'val', 'string');
@@ -122,6 +130,7 @@ class Chart
$plotSer->setPlotStyle($scatterStyle);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
+
break;
case 'bubbleChart':
$bubbleScale = self::getAttribute($chartDetail->bubbleScale, 'val', 'integer');
@@ -129,6 +138,7 @@ class Chart
$plotSer->setPlotStyle($bubbleScale);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
+
break;
case 'radarChart':
$radarStyle = self::getAttribute($chartDetail->radarStyle, 'val', 'string');
@@ -136,6 +146,7 @@ class Chart
$plotSer->setPlotStyle($radarStyle);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
+
break;
case 'surfaceChart':
case 'surface3DChart':
@@ -144,10 +155,12 @@ class Chart
$plotSer->setPlotStyle($wireFrame);
$plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail);
+
break;
case 'stockChart':
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::readChartAttributes($plotAreaLayout);
+
break;
}
}
@@ -156,15 +169,19 @@ class Chart
}
$plotArea = new PlotArea($plotAreaLayout, $plotSeries);
self::setChartAttributes($plotAreaLayout, $plotAttributes);
+
break;
case 'plotVisOnly':
$plotVisOnly = self::getAttribute($chartDetails, 'val', 'string');
+
break;
case 'dispBlanksAs':
$dispBlanksAs = self::getAttribute($chartDetails, 'val', 'string');
+
break;
case 'title':
$title = self::chartTitle($chartDetails, $namespacesChartMeta);
+
break;
case 'legend':
$legendPos = 'r';
@@ -174,16 +191,20 @@ class Chart
switch ($chartDetailKey) {
case 'legendPos':
$legendPos = self::getAttribute($chartDetail, 'val', 'string');
+
break;
case 'overlay':
$legendOverlay = self::getAttribute($chartDetail, 'val', 'boolean');
+
break;
case 'layout':
$legendLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta);
+
break;
}
}
$legend = new Legend($legendPos, $legendLayout, $legendOverlay);
+
break;
}
}
@@ -209,9 +230,11 @@ class Chart
$caption[] = self::parseRichText($titleDetailPart);
}
}
+
break;
case 'layout':
$titleLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta);
+
break;
}
}
@@ -225,7 +248,7 @@ class Chart
return null;
}
$details = $chartDetail->manualLayout->children($namespacesChartMeta['c']);
- if (is_null($details)) {
+ if ($details === null) {
return null;
}
$layout = [];
@@ -247,6 +270,7 @@ class Chart
switch ($seriesDetailKey) {
case 'grouping':
$multiSeriesType = self::getAttribute($chartDetail->grouping, 'val', 'string');
+
break;
case 'ser':
$marker = null;
@@ -254,31 +278,40 @@ class Chart
switch ($seriesKey) {
case 'idx':
$seriesIndex = self::getAttribute($seriesDetail, 'val', 'integer');
+
break;
case 'order':
$seriesOrder = self::getAttribute($seriesDetail, 'val', 'integer');
$plotOrder[$seriesIndex] = $seriesOrder;
+
break;
case 'tx':
$seriesLabel[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
+
break;
case 'marker':
$marker = self::getAttribute($seriesDetail->symbol, 'val', 'string');
+
break;
case 'smooth':
$smoothLine = self::getAttribute($seriesDetail, 'val', 'boolean');
+
break;
case 'cat':
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
+
break;
case 'val':
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
+
break;
case 'xVal':
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
+
break;
case 'yVal':
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
+
break;
}
}
@@ -327,9 +360,11 @@ class Chart
switch ($seriesValueIdx) {
case 'ptCount':
$pointCount = self::getAttribute($seriesValue, 'val', 'integer');
+
break;
case 'formatCode':
$formatCode = (string) $seriesValue;
+
break;
case 'pt':
$pointVal = self::getAttribute($seriesValue, 'idx', 'integer');
@@ -340,6 +375,7 @@ class Chart
} else {
$seriesVal[$pointVal] = (float) $seriesValue->v;
}
+
break;
}
}
@@ -362,9 +398,11 @@ class Chart
switch ($seriesValueIdx) {
case 'ptCount':
$pointCount = self::getAttribute($seriesValue, 'val', 'integer');
+
break;
case 'formatCode':
$formatCode = (string) $seriesValue;
+
break;
case 'pt':
$pointVal = self::getAttribute($seriesValue, 'idx', 'integer');
@@ -375,6 +413,7 @@ class Chart
} else {
$seriesVal[$pointVal][] = (float) $seriesValue->v;
}
+
break;
}
}
@@ -401,27 +440,27 @@ class Chart
}
$fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
- if (!is_null($fontSize)) {
+ if ($fontSize !== null) {
$objText->getFont()->setSize(floor($fontSize / 100));
}
$fontColor = (self::getAttribute($titleDetailElement->rPr, 'color', 'string'));
- if (!is_null($fontColor)) {
+ if ($fontColor !== null) {
$objText->getFont()->setColor(new Color(self::readColor($fontColor)));
}
$bold = self::getAttribute($titleDetailElement->rPr, 'b', 'boolean');
- if (!is_null($bold)) {
+ if ($bold !== null) {
$objText->getFont()->setBold($bold);
}
$italic = self::getAttribute($titleDetailElement->rPr, 'i', 'boolean');
- if (!is_null($italic)) {
+ if ($italic !== null) {
$objText->getFont()->setItalic($italic);
}
$baseline = self::getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
- if (!is_null($baseline)) {
+ if ($baseline !== null) {
if ($baseline > 0) {
$objText->getFont()->setSuperscript(true);
} elseif ($baseline < 0) {
@@ -430,7 +469,7 @@ class Chart
}
$underscore = (self::getAttribute($titleDetailElement->rPr, 'u', 'string'));
- if (!is_null($underscore)) {
+ if ($underscore !== null) {
if ($underscore == 'sng') {
$objText->getFont()->setUnderline(Font::UNDERLINE_SINGLE);
} elseif ($underscore == 'dbl') {
@@ -441,7 +480,7 @@ class Chart
}
$strikethrough = (self::getAttribute($titleDetailElement->rPr, 's', 'string'));
- if (!is_null($strikethrough)) {
+ if ($strikethrough !== null) {
if ($strikethrough == 'noStrike') {
$objText->getFont()->setStrikethrough(false);
} else {
@@ -494,24 +533,31 @@ class Chart
switch ($plotAttributeKey) {
case 'showLegendKey':
$plotArea->setShowLegendKey($plotAttributeValue);
+
break;
case 'showVal':
$plotArea->setShowVal($plotAttributeValue);
+
break;
case 'showCatName':
$plotArea->setShowCatName($plotAttributeValue);
+
break;
case 'showSerName':
$plotArea->setShowSerName($plotAttributeValue);
+
break;
case 'showPercent':
$plotArea->setShowPercent($plotAttributeValue);
+
break;
case 'showBubbleSize':
$plotArea->setShowBubbleSize($plotAttributeValue);
+
break;
case 'showLeaderLines':
$plotArea->setShowLeaderLines($plotAttributeValue);
+
break;
}
}
diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php
index 02611197..7773e7ac 100644
--- a/src/PhpSpreadsheet/Reader/Xml.php
+++ b/src/PhpSpreadsheet/Reader/Xml.php
@@ -82,6 +82,7 @@ class Xml extends BaseReader implements IReader
// every part of the signature must be present
if (strpos($data, $match) === false) {
$valid = false;
+
break;
}
}
@@ -344,38 +345,49 @@ class Xml extends BaseReader implements IReader
switch ($propertyName) {
case 'Title':
$docProps->setTitle(self::convertStringEncoding($propertyValue, $this->charSet));
+
break;
case 'Subject':
$docProps->setSubject(self::convertStringEncoding($propertyValue, $this->charSet));
+
break;
case 'Author':
$docProps->setCreator(self::convertStringEncoding($propertyValue, $this->charSet));
+
break;
case 'Created':
$creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate);
+
break;
case 'LastAuthor':
$docProps->setLastModifiedBy(self::convertStringEncoding($propertyValue, $this->charSet));
+
break;
case 'LastSaved':
$lastSaveDate = strtotime($propertyValue);
$docProps->setModified($lastSaveDate);
+
break;
case 'Company':
$docProps->setCompany(self::convertStringEncoding($propertyValue, $this->charSet));
+
break;
case 'Category':
$docProps->setCategory(self::convertStringEncoding($propertyValue, $this->charSet));
+
break;
case 'Manager':
$docProps->setManager(self::convertStringEncoding($propertyValue, $this->charSet));
+
break;
case 'Keywords':
$docProps->setKeywords(self::convertStringEncoding($propertyValue, $this->charSet));
+
break;
case 'Description':
$docProps->setDescription(self::convertStringEncoding($propertyValue, $this->charSet));
+
break;
}
}
@@ -389,22 +401,27 @@ class Xml extends BaseReader implements IReader
case 'string':
$propertyType = Properties::PROPERTY_TYPE_STRING;
$propertyValue = trim($propertyValue);
+
break;
case 'boolean':
$propertyType = Properties::PROPERTY_TYPE_BOOLEAN;
$propertyValue = (bool) $propertyValue;
+
break;
case 'integer':
$propertyType = Properties::PROPERTY_TYPE_INTEGER;
$propertyValue = (int) $propertyValue;
+
break;
case 'float':
$propertyType = Properties::PROPERTY_TYPE_FLOAT;
$propertyValue = (float) $propertyValue;
+
break;
case 'dateTime.tz':
$propertyType = Properties::PROPERTY_TYPE_DATE;
$propertyValue = strtotime(trim($propertyValue));
+
break;
}
$docProps->setCustomProperty($propertyName, $propertyValue, $propertyType);
@@ -426,17 +443,21 @@ class Xml extends BaseReader implements IReader
if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) {
$this->styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
}
+
break;
case 'Horizontal':
if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) {
$this->styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
}
+
break;
case 'WrapText':
$this->styles[$styleID]['alignment']['wrapText'] = true;
+
break;
}
}
+
break;
case 'Borders':
foreach ($styleData->Border as $borderStyle) {
@@ -446,15 +467,18 @@ class Xml extends BaseReader implements IReader
switch ($borderStyleKey) {
case 'LineStyle':
$thisBorder['borderStyle'] = Border::BORDER_MEDIUM;
+
break;
case 'Weight':
break;
case 'Position':
$borderPosition = strtolower($borderStyleValue);
+
break;
case 'Color':
$borderColour = substr($borderStyleValue, 1);
$thisBorder['color']['rgb'] = $borderColour;
+
break;
}
}
@@ -464,6 +488,7 @@ class Xml extends BaseReader implements IReader
}
}
}
+
break;
case 'Font':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
@@ -471,38 +496,48 @@ class Xml extends BaseReader implements IReader
switch ($styleAttributeKey) {
case 'FontName':
$this->styles[$styleID]['font']['name'] = $styleAttributeValue;
+
break;
case 'Size':
$this->styles[$styleID]['font']['size'] = $styleAttributeValue;
+
break;
case 'Color':
$this->styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue, 1);
+
break;
case 'Bold':
$this->styles[$styleID]['font']['bold'] = true;
+
break;
case 'Italic':
$this->styles[$styleID]['font']['italic'] = true;
+
break;
case 'Underline':
if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) {
$this->styles[$styleID]['font']['underline'] = $styleAttributeValue;
}
+
break;
}
}
+
break;
case 'Interior':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
switch ($styleAttributeKey) {
case 'Color':
$this->styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue, 1);
+
break;
case 'Pattern':
$this->styles[$styleID]['fill']['fillType'] = strtolower($styleAttributeValue);
+
break;
}
}
+
break;
case 'NumberFormat':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
@@ -510,16 +545,19 @@ class Xml extends BaseReader implements IReader
switch ($styleAttributeValue) {
case 'Short Date':
$styleAttributeValue = 'dd/mm/yyyy';
+
break;
}
if ($styleAttributeValue > '') {
$this->styles[$styleID]['numberFormat']['formatCode'] = $styleAttributeValue;
}
}
+
break;
case 'Protection':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
}
+
break;
}
}
@@ -583,6 +621,7 @@ class Xml extends BaseReader implements IReader
if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
++$columnID;
+
continue;
}
}
@@ -634,6 +673,7 @@ class Xml extends BaseReader implements IReader
case 'String':
$cellValue = self::convertStringEncoding($cellValue, $this->charSet);
$type = Cell\DataType::TYPE_STRING;
+
break;
case 'Number':
$type = Cell\DataType::TYPE_NUMERIC;
@@ -641,17 +681,21 @@ class Xml extends BaseReader implements IReader
if (floor($cellValue) == $cellValue) {
$cellValue = (int) $cellValue;
}
+
break;
case 'Boolean':
$type = Cell\DataType::TYPE_BOOL;
$cellValue = ($cellValue != 0);
+
break;
case 'DateTime':
$type = Cell\DataType::TYPE_NUMERIC;
$cellValue = Date::PHPToExcel(strtotime($cellValue));
+
break;
case 'Error':
$type = Cell\DataType::TYPE_ERROR;
+
break;
}
}
diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php
index 1397d400..9a7b6785 100644
--- a/src/PhpSpreadsheet/ReferenceHelper.php
+++ b/src/PhpSpreadsheet/ReferenceHelper.php
@@ -122,7 +122,7 @@ class ReferenceHelper
*/
private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)
{
- list($cellColumn, $cellRow) = Cell::coordinateFromString($cellAddress);
+ [$cellColumn, $cellRow] = Cell::coordinateFromString($cellAddress);
$cellColumnIndex = Cell::columnIndexFromString($cellColumn);
// Is cell within the range of rows/columns if we're deleting
if ($pNumRows < 0 &&
@@ -309,7 +309,7 @@ class ReferenceHelper
if (!empty($aColumnDimensions)) {
foreach ($aColumnDimensions as $objColumnDimension) {
$newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows);
- list($newReference) = Cell::coordinateFromString($newReference);
+ [$newReference] = Cell::coordinateFromString($newReference);
if ($objColumnDimension->getColumnIndex() != $newReference) {
$objColumnDimension->setColumnIndex($newReference);
}
@@ -334,7 +334,7 @@ class ReferenceHelper
if (!empty($aRowDimensions)) {
foreach ($aRowDimensions as $objRowDimension) {
$newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows);
- list(, $newReference) = Cell::coordinateFromString($newReference);
+ [, $newReference] = Cell::coordinateFromString($newReference);
if ($objRowDimension->getRowIndex() != $newReference) {
$objRowDimension->setRowIndex($newReference);
}
@@ -370,7 +370,7 @@ class ReferenceHelper
// Get coordinate of $pBefore
$beforeColumn = 'A';
$beforeRow = 1;
- list($beforeColumn, $beforeRow) = Cell::coordinateFromString($pBefore);
+ [$beforeColumn, $beforeRow] = Cell::coordinateFromString($pBefore);
$beforeColumnIndex = Cell::columnIndexFromString($beforeColumn);
// Clear cells if we are removing columns or rows
@@ -529,7 +529,7 @@ class ReferenceHelper
if (count($autoFilterColumns) > 0) {
sscanf($pBefore, '%[A-Z]%d', $column, $row);
$columnIndex = Cell::columnIndexFromString($column);
- list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($autoFilterRange);
+ [$rangeStart, $rangeEnd] = Cell::rangeBoundaries($autoFilterRange);
if ($columnIndex <= $rangeEnd[0]) {
if ($pNumCols < 0) {
// If we're actually deleting any columns that fall within the autofilter range,
@@ -696,7 +696,7 @@ class ReferenceHelper
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2] . '!' : '';
$toString .= $modified3 . ':' . $modified4;
- list($column, $row) = Cell::coordinateFromString($match[3]);
+ [$column, $row] = Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = Cell::columnIndexFromString(trim($column, '$')) + 100000;
$row = trim($row, '$') + 10000000;
@@ -722,7 +722,7 @@ class ReferenceHelper
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2] . '!' : '';
$toString .= $modified3;
- list($column, $row) = Cell::coordinateFromString($match[3]);
+ [$column, $row] = Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = Cell::columnIndexFromString(trim($column, '$')) + 100000;
$row = trim($row, '$') + 10000000;
@@ -770,7 +770,7 @@ class ReferenceHelper
// Is it in another worksheet? Will not have to update anything.
if (strpos($pCellRange, '!') !== false) {
return $pCellRange;
- // Is it a range or a single cell?
+ // Is it a range or a single cell?
} elseif (strpos($pCellRange, ':') === false && strpos($pCellRange, ',') === false) {
// Single cell
return $this->updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows);
@@ -778,8 +778,8 @@ class ReferenceHelper
// Range
return $this->updateCellRange($pCellRange, $pBefore, $pNumCols, $pNumRows);
}
- // Return original
- return $pCellRange;
+ // Return original
+ return $pCellRange;
}
/**
@@ -846,6 +846,7 @@ class ReferenceHelper
// Recreate range string
return Cell::buildRange($range);
}
+
throw new Exception('Only cell ranges may be passed to this method.');
}
@@ -865,10 +866,10 @@ class ReferenceHelper
{
if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {
// Get coordinate of $pBefore
- list($beforeColumn, $beforeRow) = Cell::coordinateFromString($pBefore);
+ [$beforeColumn, $beforeRow] = Cell::coordinateFromString($pBefore);
// Get coordinate of $pCellReference
- list($newColumn, $newRow) = Cell::coordinateFromString($pCellReference);
+ [$newColumn, $newRow] = Cell::coordinateFromString($pCellReference);
// Verify which parts should be updated
$updateColumn = (($newColumn[0] != '$') && ($beforeColumn[0] != '$') && (Cell::columnIndexFromString($newColumn) >= Cell::columnIndexFromString($beforeColumn)));
@@ -887,6 +888,7 @@ class ReferenceHelper
// Return new reference
return $newColumn . $newRow;
}
+
throw new Exception('Only single cell references may be passed to this method.');
}
diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php
index 9e6e0bfb..b17b886a 100644
--- a/src/PhpSpreadsheet/Settings.php
+++ b/src/PhpSpreadsheet/Settings.php
@@ -131,7 +131,7 @@ class Settings
/**
* Return the Chart Rendering Library that PhpSpreadsheet is currently configured to use (e.g. jpgraph).
*
- * @return string|null Internal reference name of the Chart Rendering Library that PhpSpreadsheet is
+ * @return null|string Internal reference name of the Chart Rendering Library that PhpSpreadsheet is
* currently configured to use
* e.g. \PhpOffice\PhpSpreadsheet\Settings::CHART_RENDERER_JPGRAPH
*/
@@ -143,7 +143,7 @@ class Settings
/**
* Return the directory path to the Chart Rendering Library that PhpSpreadsheet is currently configured to use.
*
- * @return string|null Directory Path to the Chart Rendering Library that PhpSpreadsheet is
+ * @return null|string Directory Path to the Chart Rendering Library that PhpSpreadsheet is
* currently configured to use
*/
public static function getChartRendererPath()
@@ -170,7 +170,7 @@ class Settings
/**
* Return the PDF Rendering Library that PhpSpreadsheet is currently configured to use (e.g. dompdf).
*
- * @return string|null Internal reference name of the PDF Rendering Library that PhpSpreadsheet is
+ * @return null|string Internal reference name of the PDF Rendering Library that PhpSpreadsheet is
* currently configured to use
* e.g. \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF,
* \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF
@@ -188,7 +188,7 @@ class Settings
*/
public static function setLibXmlLoaderOptions($options)
{
- if (is_null($options) && defined('LIBXML_DTDLOAD')) {
+ if ($options === null && defined('LIBXML_DTDLOAD')) {
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
}
self::$libXmlLoaderOptions = $options;
@@ -202,9 +202,9 @@ class Settings
*/
public static function getLibXmlLoaderOptions()
{
- if (is_null(self::$libXmlLoaderOptions) && defined('LIBXML_DTDLOAD')) {
+ if (self::$libXmlLoaderOptions === null && defined('LIBXML_DTDLOAD')) {
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
- } elseif (is_null(self::$libXmlLoaderOptions)) {
+ } elseif (self::$libXmlLoaderOptions === null) {
self::$libXmlLoaderOptions = true;
}
diff --git a/src/PhpSpreadsheet/Shared/CodePage.php b/src/PhpSpreadsheet/Shared/CodePage.php
index f8917fbc..4b578242 100644
--- a/src/PhpSpreadsheet/Shared/CodePage.php
+++ b/src/PhpSpreadsheet/Shared/CodePage.php
@@ -132,6 +132,7 @@ class CodePage
case 65001:
return 'UTF-8'; // Unicode (UTF-8)
}
+
throw new PhpSpreadsheetException('Unknown codepage: ' . $codePage);
}
}
diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php
index 9e0096d5..0c13c0e1 100644
--- a/src/PhpSpreadsheet/Shared/Date.php
+++ b/src/PhpSpreadsheet/Shared/Date.php
@@ -97,7 +97,7 @@ class Date
/**
* Set the Default timezone to use for dates.
*
- * @param string|DateTimeZone $timeZone The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions
+ * @param DateTimeZone|string $timeZone The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions
*
* @throws \Exception
*
@@ -132,7 +132,7 @@ class Date
/**
* Validate a timezone.
*
- * @param string|DateTimeZone $timeZone The timezone to validate, either as a timezone string or object
+ * @param DateTimeZone|string $timeZone The timezone to validate, either as a timezone string or object
*
* @throws \Exception
*
@@ -146,14 +146,15 @@ class Date
} elseif (is_string($timeZone)) {
return new DateTimeZone($timeZone);
}
+
throw new \Exception('Invalid timezone');
}
/**
* Convert a MS serialized datetime value from Excel to a PHP Date/Time object.
*
- * @param int|float $excelTimestamp MS Excel serialized date/time value
- * @param DateTimeZone|string|null $timeZone The timezone to assume for the Excel timestamp,
+ * @param float|int $excelTimestamp MS Excel serialized date/time value
+ * @param null|DateTimeZone|string $timeZone The timezone to assume for the Excel timestamp,
* if you don't want to treat it as a UTC value
* Use the default (UST) unless you absolutely need a conversion
*
@@ -193,8 +194,8 @@ class Date
/**
* Convert a MS serialized datetime value from Excel to a unix timestamp.
*
- * @param int|float $excelTimestamp MS Excel serialized date/time value
- * @param DateTimeZone|string|null $timeZone The timezone to assume for the Excel timestamp,
+ * @param float|int $excelTimestamp MS Excel serialized date/time value
+ * @param null|DateTimeZone|string $timeZone The timezone to assume for the Excel timestamp,
* if you don't want to treat it as a UTC value
* Use the default (UST) unless you absolutely need a conversion
*
@@ -213,7 +214,7 @@ class Date
*
* @param mixed $dateValue Unix Timestamp or PHP DateTime object or a string
*
- * @return float|bool Excel date/time value
+ * @return bool|float Excel date/time value
* or boolean FALSE on failure
*/
public static function PHPToExcel($dateValue)
@@ -420,7 +421,7 @@ class Date
*
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
*
- * @return float|false Excel date/time serial value
+ * @return false|float Excel date/time serial value
*/
public static function stringToExcel($dateValue)
{
diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer.php
index af5b11da..e9d387da 100644
--- a/src/PhpSpreadsheet/Shared/Escher/DgContainer.php
+++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer.php
@@ -18,7 +18,7 @@ class DgContainer
*/
private $lastSpId;
- private $spgrContainer = null;
+ private $spgrContainer;
public function getDgId()
{
diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php
index 24aa3d91..7e2c3460 100644
--- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php
+++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php
@@ -31,7 +31,7 @@ class SpgrContainer
/**
* Get the parent Shape Group Container if any.
*
- * @return \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer|null
+ * @return null|\PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer
*/
public function getParent()
{
diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php
index 3699ede4..f9bb4c70 100644
--- a/src/PhpSpreadsheet/Shared/Font.php
+++ b/src/PhpSpreadsheet/Shared/Font.php
@@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\RichText;
class Font
{
- /* Methods for resolving autosize value */
+ // Methods for resolving autosize value
const AUTOSIZE_METHOD_APPROX = 'approx';
const AUTOSIZE_METHOD_EXACT = 'exact';
@@ -219,7 +219,7 @@ class Font
* @param \PhpOffice\PhpSpreadsheet\Style\Font $font Font object
* @param RichText|string $cellText Text to calculate width
* @param int $rotation Rotation angle
- * @param \PhpOffice\PhpSpreadsheet\Style\Font|null $defaultFont Font object
+ * @param null|\PhpOffice\PhpSpreadsheet\Style\Font $defaultFont Font object
*
* @return int Column width
*/
@@ -245,6 +245,7 @@ class Font
$approximate = self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX;
if (!$approximate) {
$columnWidthAdjust = ceil(self::getTextWidthPixelsExact('n', $font, 0) * 1.07);
+
try {
// Width of text in pixels excl. padding
// and addition because Excel adds some padding, just use approx width of 'n' glyph
@@ -416,79 +417,95 @@ class Font
$bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
: ($italic ? self::ARIAL_ITALIC : self::ARIAL)
);
+
break;
case 'Calibri':
$fontFile = (
$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
: ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
);
+
break;
case 'Courier New':
$fontFile = (
$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
: ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
);
+
break;
case 'Comic Sans MS':
$fontFile = (
$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
);
+
break;
case 'Georgia':
$fontFile = (
$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
: ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
);
+
break;
case 'Impact':
$fontFile = self::IMPACT;
+
break;
case 'Liberation Sans':
$fontFile = (
$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
: ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
);
+
break;
case 'Lucida Console':
$fontFile = self::LUCIDA_CONSOLE;
+
break;
case 'Lucida Sans Unicode':
$fontFile = self::LUCIDA_SANS_UNICODE;
+
break;
case 'Microsoft Sans Serif':
$fontFile = self::MICROSOFT_SANS_SERIF;
+
break;
case 'Palatino Linotype':
$fontFile = (
$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
: ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
);
+
break;
case 'Symbol':
$fontFile = self::SYMBOL;
+
break;
case 'Tahoma':
$fontFile = (
$bold ? self::TAHOMA_BOLD : self::TAHOMA
);
+
break;
case 'Times New Roman':
$fontFile = (
$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
: ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
);
+
break;
case 'Trebuchet MS':
$fontFile = (
$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
: ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
);
+
break;
case 'Verdana':
$fontFile = (
$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
: ($italic ? self::VERDANA_ITALIC : self::VERDANA)
);
+
break;
default:
throw new PhpSpreadsheetException('Unknown font name "' . $name . '". Cannot map to TrueType font file');
@@ -578,134 +595,166 @@ class Font
case 10:
// inspection of Arial 10 workbook says 12.75pt ~17px
$rowHeight = 12.75;
+
break;
case 9:
// inspection of Arial 9 workbook says 12.00pt ~16px
$rowHeight = 12;
+
break;
case 8:
// inspection of Arial 8 workbook says 11.25pt ~15px
$rowHeight = 11.25;
+
break;
case 7:
// inspection of Arial 7 workbook says 9.00pt ~12px
$rowHeight = 9;
+
break;
case 6:
case 5:
// inspection of Arial 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25;
+
break;
case 4:
// inspection of Arial 4 workbook says 6.75pt ~9px
$rowHeight = 6.75;
+
break;
case 3:
// inspection of Arial 3 workbook says 6.00pt ~8px
$rowHeight = 6;
+
break;
case 2:
case 1:
// inspection of Arial 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25;
+
break;
default:
// use Arial 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10;
+
break;
}
+
break;
case 'Calibri':
switch ($font->getSize()) {
case 11:
// inspection of Calibri 11 workbook says 15.00pt ~20px
$rowHeight = 15;
+
break;
case 10:
// inspection of Calibri 10 workbook says 12.75pt ~17px
$rowHeight = 12.75;
+
break;
case 9:
// inspection of Calibri 9 workbook says 12.00pt ~16px
$rowHeight = 12;
+
break;
case 8:
// inspection of Calibri 8 workbook says 11.25pt ~15px
$rowHeight = 11.25;
+
break;
case 7:
// inspection of Calibri 7 workbook says 9.00pt ~12px
$rowHeight = 9;
+
break;
case 6:
case 5:
// inspection of Calibri 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25;
+
break;
case 4:
// inspection of Calibri 4 workbook says 6.75pt ~9px
$rowHeight = 6.75;
+
break;
case 3:
// inspection of Calibri 3 workbook says 6.00pt ~8px
$rowHeight = 6.00;
+
break;
case 2:
case 1:
// inspection of Calibri 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25;
+
break;
default:
// use Calibri 11 workbook as an approximation, extrapolation
$rowHeight = 15 * $font->getSize() / 11;
+
break;
}
+
break;
case 'Verdana':
switch ($font->getSize()) {
case 10:
// inspection of Verdana 10 workbook says 12.75pt ~17px
$rowHeight = 12.75;
+
break;
case 9:
// inspection of Verdana 9 workbook says 11.25pt ~15px
$rowHeight = 11.25;
+
break;
case 8:
// inspection of Verdana 8 workbook says 10.50pt ~14px
$rowHeight = 10.50;
+
break;
case 7:
// inspection of Verdana 7 workbook says 9.00pt ~12px
$rowHeight = 9.00;
+
break;
case 6:
case 5:
// inspection of Verdana 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25;
+
break;
case 4:
// inspection of Verdana 4 workbook says 6.75pt ~9px
$rowHeight = 6.75;
+
break;
case 3:
// inspection of Verdana 3 workbook says 6.00pt ~8px
$rowHeight = 6;
+
break;
case 2:
case 1:
// inspection of Verdana 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25;
+
break;
default:
// use Verdana 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10;
+
break;
}
+
break;
default:
// just use Calibri as an approximation
$rowHeight = 15 * $font->getSize() / 11;
+
break;
}
diff --git a/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php
index 6cf68ced..ec0b431d 100644
--- a/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php
+++ b/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php
@@ -139,8 +139,10 @@ class CholeskyDecomposition
return new Matrix($X, $this->m, $nx);
}
+
throw new CalculationException(Matrix::MATRIX_SPD_EXCEPTION);
}
+
throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION);
}
}
diff --git a/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php
index a7b1e2ab..00842c79 100644
--- a/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php
+++ b/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php
@@ -255,7 +255,7 @@ class EigenvalueDecomposition
$p = -$s * $s2 * $c3 * $el1 * $this->e[$l] / $dl1;
$this->e[$l] = $s * $p;
$this->d[$l] = $c * $p;
- // Check for convergence.
+ // Check for convergence.
} while (abs($this->e[$l]) > $eps * $tst1);
}
$this->d[$l] = $this->d[$l] + $f;
@@ -446,7 +446,7 @@ class EigenvalueDecomposition
$this->e[$n] = 0.0;
--$n;
$iter = 0;
- // Two roots found
+ // Two roots found
} elseif ($l == $n - 1) {
$w = $this->H[$n][$n - 1] * $this->H[$n - 1][$n];
$p = ($this->H[$n - 1][$n - 1] - $this->H[$n][$n]) / 2.0;
@@ -494,7 +494,7 @@ class EigenvalueDecomposition
$this->V[$i][$n - 1] = $q * $z + $p * $this->V[$i][$n];
$this->V[$i][$n] = $q * $this->V[$i][$n] - $p * $z;
}
- // Complex pair
+ // Complex pair
} else {
$this->d[$n - 1] = $x + $p;
$this->d[$n] = $x + $p;
@@ -503,7 +503,7 @@ class EigenvalueDecomposition
}
$n = $n - 2;
$iter = 0;
- // No convergence yet
+ // No convergence yet
} else {
// Form shift
$x = $this->H[$n][$n];
@@ -667,7 +667,7 @@ class EigenvalueDecomposition
} else {
$this->H[$i][$n] = -$r / ($eps * $norm);
}
- // Solve real equations
+ // Solve real equations
} else {
$x = $this->H[$i][$i + 1];
$y = $this->H[$i + 1][$i];
@@ -689,7 +689,7 @@ class EigenvalueDecomposition
}
}
}
- // Complex vector
+ // Complex vector
} elseif ($q < 0) {
$l = $n - 1;
// Last vector component imaginary so matrix is triangular
diff --git a/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php
index b72a56c7..e275fcc4 100644
--- a/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php
+++ b/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php
@@ -233,6 +233,7 @@ class LUDecomposition
return $d;
}
+
throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION);
}
@@ -277,8 +278,10 @@ class LUDecomposition
return $X;
}
+
throw new CalculationException(self::MATRIX_SINGULAR_EXCEPTION);
}
+
throw new CalculationException(self::MATRIX_SQUARE_EXCEPTION);
}
}
diff --git a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php
index 9a91183c..2d1d3fdb 100644
--- a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php
+++ b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php
@@ -62,18 +62,21 @@ class Matrix
$this->m = count($args[0]);
$this->n = count($args[0][0]);
$this->A = $args[0];
+
break;
//Square matrix - n x n
case 'integer':
$this->m = $args[0];
$this->n = $args[0];
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
+
break;
//Rectangular matrix - m x n
case 'integer,integer':
$this->m = $args[0];
$this->n = $args[1];
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
+
break;
//Rectangular matrix - m x n initialized from packed array
case 'array,integer':
@@ -92,6 +95,7 @@ class Matrix
} else {
throw new CalculationException(self::ARRAY_LENGTH_EXCEPTION);
}
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -167,7 +171,7 @@ class Matrix
switch ($match) {
//A($i0...; $j0...)
case 'integer,integer':
- list($i0, $j0) = $args;
+ [$i0, $j0] = $args;
if ($i0 >= 0) {
$m = $this->m - $i0;
} else {
@@ -189,7 +193,7 @@ class Matrix
break;
//A($i0...$iF; $j0...$jF)
case 'integer,integer,integer,integer':
- list($i0, $iF, $j0, $jF) = $args;
+ [$i0, $iF, $j0, $jF] = $args;
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) {
$m = $iF - $i0;
} else {
@@ -211,7 +215,7 @@ class Matrix
break;
//$R = array of row indices; $C = array of column indices
case 'array,array':
- list($RL, $CL) = $args;
+ [$RL, $CL] = $args;
if (count($RL) > 0) {
$m = count($RL);
} else {
@@ -233,7 +237,7 @@ class Matrix
break;
//A($i0...$iF); $CL = array of column indices
case 'integer,integer,array':
- list($i0, $iF, $CL) = $args;
+ [$i0, $iF, $CL] = $args;
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) {
$m = $iF - $i0;
} else {
@@ -255,7 +259,7 @@ class Matrix
break;
//$RL = array of row indices
case 'array,integer,integer':
- list($RL, $j0, $jF) = $args;
+ [$RL, $j0, $jF] = $args;
if (count($RL) > 0) {
$m = count($RL);
} else {
@@ -299,8 +303,10 @@ class Matrix
if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) {
return true;
}
+
throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION);
}
+
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
@@ -380,6 +386,7 @@ class Matrix
return $this->getMatrix($i0, 0, $i0 + 1, $this->n);
}
+
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
@@ -402,6 +409,7 @@ class Matrix
return $this->getMatrix(0, $j0, $this->m, $j0 + 1);
}
+
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
@@ -476,9 +484,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -493,6 +503,7 @@ class Matrix
return $M;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -517,9 +528,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -548,6 +561,7 @@ class Matrix
return $this;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -572,9 +586,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -589,6 +605,7 @@ class Matrix
return $M;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -613,9 +630,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -644,6 +663,7 @@ class Matrix
return $this;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -669,9 +689,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -686,6 +708,7 @@ class Matrix
return $M;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -711,9 +734,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -742,6 +767,7 @@ class Matrix
return $this;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -767,9 +793,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -803,6 +831,7 @@ class Matrix
return $M;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -828,9 +857,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -845,6 +876,7 @@ class Matrix
return $M;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -870,9 +902,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -887,6 +921,7 @@ class Matrix
return $M;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -912,9 +947,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -929,6 +966,7 @@ class Matrix
return $M;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -971,6 +1009,7 @@ class Matrix
return $C;
}
+
throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION);
case 'array':
$B = new self($args[0]);
@@ -988,6 +1027,7 @@ class Matrix
return $C;
}
+
throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION);
case 'integer':
$C = new self($this->A);
@@ -1045,9 +1085,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -1076,6 +1118,7 @@ class Matrix
return $this;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
@@ -1100,9 +1143,11 @@ class Matrix
} else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
}
+
break;
case 'array':
$M = new self($args[0]);
+
break;
default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@@ -1117,6 +1162,7 @@ class Matrix
return $this;
}
+
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
}
diff --git a/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php
index f3e9d6ed..a461ade4 100644
--- a/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php
+++ b/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php
@@ -247,8 +247,10 @@ class QRDecomposition
return $X->getMatrix(0, $this->n - 1, 0, $nx);
}
+
throw new CalculationException(self::MATRIX_RANK_EXCEPTION);
}
+
throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION);
}
}
diff --git a/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php
index 8225ab07..a2fd69d5 100644
--- a/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php
+++ b/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php
@@ -263,6 +263,7 @@ class SingularValueDecomposition
}
if (abs($e[$k]) <= $eps * (abs($this->s[$k]) + abs($this->s[$k + 1]))) {
$e[$k] = 0.0;
+
break;
}
}
@@ -276,6 +277,7 @@ class SingularValueDecomposition
$t = ($ks != $p ? abs($e[$ks]) : 0.) + ($ks != $k + 1 ? abs($e[$ks - 1]) : 0.);
if (abs($this->s[$ks]) <= $eps * $t) {
$this->s[$ks] = 0.0;
+
break;
}
}
@@ -313,6 +315,7 @@ class SingularValueDecomposition
}
}
}
+
break;
// Split at negligible s(k).
case 2:
@@ -333,6 +336,7 @@ class SingularValueDecomposition
}
}
}
+
break;
// Perform one qr step.
case 3:
@@ -392,6 +396,7 @@ class SingularValueDecomposition
}
$e[$p - 2] = $f;
$iter = $iter + 1;
+
break;
// Convergence.
case 4:
@@ -430,6 +435,7 @@ class SingularValueDecomposition
}
$iter = 0;
--$p;
+
break;
} // end switch
} // end while
diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php
index 4f293659..686fff83 100644
--- a/src/PhpSpreadsheet/Shared/OLE.php
+++ b/src/PhpSpreadsheet/Shared/OLE.php
@@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Shared;
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
+// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
@@ -245,7 +245,7 @@ class OLE
*/
private static function _readInt1($fh)
{
- list(, $tmp) = unpack('c', fread($fh, 1));
+ [, $tmp] = unpack('c', fread($fh, 1));
return $tmp;
}
@@ -259,7 +259,7 @@ class OLE
*/
private static function _readInt2($fh)
{
- list(, $tmp) = unpack('v', fread($fh, 2));
+ [, $tmp] = unpack('v', fread($fh, 2));
return $tmp;
}
@@ -273,7 +273,7 @@ class OLE
*/
private static function _readInt4($fh)
{
- list(, $tmp) = unpack('V', fread($fh, 4));
+ [, $tmp] = unpack('V', fread($fh, 4));
return $tmp;
}
@@ -301,12 +301,15 @@ class OLE
case self::OLE_PPS_TYPE_ROOT:
$pps = new OLE\PPS_Root(null, null, []);
$this->root = $pps;
+
break;
case self::OLE_PPS_TYPE_DIR:
$pps = new OLE\PPS(null, null, null, null, null, null, null, null, null, []);
+
break;
case self::OLE_PPS_TYPE_FILE:
$pps = new OLE\PPS\File($name);
+
break;
default:
continue;
@@ -543,8 +546,8 @@ class OLE
// factor used for separating numbers into 4 bytes parts
$factor = pow(2, 32);
- list(, $high_part) = unpack('V', substr($string, 4, 4));
- list(, $low_part) = unpack('V', substr($string, 0, 4));
+ [, $high_part] = unpack('V', substr($string, 4, 4));
+ [, $low_part] = unpack('V', substr($string, 0, 4));
$big_date = ($high_part * $factor) + $low_part;
// translate to seconds
diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php
index c5b91999..e53f2575 100644
--- a/src/PhpSpreadsheet/Shared/OLE/PPS.php
+++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php
@@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Shared\OLE;
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
+// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php
index ffaf7e0c..240ed99a 100644
--- a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php
+++ b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php
@@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS;
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
+// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php
index 7e411397..1e1487b9 100644
--- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php
+++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php
@@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS;
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
+// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
@@ -38,7 +38,7 @@ class Root extends PPS
*
* @var string
*/
- protected $tempDirectory = null;
+ protected $tempDirectory;
/**
* @param int $time_1st A timestamp
@@ -59,7 +59,7 @@ class Root extends PPS
* If a resource pointer to a stream created by fopen() is passed
* it will be used, but you have to close such stream by yourself.
*
- * @param string|resource $filename the name of the file or stream where to save the OLE container
+ * @param resource|string $filename the name of the file or stream where to save the OLE container
*
* @throws WriterException
*
@@ -98,7 +98,7 @@ class Root extends PPS
$aList = [];
PPS::_savePpsSetPnt($aList, [$this]);
// calculate values for header
- list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo);
+ [$iSBDcnt, $iBBcnt, $iPPScnt] = $this->_calcSize($aList); //, $rhInfo);
// Save Header
$this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt);
@@ -129,7 +129,7 @@ class Root extends PPS
public function _calcSize(&$raList)
{
// Calculate Basic Setting
- list($iSBDcnt, $iBBcnt, $iPPScnt) = [0, 0, 0];
+ [$iSBDcnt, $iBBcnt, $iPPScnt] = [0, 0, 0];
$iSmallLen = 0;
$iSBcnt = 0;
$iCount = count($raList);
diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php
index 8d002024..b145cfc2 100644
--- a/src/PhpSpreadsheet/Shared/OLERead.php
+++ b/src/PhpSpreadsheet/Shared/OLERead.php
@@ -34,9 +34,9 @@ class OLERead
const START_BLOCK_POS = 0x74;
const SIZE_POS = 0x78;
- public $wrkbook = null;
- public $summaryInformation = null;
- public $documentSummaryInformation = null;
+ public $wrkbook;
+ public $summaryInformation;
+ public $documentSummaryInformation;
/**
* Read the file.
diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php
index 968de91c..068ce99b 100644
--- a/src/PhpSpreadsheet/Shared/StringHelper.php
+++ b/src/PhpSpreadsheet/Shared/StringHelper.php
@@ -133,7 +133,7 @@ class StringHelper
"\x1BNz" => 'Å“', // 156 in CP1252
"\x1B)>" => 'ž', // 158 in CP1252
"\x1B)?" => 'Ÿ', // 159 in CP1252
- "\x1B*0" => 'Â ', // 160 in CP1252
+ "\x1B*0" => ' ', // 160 in CP1252
"\x1BN!" => '¡', // 161 in CP1252
"\x1BN\"" => '¢', // 162 in CP1252
"\x1BN#" => '£', // 163 in CP1252
diff --git a/src/PhpSpreadsheet/Shared/Xls.php b/src/PhpSpreadsheet/Shared/Xls.php
index 6b3740c7..f20e9310 100644
--- a/src/PhpSpreadsheet/Shared/Xls.php
+++ b/src/PhpSpreadsheet/Shared/Xls.php
@@ -211,7 +211,7 @@ class Xls
*/
public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height)
{
- list($column, $row) = Cell::coordinateFromString($coordinates);
+ [$column, $row] = Cell::coordinateFromString($coordinates);
$col_start = Cell::columnIndexFromString($column) - 1;
$row_start = $row - 1;
diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php
index a0516fe1..d0c8a965 100644
--- a/src/PhpSpreadsheet/Spreadsheet.php
+++ b/src/PhpSpreadsheet/Spreadsheet.php
@@ -137,13 +137,13 @@ class Spreadsheet
public function setMacrosCode($macroCode)
{
$this->macrosCode = $macroCode;
- $this->setHasMacros(!is_null($macroCode));
+ $this->setHasMacros($macroCode !== null);
}
/**
* Return the macros code.
*
- * @return string|null
+ * @return null|string
*/
public function getMacrosCode()
{
@@ -153,7 +153,7 @@ class Spreadsheet
/**
* Set the macros certificate.
*
- * @param string|null $certificate
+ * @param null|string $certificate
*/
public function setMacrosCertificate($certificate)
{
@@ -167,13 +167,13 @@ class Spreadsheet
*/
public function hasMacrosCertificate()
{
- return !is_null($this->macrosCertificate);
+ return $this->macrosCertificate !== null;
}
/**
* Return the macros certificate.
*
- * @return string|null
+ * @return null|string
*/
public function getMacrosCertificate()
{
@@ -198,7 +198,7 @@ class Spreadsheet
*/
public function setRibbonXMLData($target, $xmlData)
{
- if (!is_null($target) && !is_null($xmlData)) {
+ if ($target !== null && $xmlData !== null) {
$this->ribbonXMLData = ['target' => $target, 'data' => $xmlData];
} else {
$this->ribbonXMLData = null;
@@ -221,12 +221,14 @@ class Spreadsheet
switch ($what) {
case 'all':
$returnData = $this->ribbonXMLData;
+
break;
case 'target':
case 'data':
if (is_array($this->ribbonXMLData) && isset($this->ribbonXMLData[$what])) {
$returnData = $this->ribbonXMLData[$what];
}
+
break;
}
@@ -241,7 +243,7 @@ class Spreadsheet
*/
public function setRibbonBinObjects($BinObjectsNames, $BinObjectsData)
{
- if (!is_null($BinObjectsNames) && !is_null($BinObjectsData)) {
+ if ($BinObjectsNames !== null && $BinObjectsData !== null) {
$this->ribbonBinObjects = ['names' => $BinObjectsNames, 'data' => $BinObjectsData];
} else {
$this->ribbonBinObjects = null;
@@ -276,6 +278,7 @@ class Spreadsheet
if (is_array($this->ribbonBinObjects) && isset($this->ribbonBinObjects[$what])) {
$ReturnData = $this->ribbonBinObjects[$what];
}
+
break;
case 'types':
if (is_array($this->ribbonBinObjects) &&
@@ -285,6 +288,7 @@ class Spreadsheet
} else {
$ReturnData = []; // the caller want an array... not null if empty
}
+
break;
}
@@ -298,7 +302,7 @@ class Spreadsheet
*/
public function hasRibbon()
{
- return !is_null($this->ribbonXMLData);
+ return $this->ribbonXMLData !== null;
}
/**
@@ -308,7 +312,7 @@ class Spreadsheet
*/
public function hasRibbonBinObjects()
{
- return !is_null($this->ribbonBinObjects);
+ return $this->ribbonBinObjects !== null;
}
/**
@@ -462,7 +466,7 @@ class Spreadsheet
/**
* Create sheet and add it to this workbook.
*
- * @param int|null $sheetIndex Index where sheet should go (0,1,..., or null for last)
+ * @param null|int $sheetIndex Index where sheet should go (0,1,..., or null for last)
*
* @throws Exception
*
@@ -492,7 +496,7 @@ class Spreadsheet
* Add sheet.
*
* @param Worksheet $pSheet
- * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
+ * @param null|int $iSheetIndex Index where sheet should go (0,1,..., or null for last)
*
* @throws Exception
*
@@ -570,6 +574,7 @@ class Spreadsheet
{
if (!isset($this->workSheetCollection[$pIndex])) {
$numSheets = $this->getSheetCount();
+
throw new Exception(
"Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}."
);
@@ -738,7 +743,7 @@ class Spreadsheet
* Add external sheet.
*
* @param Worksheet $pSheet External sheet to add
- * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
+ * @param null|int $iSheetIndex Index where sheet should go (0,1,..., or null for last)
*
* @throws Exception
*
@@ -804,9 +809,9 @@ class Spreadsheet
* Get named range.
*
* @param string $namedRange
- * @param Worksheet|null $pSheet Scope. Use null for global scope
+ * @param null|Worksheet $pSheet Scope. Use null for global scope
*
- * @return NamedRange|null
+ * @return null|NamedRange
*/
public function getNamedRange($namedRange, Worksheet $pSheet = null)
{
@@ -831,7 +836,7 @@ class Spreadsheet
* Remove named range.
*
* @param string $namedRange
- * @param Worksheet|null $pSheet scope: use null for global scope
+ * @param null|Worksheet $pSheet scope: use null for global scope
*
* @return Spreadsheet
*/
@@ -917,7 +922,7 @@ class Spreadsheet
*
* @param string $pValue
*
- * @return Style|false
+ * @return false|Style
*/
public function getCellXfByHashCode($pValue)
{
@@ -954,6 +959,7 @@ class Spreadsheet
if (isset($this->cellXfCollection[0])) {
return $this->cellXfCollection[0];
}
+
throw new Exception('No default style found for this workbook');
}
@@ -1037,7 +1043,7 @@ class Spreadsheet
*
* @param string $pValue
*
- * @return Style|false
+ * @return false|Style
*/
public function getCellStyleXfByHashCode($pValue)
{
diff --git a/src/PhpSpreadsheet/Style.php b/src/PhpSpreadsheet/Style.php
index c37bf313..2fed829b 100644
--- a/src/PhpSpreadsheet/Style.php
+++ b/src/PhpSpreadsheet/Style.php
@@ -199,7 +199,7 @@ class Style extends Style\Supervisor implements IComparable
$rangeA = $pRange;
$rangeB = $pRange;
} else {
- list($rangeA, $rangeB) = explode(':', $pRange);
+ [$rangeA, $rangeB] = explode(':', $pRange);
}
// Calculate range outer borders
@@ -313,6 +313,7 @@ class Style extends Style\Supervisor implements IComparable
} else {
unset($regionStyles['borders'][$innerEdge]);
}
+
break;
case 'left':
case 'right':
@@ -322,6 +323,7 @@ class Style extends Style\Supervisor implements IComparable
} else {
unset($regionStyles['borders'][$innerEdge]);
}
+
break;
}
}
@@ -351,6 +353,7 @@ class Style extends Style\Supervisor implements IComparable
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
$oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true;
}
+
break;
case 'ROW':
$oldXfIndexes = [];
@@ -361,6 +364,7 @@ class Style extends Style\Supervisor implements IComparable
$oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true;
}
}
+
break;
case 'CELL':
$oldXfIndexes = [];
@@ -369,6 +373,7 @@ class Style extends Style\Supervisor implements IComparable
$oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true;
}
}
+
break;
}
@@ -397,6 +402,7 @@ class Style extends Style\Supervisor implements IComparable
$oldXfIndex = $columnDimension->getXfIndex();
$columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
}
+
break;
case 'ROW':
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
@@ -405,6 +411,7 @@ class Style extends Style\Supervisor implements IComparable
0 : $rowDimension->getXfIndex(); // row without explicit style should be formatted based on default style
$rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
}
+
break;
case 'CELL':
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
@@ -414,6 +421,7 @@ class Style extends Style\Supervisor implements IComparable
$cell->setXfIndex($newXfIndexes[$oldXfIndex]);
}
}
+
break;
}
} else {
diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php
index 58e1fbe0..9b284a04 100644
--- a/src/PhpSpreadsheet/Style/Alignment.php
+++ b/src/PhpSpreadsheet/Style/Alignment.php
@@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Alignment extends Supervisor implements IComparable
{
- /* Horizontal alignment styles */
+ // Horizontal alignment styles
const HORIZONTAL_GENERAL = 'general';
const HORIZONTAL_LEFT = 'left';
const HORIZONTAL_RIGHT = 'right';
@@ -17,14 +17,14 @@ class Alignment extends Supervisor implements IComparable
const HORIZONTAL_FILL = 'fill';
const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only
- /* Vertical alignment styles */
+ // Vertical alignment styles
const VERTICAL_BOTTOM = 'bottom';
const VERTICAL_TOP = 'top';
const VERTICAL_CENTER = 'center';
const VERTICAL_JUSTIFY = 'justify';
const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only
- /* Read order */
+ // Read order
const READORDER_CONTEXT = 0;
const READORDER_LTR = 1;
const READORDER_RTL = 2;
diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php
index ea05ad54..fdc251d7 100644
--- a/src/PhpSpreadsheet/Style/Border.php
+++ b/src/PhpSpreadsheet/Style/Border.php
@@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Border extends Supervisor implements IComparable
{
- /* Border style */
+ // Border style
const BORDER_NONE = 'none';
const BORDER_DASHDOT = 'dashDot';
const BORDER_DASHDOTDOT = 'dashDotDot';
@@ -180,7 +180,7 @@ class Border extends Supervisor implements IComparable
/**
* Set Border style.
*
- * @param string|bool $pValue
+ * @param bool|string $pValue
* When passing a boolean, FALSE equates Border::BORDER_NONE
* and TRUE to Border::BORDER_MEDIUM
*
diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php
index 84a141d4..da1064d6 100644
--- a/src/PhpSpreadsheet/Style/Borders.php
+++ b/src/PhpSpreadsheet/Style/Borders.php
@@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Borders extends Supervisor implements IComparable
{
- /* Diagonal directions */
+ // Diagonal directions
const DIAGONAL_NONE = 0;
const DIAGONAL_UP = 1;
const DIAGONAL_DOWN = 2;
diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php
index 42086b98..e30916a7 100644
--- a/src/PhpSpreadsheet/Style/Color.php
+++ b/src/PhpSpreadsheet/Style/Color.php
@@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Color extends Supervisor implements IComparable
{
- /* Colors */
+ // Colors
const COLOR_BLACK = 'FF000000';
const COLOR_WHITE = 'FFFFFFFF';
const COLOR_RED = 'FFFF0000';
@@ -31,7 +31,7 @@ class Color extends Supervisor implements IComparable
*
* @var string
*/
- protected $argb = null;
+ protected $argb;
/**
* Parent property name.
@@ -337,7 +337,7 @@ class Color extends Supervisor implements IComparable
$pIndex = (int) $pIndex;
// Indexed colors
- if (is_null(self::$indexedColors)) {
+ if (self::$indexedColors === null) {
self::$indexedColors = [
1 => 'FF000000', // System Colour #1 - Black
2 => 'FFFFFFFF', // System Colour #2 - White
diff --git a/src/PhpSpreadsheet/Style/Conditional.php b/src/PhpSpreadsheet/Style/Conditional.php
index c951cfa4..42cedf91 100644
--- a/src/PhpSpreadsheet/Style/Conditional.php
+++ b/src/PhpSpreadsheet/Style/Conditional.php
@@ -8,14 +8,14 @@ use PhpOffice\PhpSpreadsheet\Style;
class Conditional implements IComparable
{
- /* Condition types */
+ // Condition types
const CONDITION_NONE = 'none';
const CONDITION_CELLIS = 'cellIs';
const CONDITION_CONTAINSTEXT = 'containsText';
const CONDITION_EXPRESSION = 'expression';
const CONDITION_CONTAINSBLANKS = 'containsBlanks';
- /* Operator types */
+ // Operator types
const OPERATOR_NONE = '';
const OPERATOR_BEGINSWITH = 'beginsWith';
const OPERATOR_ENDSWITH = 'endsWith';
diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php
index 5f003cd7..d1a3edb9 100644
--- a/src/PhpSpreadsheet/Style/Fill.php
+++ b/src/PhpSpreadsheet/Style/Fill.php
@@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Fill extends Supervisor implements IComparable
{
- /* Fill types */
+ // Fill types
const FILL_NONE = 'none';
const FILL_SOLID = 'solid';
const FILL_GRADIENT_LINEAR = 'linear';
diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php
index 8de92b33..3336ce25 100644
--- a/src/PhpSpreadsheet/Style/Font.php
+++ b/src/PhpSpreadsheet/Style/Font.php
@@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Font extends Supervisor implements IComparable
{
- /* Underline types */
+ // Underline types
const UNDERLINE_NONE = 'none';
const UNDERLINE_DOUBLE = 'double';
const UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting';
@@ -430,7 +430,7 @@ class Font extends Supervisor implements IComparable
/**
* Set Underline.
*
- * @param string|bool $pValue \PhpOffice\PhpSpreadsheet\Style\Font underline type
+ * @param bool|string $pValue \PhpOffice\PhpSpreadsheet\Style\Font underline type
* If a boolean is passed, then TRUE equates to UNDERLINE_SINGLE,
* false equates to UNDERLINE_NONE
*
diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php
index 8ba018de..d4f196cb 100644
--- a/src/PhpSpreadsheet/Style/NumberFormat.php
+++ b/src/PhpSpreadsheet/Style/NumberFormat.php
@@ -10,7 +10,7 @@ use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
class NumberFormat extends Supervisor implements IComparable
{
- /* Pre-defined formats */
+ // Pre-defined formats
const FORMAT_GENERAL = 'General';
const FORMAT_TEXT = '@';
@@ -253,7 +253,7 @@ class NumberFormat extends Supervisor implements IComparable
// KOR fmt 55: "yyyy/mm/dd"
// Built-in format codes
- if (is_null(self::$builtInFormats)) {
+ if (self::$builtInFormats === null) {
self::$builtInFormats = [];
// General
@@ -340,7 +340,7 @@ class NumberFormat extends Supervisor implements IComparable
*
* @param string $formatCode
*
- * @return int|bool
+ * @return bool|int
*/
public static function builtInFormatCodeIndex($formatCode)
{
@@ -601,6 +601,7 @@ class NumberFormat extends Supervisor implements IComparable
switch (count($sections)) {
case 1:
$format = $sections[0];
+
break;
case 2:
$format = ($value >= 0) ? $sections[0] : $sections[1];
@@ -621,6 +622,7 @@ class NumberFormat extends Supervisor implements IComparable
default:
// something is wrong, just use first section
$format = $sections[0];
+
break;
}
@@ -722,7 +724,7 @@ class NumberFormat extends Supervisor implements IComparable
// Currency or Accounting
$currencyFormat = $m[0];
$currencyCode = $m[1];
- list($currencyCode) = explode('-', $currencyCode);
+ [$currencyCode] = explode('-', $currencyCode);
if ($currencyCode == '') {
$currencyCode = StringHelper::getCurrencyCode();
}
@@ -736,7 +738,7 @@ class NumberFormat extends Supervisor implements IComparable
// Additional formatting provided by callback function
if ($callBack !== null) {
- list($writerInstance, $function) = $callBack;
+ [$writerInstance, $function] = $callBack;
$value = $writerInstance->$function($value, $formatColor);
}
diff --git a/src/PhpSpreadsheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet.php
index 469532a8..acda2fc9 100644
--- a/src/PhpSpreadsheet/Worksheet.php
+++ b/src/PhpSpreadsheet/Worksheet.php
@@ -8,12 +8,12 @@ use PhpOffice\PhpSpreadsheet\Collection\CellsFactory;
class Worksheet implements IComparable
{
- /* Break types */
+ // Break types
const BREAK_NONE = 0;
const BREAK_ROW = 1;
const BREAK_COLUMN = 2;
- /* Sheet state */
+ // Sheet state
const SHEETSTATE_VISIBLE = 'visible';
const SHEETSTATE_HIDDEN = 'hidden';
const SHEETSTATE_VERYHIDDEN = 'veryHidden';
@@ -65,14 +65,14 @@ class Worksheet implements IComparable
*
* @var Worksheet\ColumnDimension
*/
- private $defaultColumnDimension = null;
+ private $defaultColumnDimension;
/**
* Collection of drawings.
*
* @var Worksheet\BaseDrawing[]
*/
- private $drawingCollection = null;
+ private $drawingCollection;
/**
* Collection of Chart objects.
@@ -303,7 +303,7 @@ class Worksheet implements IComparable
*
* @var string
*/
- private $codeName = null;
+ private $codeName;
/**
* Create a new worksheet.
@@ -524,14 +524,14 @@ class Worksheet implements IComparable
* Add chart.
*
* @param Chart $pChart
- * @param int|null $iChartIndex Index where chart should go (0,1,..., or null for last)
+ * @param null|int $iChartIndex Index where chart should go (0,1,..., or null for last)
*
* @return Chart
*/
public function addChart(Chart $pChart, $iChartIndex = null)
{
$pChart->setWorksheet($this);
- if (is_null($iChartIndex)) {
+ if ($iChartIndex === null) {
$this->chartCollection[] = $pChart;
} else {
// Insert the chart at the requested index
@@ -558,7 +558,7 @@ class Worksheet implements IComparable
*
* @throws Exception
*
- * @return false|Chart
+ * @return Chart|false
*/
public function getChartByIndex($index)
{
@@ -566,7 +566,7 @@ class Worksheet implements IComparable
if ($chartCount == 0) {
return false;
}
- if (is_null($index)) {
+ if ($index === null) {
$index = --$chartCount;
}
if (!isset($this->chartCollection[$index])) {
@@ -600,7 +600,7 @@ class Worksheet implements IComparable
*
* @throws Exception
*
- * @return false|Chart
+ * @return Chart|false
*/
public function getChartByName($chartName)
{
@@ -1287,6 +1287,7 @@ class Worksheet implements IComparable
if (!$namedRange->getLocalOnly()) {
return $namedRange->getWorksheet()->cellExists($pCoordinate);
}
+
throw new Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
}
} else {
@@ -1302,11 +1303,11 @@ class Worksheet implements IComparable
} elseif (strpos($pCoordinate, '$') !== false) {
throw new Exception('Cell coordinate must not be absolute.');
}
- // Coordinates
- $aCoordinates = Cell::coordinateFromString($pCoordinate);
+ // Coordinates
+ $aCoordinates = Cell::coordinateFromString($pCoordinate);
- // Cell exists?
- return $this->cellCollection->has($pCoordinate);
+ // Cell exists?
+ return $this->cellCollection->has($pCoordinate);
}
/**
@@ -1504,7 +1505,7 @@ class Worksheet implements IComparable
*/
public function getStyleByColumnAndRow($pColumn, $pRow, $pColumn2 = null, $pRow2 = null)
{
- if (!is_null($pColumn2) && !is_null($pRow2)) {
+ if ($pColumn2 !== null && $pRow2 !== null) {
$cellRange = Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->getStyle($cellRange);
@@ -1542,7 +1543,7 @@ class Worksheet implements IComparable
}
// Calculate range outer borders
- list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($pRange . ':' . $pRange);
+ [$rangeStart, $rangeEnd] = Cell::rangeBoundaries($pRange . ':' . $pRange);
// Make sure we can loop upwards on rows and columns
if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
@@ -1582,7 +1583,7 @@ class Worksheet implements IComparable
}
// Calculate range outer borders
- list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($pRange . ':' . $pRange);
+ [$rangeStart, $rangeEnd] = Cell::rangeBoundaries($pRange . ':' . $pRange);
// Make sure we can loop upwards on rows and columns
if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
@@ -1898,7 +1899,7 @@ class Worksheet implements IComparable
/**
* Set AutoFilter.
*
- * @param Worksheet\AutoFilter|string $pValue
+ * @param string|Worksheet\AutoFilter $pValue
* A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility
*
* @throws Exception
@@ -2071,6 +2072,7 @@ class Worksheet implements IComparable
if ($pBefore >= 0) {
return $this->insertNewColumnBefore(Cell::stringFromColumnIndex($pBefore), $pNumCols);
}
+
throw new Exception('Columns can only be inserted before at least column A (0).');
}
@@ -2144,6 +2146,7 @@ class Worksheet implements IComparable
if ($pColumn >= 0) {
return $this->removeColumn(Cell::stringFromColumnIndex($pColumn), $pNumCols);
}
+
throw new Exception('Columns to be deleted should at least start from column 0');
}
@@ -2398,7 +2401,7 @@ class Worksheet implements IComparable
$pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate);
if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) {
- list($first) = Cell::splitRange($pCoordinate);
+ [$first] = Cell::splitRange($pCoordinate);
$this->activeCell = $first[0];
} else {
$this->activeCell = $pCoordinate;
@@ -2467,7 +2470,7 @@ class Worksheet implements IComparable
}
// start coordinate
- list($startColumn, $startRow) = Cell::coordinateFromString($startCell);
+ [$startColumn, $startRow] = Cell::coordinateFromString($startCell);
// Loop through $source
foreach ($source as $rowData) {
@@ -2509,7 +2512,7 @@ class Worksheet implements IComparable
// Returnvalue
$returnValue = [];
// Identify the range that we need to extract from the worksheet
- list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($pRange);
+ [$rangeStart, $rangeEnd] = Cell::rangeBoundaries($pRange);
$minCol = Cell::stringFromColumnIndex($rangeStart[0] - 1);
$minRow = $rangeStart[1];
$maxCol = Cell::stringFromColumnIndex($rangeEnd[0] - 1);
@@ -2737,7 +2740,7 @@ class Worksheet implements IComparable
* Set hyperlink.
*
* @param string $pCellCoordinate Cell coordinate to insert hyperlink, eg: 'A1'
- * @param Cell\Hyperlink|null $pHyperlink
+ * @param null|Cell\Hyperlink $pHyperlink
*
* @return Worksheet
*/
@@ -2796,7 +2799,7 @@ class Worksheet implements IComparable
* Set data validation.
*
* @param string $pCellCoordinate Cell coordinate to insert data validation, eg: 'A1'
- * @param Cell\DataValidation|null $pDataValidation
+ * @param null|Cell\DataValidation $pDataValidation
*
* @return Worksheet
*/
@@ -3029,6 +3032,6 @@ class Worksheet implements IComparable
*/
public function hasCodeName()
{
- return !(is_null($this->codeName));
+ return !($this->codeName === null);
}
}
diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php
index 03b905c2..303f1b85 100644
--- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php
+++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php
@@ -93,7 +93,7 @@ class AutoFilter
// Uppercase coordinate
$cellAddress = explode('!', strtoupper($pRange));
if (count($cellAddress) > 1) {
- list($worksheet, $pRange) = $cellAddress;
+ [$worksheet, $pRange] = $cellAddress;
}
if (strpos($pRange, ':') !== false) {
@@ -109,7 +109,7 @@ class AutoFilter
$this->columns = [];
} else {
// Discard any column rules that are no longer valid within this range
- list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($this->range);
+ [$rangeStart, $rangeEnd] = Cell::rangeBoundaries($this->range);
foreach ($this->columns as $key => $value) {
$colIndex = Cell::columnIndexFromString($key);
if (($rangeStart[0] > $colIndex) || ($rangeEnd[0] < $colIndex)) {
@@ -149,7 +149,7 @@ class AutoFilter
}
$columnIndex = Cell::columnIndexFromString($column);
- list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($this->range);
+ [$rangeStart, $rangeEnd] = Cell::rangeBoundaries($this->range);
if (($rangeStart[0] > $columnIndex) || ($rangeEnd[0] < $columnIndex)) {
throw new PhpSpreadsheetException('Column is outside of current autofilter range.');
}
@@ -202,7 +202,7 @@ class AutoFilter
*/
public function getColumnByOffset($pColumnOffset)
{
- list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($this->range);
+ [$rangeStart, $rangeEnd] = Cell::rangeBoundaries($this->range);
$pColumn = Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1);
return $this->getColumn($pColumn);
@@ -378,33 +378,42 @@ class AutoFilter
switch ($rule['operator']) {
case AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL:
$retVal = ($cellValue == $rule['value']);
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL:
$retVal = ($cellValue != $rule['value']);
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN:
$retVal = ($cellValue > $rule['value']);
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL:
$retVal = ($cellValue >= $rule['value']);
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN:
$retVal = ($cellValue < $rule['value']);
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL:
$retVal = ($cellValue <= $rule['value']);
+
break;
}
} elseif ($rule['value'] == '') {
switch ($rule['operator']) {
case AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL:
$retVal = (($cellValue == '') || ($cellValue === null));
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL:
$retVal = (($cellValue != '') && ($cellValue !== null));
+
break;
default:
$retVal = true;
+
break;
}
} else {
@@ -420,9 +429,11 @@ class AutoFilter
if ($returnVal) {
return $returnVal;
}
+
break;
case AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND:
$returnVal = $returnVal && $retVal;
+
break;
}
}
@@ -483,27 +494,35 @@ class AutoFilter
switch ($dynamicRuleType) {
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK:
$baseDate = strtotime('-7 days', $baseDate);
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK:
$baseDate = strtotime('-7 days', $baseDate);
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH:
$baseDate = strtotime('-1 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH:
$baseDate = strtotime('+1 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER:
$baseDate = strtotime('-3 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER:
$baseDate = strtotime('+3 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR:
$baseDate = strtotime('-1 year', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR:
$baseDate = strtotime('+1 year', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
+
break;
}
@@ -513,10 +532,12 @@ class AutoFilter
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW:
$maxVal = (int) Date::PHPtoExcel(strtotime('+1 day', $baseDate));
$val = (int) Date::PHPToExcel($baseDate);
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE:
$maxVal = (int) Date::PHPtoExcel(strtotime('+1 day', $baseDate));
$val = (int) Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate)));
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR:
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR:
@@ -524,6 +545,7 @@ class AutoFilter
$maxVal = (int) Date::PHPToExcel(gmmktime(0, 0, 0, 31, 12, date('Y', $baseDate)));
++$maxVal;
$val = (int) Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate)));
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER:
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER:
@@ -533,6 +555,7 @@ class AutoFilter
$maxVal = (int) Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), (1 + $thisQuarter) * 3, date('Y', $baseDate)));
++$maxVal;
$val = (int) Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1 + $thisQuarter * 3, date('Y', $baseDate)));
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH:
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH:
@@ -540,6 +563,7 @@ class AutoFilter
$maxVal = (int) Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), date('m', $baseDate), date('Y', $baseDate)));
++$maxVal;
$val = (int) Date::PHPToExcel(gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK:
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK:
@@ -547,6 +571,7 @@ class AutoFilter
$dayOfWeek = date('w', $baseDate);
$val = (int) Date::PHPToExcel($baseDate) - $dayOfWeek;
$maxVal = $val + 7;
+
break;
}
@@ -555,10 +580,12 @@ class AutoFilter
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY:
--$maxVal;
--$val;
+
break;
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW:
++$maxVal;
++$val;
+
break;
}
@@ -597,7 +624,7 @@ class AutoFilter
*/
public function showHideRows()
{
- list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($this->range);
+ [$rangeStart, $rangeEnd] = Cell::rangeBoundaries($this->range);
// The heading row should always be visible
$this->workSheet->getRowDimension($rangeStart[1])->setVisible(true);
@@ -673,6 +700,7 @@ class AutoFilter
'arguments' => ['filterValues' => $arguments, 'blanks' => $blanks],
];
}
+
break;
case AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER:
$customRuleForBlanks = false;
@@ -696,6 +724,7 @@ class AutoFilter
'method' => 'filterTestInCustomDataSet',
'arguments' => ['filterRules' => $ruleValues, 'join' => $join, 'customRuleForBlanks' => $customRuleForBlanks],
];
+
break;
case AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER:
$ruleValues = [];
@@ -741,10 +770,12 @@ class AutoFilter
} else {
// Date Range
$columnFilterTests[$columnID] = $this->dynamicFilterDateRange($dynamicRuleType, $filterColumn);
+
break;
}
}
}
+
break;
case AutoFilter\Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER:
$ruleValues = [];
@@ -776,6 +807,7 @@ class AutoFilter
'arguments' => ['filterRules' => $ruleValues, 'join' => AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_OR],
];
$filterColumn->setAttributes(['maxVal' => $maxVal]);
+
break;
}
}
diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php
index 07940eb4..97a80931 100644
--- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php
+++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php
@@ -32,7 +32,7 @@ class Column
self::AUTOFILTER_FILTERTYPE_TOPTENFILTER,
];
- /* Multiple Rule Connections */
+ // Multiple Rule Connections
const AUTOFILTER_COLUMN_JOIN_AND = 'and';
const AUTOFILTER_COLUMN_JOIN_OR = 'or';
diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php
index 6aacab78..3f2d97c7 100644
--- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php
+++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php
@@ -166,19 +166,19 @@ class Rule
self::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM,
];
- /* Rule Operators (Numeric, Boolean etc) */
+ // Rule Operators (Numeric, Boolean etc)
// const AUTOFILTER_COLUMN_RULE_BETWEEN = 'between'; // greaterThanOrEqual 1 && lessThanOrEqual 2
- /* Rule Operators (Numeric Special) which are translated to standard numeric operators with calculated values */
+ // Rule Operators (Numeric Special) which are translated to standard numeric operators with calculated values
// const AUTOFILTER_COLUMN_RULE_TOPTEN = 'topTen'; // greaterThan calculated value
// const AUTOFILTER_COLUMN_RULE_TOPTENPERCENT = 'topTenPercent'; // greaterThan calculated value
// const AUTOFILTER_COLUMN_RULE_ABOVEAVERAGE = 'aboveAverage'; // Value is calculated as the average
// const AUTOFILTER_COLUMN_RULE_BELOWAVERAGE = 'belowAverage'; // Value is calculated as the average
- /* Rule Operators (String) which are set as wild-carded values */
+ // Rule Operators (String) which are set as wild-carded values
// const AUTOFILTER_COLUMN_RULE_BEGINSWITH = 'beginsWith'; // A*
// const AUTOFILTER_COLUMN_RULE_ENDSWITH = 'endsWith'; // *Z
// const AUTOFILTER_COLUMN_RULE_CONTAINS = 'contains'; // *B*
// const AUTOFILTER_COLUMN_RULE_DOESNTCONTAIN = 'notEqual'; // notEqual *B*
- /* Rule Operators (Date Special) which are translated to standard numeric operators with calculated values */
+ // Rule Operators (Date Special) which are translated to standard numeric operators with calculated values
// const AUTOFILTER_COLUMN_RULE_BEFORE = 'lessThan';
// const AUTOFILTER_COLUMN_RULE_AFTER = 'greaterThan';
// const AUTOFILTER_COLUMN_RULE_YESTERDAY = 'yesterday';
@@ -205,7 +205,7 @@ class Rule
*
* @var Column
*/
- private $parent = null;
+ private $parent;
/**
* Autofilter Rule Type.
diff --git a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php
index 1fd32c73..9bf2cf35 100644
--- a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php
+++ b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php
@@ -202,7 +202,7 @@ class BaseDrawing implements IComparable
*/
public function setWorksheet(Worksheet $pValue = null, $pOverrideOld = false)
{
- if (is_null($this->worksheet)) {
+ if ($this->worksheet === null) {
// Add drawing to \PhpOffice\PhpSpreadsheet\Worksheet
$this->worksheet = $pValue;
$this->worksheet->getCell($this->coordinates);
@@ -216,6 +216,7 @@ class BaseDrawing implements IComparable
if ($iterator->current()->getHashCode() == $this->getHashCode()) {
$this->worksheet->getDrawingCollection()->offsetUnset($iterator->key());
$this->worksheet = null;
+
break;
}
}
diff --git a/src/PhpSpreadsheet/Worksheet/CellIterator.php b/src/PhpSpreadsheet/Worksheet/CellIterator.php
index 51ef99da..56119dc3 100644
--- a/src/PhpSpreadsheet/Worksheet/CellIterator.php
+++ b/src/PhpSpreadsheet/Worksheet/CellIterator.php
@@ -18,7 +18,7 @@ abstract class CellIterator
*
* @var mixed
*/
- protected $position = null;
+ protected $position;
/**
* Iterate only existing cells.
diff --git a/src/PhpSpreadsheet/Worksheet/Dimension.php b/src/PhpSpreadsheet/Worksheet/Dimension.php
index 157988d0..44e66323 100644
--- a/src/PhpSpreadsheet/Worksheet/Dimension.php
+++ b/src/PhpSpreadsheet/Worksheet/Dimension.php
@@ -30,7 +30,7 @@ abstract class Dimension
/**
* Index to cellXf. Null value means row has no explicit cellXf format.
*
- * @var int|null
+ * @var null|int
*/
private $xfIndex;
diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php
index 12c81041..5f671fa0 100644
--- a/src/PhpSpreadsheet/Worksheet/Drawing.php
+++ b/src/PhpSpreadsheet/Worksheet/Drawing.php
@@ -89,7 +89,7 @@ class Drawing extends BaseDrawing implements IComparable
if ($this->width == 0 && $this->height == 0) {
// Get width/height
- list($this->width, $this->height) = getimagesize($pValue);
+ [$this->width, $this->height] = getimagesize($pValue);
}
} else {
throw new PhpSpreadsheetException("File $pValue not found!");
diff --git a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php
index 1adc5262..44abbc60 100644
--- a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php
+++ b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php
@@ -8,7 +8,7 @@ use PhpOffice\PhpSpreadsheet\Style\Color;
class Shadow implements IComparable
{
- /* Shadow alignment */
+ // Shadow alignment
const SHADOW_BOTTOM = 'b';
const SHADOW_BOTTOM_LEFT = 'bl';
const SHADOW_BOTTOM_RIGHT = 'br';
diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php
index 760c429b..c2606c5f 100644
--- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php
+++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php
@@ -67,7 +67,7 @@ use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
*/
class HeaderFooter
{
- /* Header/footer image location */
+ // Header/footer image location
const IMAGE_HEADER_LEFT = 'LH';
const IMAGE_HEADER_CENTER = 'CH';
const IMAGE_HEADER_RIGHT = 'RH';
diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php b/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php
index 18a152e6..4e7b70ce 100644
--- a/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php
+++ b/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php
@@ -311,7 +311,7 @@ class HeaderFooterDrawing extends Drawing implements IComparable
if ($this->width == 0 && $this->height == 0) {
// Get width/height
- list($this->width, $this->height) = getimagesize($pValue);
+ [$this->width, $this->height] = getimagesize($pValue);
}
} else {
throw new PhpSpreadsheetException("File $pValue not found!");
diff --git a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php
index ba3f4702..7af32444 100644
--- a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php
+++ b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php
@@ -6,13 +6,13 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class MemoryDrawing extends BaseDrawing implements IComparable
{
- /* Rendering functions */
+ // Rendering functions
const RENDERING_DEFAULT = 'imagepng';
const RENDERING_PNG = 'imagepng';
const RENDERING_GIF = 'imagegif';
const RENDERING_JPEG = 'imagejpeg';
- /* MIME types */
+ // MIME types
const MIMETYPE_DEFAULT = 'image/png';
const MIMETYPE_PNG = 'image/png';
const MIMETYPE_GIF = 'image/gif';
@@ -82,7 +82,7 @@ class MemoryDrawing extends BaseDrawing implements IComparable
{
$this->imageResource = $value;
- if (!is_null($this->imageResource)) {
+ if ($this->imageResource !== null) {
// Get width/height
$this->width = imagesx($this->imageResource);
$this->height = imagesy($this->imageResource);
diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php
index 1baac7f2..9258ebf5 100644
--- a/src/PhpSpreadsheet/Worksheet/PageSetup.php
+++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php
@@ -83,7 +83,7 @@ use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
*/
class PageSetup
{
- /* Paper size */
+ // Paper size
const PAPERSIZE_LETTER = 1;
const PAPERSIZE_LETTER_SMALL = 2;
const PAPERSIZE_TABLOID = 3;
@@ -151,12 +151,12 @@ class PageSetup
const PAPERSIZE_A3_TRANSVERSE_PAPER = 65;
const PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER = 66;
- /* Page orientation */
+ // Page orientation
const ORIENTATION_DEFAULT = 'default';
const ORIENTATION_LANDSCAPE = 'landscape';
const ORIENTATION_PORTRAIT = 'portrait';
- /* Print Range Set Method */
+ // Print Range Set Method
const SETPRINTRANGE_OVERWRITE = 'O';
const SETPRINTRANGE_INSERT = 'I';
@@ -241,14 +241,14 @@ class PageSetup
*
* @var string
*/
- private $printArea = null;
+ private $printArea;
/**
* First page number.
*
* @var int
*/
- private $firstPageNumber = null;
+ private $firstPageNumber;
/**
* Create a new PageSetup.
@@ -320,7 +320,7 @@ class PageSetup
* Print scaling. Valid values range from 10 to 400
* This setting is overridden when fitToWidth and/or fitToHeight are in use.
*
- * @param int|null $pValue
+ * @param null|int $pValue
* @param bool $pUpdate Update fitToPage so scaling applies rather than fitToHeight / fitToWidth
*
* @throws PhpSpreadsheetException
@@ -331,7 +331,7 @@ class PageSetup
{
// Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
// but it is apparently still able to handle any scale >= 0, where 0 results in 100
- if (($pValue >= 0) || is_null($pValue)) {
+ if (($pValue >= 0) || $pValue === null) {
$this->scale = $pValue;
if ($pUpdate) {
$this->fitToPage = false;
@@ -380,7 +380,7 @@ class PageSetup
/**
* Set Fit To Height.
*
- * @param int|null $pValue
+ * @param null|int $pValue
* @param bool $pUpdate Update fitToPage so it applies rather than scaling
*
* @return PageSetup
@@ -408,7 +408,7 @@ class PageSetup
/**
* Set Fit To Width.
*
- * @param int|null $pValue
+ * @param null|int $pValue
* @param bool $pUpdate Update fitToPage so it applies rather than scaling
*
* @return PageSetup
@@ -602,6 +602,7 @@ class PageSetup
if (isset($printAreas[$index - 1])) {
return $printAreas[$index - 1];
}
+
throw new PhpSpreadsheetException('Requested Print Area does not exist');
}
@@ -618,7 +619,7 @@ class PageSetup
public function isPrintAreaSet($index = 0)
{
if ($index == 0) {
- return !is_null($this->printArea);
+ return $this->printArea !== null;
}
$printAreas = explode(',', $this->printArea);
diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php
index 7aaaa146..17282324 100644
--- a/src/PhpSpreadsheet/Worksheet/SheetView.php
+++ b/src/PhpSpreadsheet/Worksheet/SheetView.php
@@ -6,7 +6,7 @@ use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
class SheetView
{
- /* Sheet View types */
+ // Sheet View types
const SHEETVIEW_NORMAL = 'normal';
const SHEETVIEW_PAGE_LAYOUT = 'pageLayout';
const SHEETVIEW_PAGE_BREAK_PREVIEW = 'pageBreakPreview';
@@ -75,7 +75,7 @@ class SheetView
{
// Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
// but it is apparently still able to handle any scale >= 1
- if (($pValue >= 1) || is_null($pValue)) {
+ if (($pValue >= 1) || $pValue === null) {
$this->zoomScale = $pValue;
} else {
throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.');
@@ -106,7 +106,7 @@ class SheetView
*/
public function setZoomScaleNormal($pValue)
{
- if (($pValue >= 1) || is_null($pValue)) {
+ if (($pValue >= 1) || $pValue === null) {
$this->zoomScaleNormal = $pValue;
} else {
throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.');
diff --git a/src/PhpSpreadsheet/Writer/Exception.php b/src/PhpSpreadsheet/Writer/Exception.php
index d3d0914b..6dc4774e 100644
--- a/src/PhpSpreadsheet/Writer/Exception.php
+++ b/src/PhpSpreadsheet/Writer/Exception.php
@@ -20,6 +20,7 @@ class Exception extends PhpSpreadsheetException
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
+
throw $e;
}
}
diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php
index 374749c5..20fb9f35 100644
--- a/src/PhpSpreadsheet/Writer/Html.php
+++ b/src/PhpSpreadsheet/Writer/Html.php
@@ -208,7 +208,7 @@ class Html extends BaseWriter implements IWriter
*
* @param string $hAlign Horizontal alignment
*
- * @return string|false
+ * @return false|string
*/
private function mapHAlign($hAlign)
{
@@ -343,7 +343,7 @@ class Html extends BaseWriter implements IWriter
public function generateHTMLHeader($pIncludeStyles = false)
{
// Spreadsheet object known?
- if (is_null($this->spreadsheet)) {
+ if ($this->spreadsheet === null) {
throw new WriterException('Internal Spreadsheet object not set to an instance of an object.');
}
@@ -403,7 +403,7 @@ class Html extends BaseWriter implements IWriter
public function generateSheetData()
{
// Spreadsheet object known?
- if (is_null($this->spreadsheet)) {
+ if ($this->spreadsheet === null) {
throw new WriterException('Internal Spreadsheet object not set to an instance of an object.');
}
@@ -414,7 +414,7 @@ class Html extends BaseWriter implements IWriter
// Fetch sheets
$sheets = [];
- if (is_null($this->sheetIndex)) {
+ if ($this->sheetIndex === null) {
$sheets = $this->spreadsheet->getAllSheets();
} else {
$sheets[] = $this->spreadsheet->getSheet($this->sheetIndex);
@@ -501,7 +501,7 @@ class Html extends BaseWriter implements IWriter
// Writing PDF?
if ($this->isPdf) {
- if (is_null($this->sheetIndex) && $sheetId + 1 < $this->spreadsheet->getSheetCount()) {
+ if ($this->sheetIndex === null && $sheetId + 1 < $this->spreadsheet->getSheetCount()) {
$html .= '';
}
}
@@ -523,13 +523,13 @@ class Html extends BaseWriter implements IWriter
public function generateNavigation()
{
// Spreadsheet object known?
- if (is_null($this->spreadsheet)) {
+ if ($this->spreadsheet === null) {
throw new WriterException('Internal Spreadsheet object not set to an instance of an object.');
}
// Fetch sheets
$sheets = [];
- if (is_null($this->sheetIndex)) {
+ if ($this->sheetIndex === null) {
$sheets = $this->spreadsheet->getAllSheets();
} else {
$sheets[] = $this->spreadsheet->getSheet($this->sheetIndex);
@@ -758,7 +758,7 @@ class Html extends BaseWriter implements IWriter
public function generateStyles($generateSurroundingHTML = true)
{
// Spreadsheet object known?
- if (is_null($this->spreadsheet)) {
+ if ($this->spreadsheet === null) {
throw new WriterException('Internal Spreadsheet object not set to an instance of an object.');
}
@@ -802,12 +802,12 @@ class Html extends BaseWriter implements IWriter
public function buildCSS($generateSurroundingHTML = true)
{
// Spreadsheet object known?
- if (is_null($this->spreadsheet)) {
+ if ($this->spreadsheet === null) {
throw new WriterException('Internal Spreadsheet object not set to an instance of an object.');
}
// Cached?
- if (!is_null($this->cssStyles)) {
+ if ($this->cssStyles !== null) {
return $this->cssStyles;
}
@@ -863,7 +863,7 @@ class Html extends BaseWriter implements IWriter
// Fetch sheets
$sheets = [];
- if (is_null($this->sheetIndex)) {
+ if ($this->sheetIndex === null) {
$sheets = $this->spreadsheet->getAllSheets();
} else {
$sheets[] = $this->spreadsheet->getSheet($this->sheetIndex);
@@ -939,7 +939,7 @@ class Html extends BaseWriter implements IWriter
}
// Cache
- if (is_null($this->cssStyles)) {
+ if ($this->cssStyles === null) {
$this->cssStyles = $css;
}
@@ -1232,7 +1232,7 @@ class Html extends BaseWriter implements IWriter
// Cell
if ($cell instanceof Cell) {
$cellData = '';
- if (is_null($cell->getParent())) {
+ if ($cell->getParent() === null) {
$cell->attach($pSheet);
}
// Value
@@ -1548,14 +1548,14 @@ class Html extends BaseWriter implements IWriter
// loop through all Excel merged cells
foreach ($sheet->getMergeCells() as $cells) {
- list($cells) = Cell::splitRange($cells);
+ [$cells] = Cell::splitRange($cells);
$first = $cells[0];
$last = $cells[1];
- list($fc, $fr) = Cell::coordinateFromString($first);
+ [$fc, $fr] = Cell::coordinateFromString($first);
$fc = Cell::columnIndexFromString($fc) - 1;
- list($lc, $lr) = Cell::coordinateFromString($last);
+ [$lc, $lr] = Cell::coordinateFromString($last);
$lc = Cell::columnIndexFromString($lc) - 1;
// loop through the individual cells in the individual merge
diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php
index 7ae9f7da..64e163b1 100644
--- a/src/PhpSpreadsheet/Writer/Ods.php
+++ b/src/PhpSpreadsheet/Writer/Ods.php
@@ -59,7 +59,7 @@ class Ods extends BaseWriter implements IWriter
*
* @param string $pPartName Writer part name
*
- * @return Ods\WriterPart|null
+ * @return null|Ods\WriterPart
*/
public function getWriterPart($pPartName)
{
@@ -158,6 +158,7 @@ class Ods extends BaseWriter implements IWriter
if ($this->spreadSheet !== null) {
return $this->spreadSheet;
}
+
throw new WriterException('No PhpSpreadsheet assigned.');
}
diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php
index d8137083..01825ef7 100644
--- a/src/PhpSpreadsheet/Writer/Ods/Content.php
+++ b/src/PhpSpreadsheet/Writer/Ods/Content.php
@@ -111,7 +111,7 @@ class Content extends WriterPart
*/
private function writeSheets(XMLWriter $objWriter)
{
- $spreadsheet = $this->getParentWriter()->getSpreadsheet(); /* @var $spreadsheet Spreadsheet */
+ $spreadsheet = $this->getParentWriter()->getSpreadsheet(); // @var $spreadsheet Spreadsheet
$sheetCount = $spreadsheet->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) {
@@ -194,6 +194,7 @@ class Content extends WriterPart
$objWriter->writeAttribute('office:value-type', 'boolean');
$objWriter->writeAttribute('office:value', $cell->getValue());
$objWriter->writeElement('text:p', $cell->getValue());
+
break;
case DataType::TYPE_ERROR:
throw new Exception('Writing of error not implemented yet.');
@@ -215,6 +216,7 @@ class Content extends WriterPart
}
$objWriter->writeAttribute('office:value', $formulaValue);
$objWriter->writeElement('text:p', $formulaValue);
+
break;
case DataType::TYPE_INLINE:
throw new Exception('Writing of inline not implemented yet.');
@@ -223,10 +225,12 @@ class Content extends WriterPart
$objWriter->writeAttribute('office:value-type', 'float');
$objWriter->writeAttribute('office:value', $cell->getValue());
$objWriter->writeElement('text:p', $cell->getValue());
+
break;
case DataType::TYPE_STRING:
$objWriter->writeAttribute('office:value-type', 'string');
$objWriter->writeElement('text:p', $cell->getValue());
+
break;
}
Comment::write($objWriter, $cell);
@@ -279,9 +283,7 @@ class Content extends WriterPart
$writer->writeAttribute('style:family', 'table-cell');
$writer->writeAttribute('style:parent-style-name', 'Default');
- /*
- * style:text-properties
- */
+ // style:text-properties
// Font
$writer->startElement('style:text-properties');
@@ -318,18 +320,18 @@ class Content extends WriterPart
switch ($font->getUnderline()) {
case Font::UNDERLINE_DOUBLE:
$writer->writeAttribute('style:text-underline-type', 'double');
+
break;
case Font::UNDERLINE_SINGLE:
$writer->writeAttribute('style:text-underline-type', 'single');
+
break;
}
}
$writer->endElement(); // Close style:text-properties
- /*
- * style:table-cell-properties
- */
+ // style:table-cell-properties
$writer->startElement('style:table-cell-properties');
$writer->writeAttribute('style:rotation-align', 'none');
@@ -342,6 +344,7 @@ class Content extends WriterPart
'#%s',
strtolower($fill->getStartColor()->getRGB())
));
+
break;
case Fill::FILL_GRADIENT_LINEAR:
case Fill::FILL_GRADIENT_PATH:
@@ -354,9 +357,7 @@ class Content extends WriterPart
$writer->endElement(); // Close style:table-cell-properties
- /*
- * End
- */
+ // End
$writer->endElement(); // Close style:style
}
diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php
index fd89a44b..55e71953 100644
--- a/src/PhpSpreadsheet/Writer/Pdf.php
+++ b/src/PhpSpreadsheet/Writer/Pdf.php
@@ -12,7 +12,7 @@ class Pdf implements IWriter
*
* @var PDF\Core
*/
- private $renderer = null;
+ private $renderer;
/**
* Instantiate a new renderer of the configured type within this container class.
@@ -24,7 +24,7 @@ class Pdf implements IWriter
public function __construct(Spreadsheet $spreadsheet)
{
$pdfLibraryName = Settings::getPdfRendererName();
- if (is_null($pdfLibraryName)) {
+ if ($pdfLibraryName === null) {
throw new Exception('PDF Rendering library has not been defined.');
}
diff --git a/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php b/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php
index 25035f59..d24caf81 100644
--- a/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php
+++ b/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php
@@ -22,7 +22,7 @@ class DomPDF extends Core implements IWriter
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
// Check for paper size and page orientation
- if (is_null($this->getSheetIndex())) {
+ if ($this->getSheetIndex() === null) {
$orientation = ($this->spreadsheet->getSheet(0)->getPageSetup()->getOrientation()
== PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->spreadsheet->getSheet(0)->getPageSetup()->getPaperSize();
@@ -37,13 +37,13 @@ class DomPDF extends Core implements IWriter
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait';
// Override Page Orientation
- if (!is_null($this->getOrientation())) {
+ if ($this->getOrientation() !== null) {
$orientation = ($this->getOrientation() == PageSetup::ORIENTATION_DEFAULT)
? PageSetup::ORIENTATION_PORTRAIT
: $this->getOrientation();
}
// Override Paper Size
- if (!is_null($this->getPaperSize())) {
+ if ($this->getPaperSize() !== null) {
$printPaperSize = $this->getPaperSize();
}
diff --git a/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php b/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php
index 8634e808..42f577ed 100644
--- a/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php
+++ b/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php
@@ -22,7 +22,7 @@ class TcPDF extends Core implements IWriter
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
// Check for paper size and page orientation
- if (is_null($this->getSheetIndex())) {
+ if ($this->getSheetIndex() === null) {
$orientation = ($this->spreadsheet->getSheet(0)->getPageSetup()->getOrientation()
== PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->spreadsheet->getSheet(0)->getPageSetup()->getPaperSize();
@@ -35,13 +35,13 @@ class TcPDF extends Core implements IWriter
}
// Override Page Orientation
- if (!is_null($this->getOrientation())) {
+ if ($this->getOrientation() !== null) {
$orientation = ($this->getOrientation() == PageSetup::ORIENTATION_LANDSCAPE)
? 'L'
: 'P';
}
// Override Paper Size
- if (!is_null($this->getPaperSize())) {
+ if ($this->getPaperSize() !== null) {
$printPaperSize = $this->getPaperSize();
}
diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php
index 251d47f0..ff19abc8 100644
--- a/src/PhpSpreadsheet/Writer/Xls.php
+++ b/src/PhpSpreadsheet/Writer/Xls.php
@@ -390,6 +390,7 @@ class Xls extends BaseWriter implements IWriter
foreach ($this->spreadsheet->getAllSheets() as $sheet) {
if (count($sheet->getDrawingCollection()) > 0) {
$found = true;
+
break;
}
}
@@ -447,7 +448,7 @@ class Xls extends BaseWriter implements IWriter
if ($drawing instanceof Drawing) {
$filename = $drawing->getPath();
- list($imagesx, $imagesy, $imageFormat) = getimagesize($filename);
+ [$imagesx, $imagesy, $imageFormat] = getimagesize($filename);
switch ($imageFormat) {
case 1: // GIF, not supported by BIFF8, we convert to PNG
@@ -456,14 +457,17 @@ class Xls extends BaseWriter implements IWriter
imagepng(imagecreatefromgif($filename));
$blipData = ob_get_contents();
ob_end_clean();
+
break;
case 2: // JPEG
$blipType = BSE::BLIPTYPE_JPEG;
$blipData = file_get_contents($filename);
+
break;
case 3: // PNG
$blipType = BSE::BLIPTYPE_PNG;
$blipData = file_get_contents($filename);
+
break;
case 6: // Windows DIB (BMP), we convert to PNG
$blipType = BSE::BLIPTYPE_PNG;
@@ -471,6 +475,7 @@ class Xls extends BaseWriter implements IWriter
imagepng(SharedDrawing::imagecreatefrombmp($filename));
$blipData = ob_get_contents();
ob_end_clean();
+
break;
default:
continue 2;
@@ -489,12 +494,14 @@ class Xls extends BaseWriter implements IWriter
case MemoryDrawing::RENDERING_JPEG:
$blipType = BSE::BLIPTYPE_JPEG;
$renderingFunction = 'imagejpeg';
+
break;
case MemoryDrawing::RENDERING_GIF:
case MemoryDrawing::RENDERING_PNG:
case MemoryDrawing::RENDERING_DEFAULT:
$blipType = BSE::BLIPTYPE_PNG;
$renderingFunction = 'imagepng';
+
break;
}
@@ -908,7 +915,7 @@ class Xls extends BaseWriter implements IWriter
$dataSection_Content_Offset += 4 + 8;
}
- // Data Type Not Used at the moment
+ // Data Type Not Used at the moment
}
// Now $dataSection_Content_Offset contains the size of the content
diff --git a/src/PhpSpreadsheet/Writer/Xls/Escher.php b/src/PhpSpreadsheet/Writer/Xls/Escher.php
index 51e2898a..91ff8845 100644
--- a/src/PhpSpreadsheet/Writer/Xls/Escher.php
+++ b/src/PhpSpreadsheet/Writer/Xls/Escher.php
@@ -69,6 +69,7 @@ class Escher
$this->spOffsets = $writer->getSpOffsets();
$this->spTypes = $writer->getSpTypes();
}
+
break;
case DggContainer::class:
// this is a container record
@@ -122,6 +123,7 @@ class Escher
$header = pack('vvV', $recVerInstance, $recType, $length);
$this->data = $header . $innerData;
+
break;
case BstoreContainer::class:
// this is a container record
@@ -149,6 +151,7 @@ class Escher
$header = pack('vvV', $recVerInstance, $recType, $length);
$this->data = $header . $innerData;
+
break;
case BSE::class:
// this is a semi-container record
@@ -198,6 +201,7 @@ class Escher
$this->data = $header;
$this->data .= $data;
+
break;
case Blip::class:
// this is an atom record
@@ -229,6 +233,7 @@ class Escher
$this->data = $header;
$this->data .= $innerData;
+
break;
case BSE::BLIPTYPE_PNG:
// initialize
@@ -255,8 +260,10 @@ class Escher
$this->data = $header;
$this->data .= $innerData;
+
break;
}
+
break;
case DgContainer::class:
// this is a container record
@@ -309,6 +316,7 @@ class Escher
$header = pack('vvV', $recVerInstance, $recType, $length);
$this->data = $header . $innerData;
+
break;
case SpgrContainer::class:
// this is a container record
@@ -348,6 +356,7 @@ class Escher
$this->data = $header . $innerData;
$this->spOffsets = $spOffsets;
$this->spTypes = $spTypes;
+
break;
case SpContainer::class:
// initialize
@@ -412,7 +421,7 @@ class Escher
$recType = 0xF010;
// start coordinates
- list($column, $row) = Cell::coordinateFromString($this->object->getStartCoordinates());
+ [$column, $row] = Cell::coordinateFromString($this->object->getStartCoordinates());
$c1 = Cell::columnIndexFromString($column) - 1;
$r1 = $row - 1;
@@ -423,7 +432,7 @@ class Escher
$startOffsetY = $this->object->getStartOffsetY();
// end coordinates
- list($column, $row) = Cell::coordinateFromString($this->object->getEndCoordinates());
+ [$column, $row] = Cell::coordinateFromString($this->object->getEndCoordinates());
$c2 = Cell::columnIndexFromString($column) - 1;
$r2 = $row - 1;
@@ -473,6 +482,7 @@ class Escher
$header = pack('vvV', $recVerInstance, $recType, $length);
$this->data = $header . $data;
+
break;
}
diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php
index c5bb9b49..92c3474a 100644
--- a/src/PhpSpreadsheet/Writer/Xls/Parser.php
+++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php
@@ -493,31 +493,31 @@ class Parser
return $this->convertString($token);
} elseif (is_numeric($token)) {
return $this->convertNumber($token);
- // match references like A1 or $A$1
+ // match references like A1 or $A$1
} elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/', $token)) {
return $this->convertRef2d($token);
- // match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1
+ // match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1
} elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u", $token)) {
return $this->convertRef3d($token);
- // match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1
+ // match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u", $token)) {
return $this->convertRef3d($token);
- // match ranges like A1:B2 or $A$1:$B$2
+ // match ranges like A1:B2 or $A$1:$B$2
} elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/', $token)) {
return $this->convertRange2d($token);
- // match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
+ // match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
} elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u", $token)) {
return $this->convertRange3d($token);
- // match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
+ // match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u", $token)) {
return $this->convertRange3d($token);
- // operators (including parentheses)
+ // operators (including parentheses)
} elseif (isset($this->ptg[$token])) {
return pack('C', $this->ptg[$token]);
- // match error codes
+ // match error codes
} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') {
return $this->convertError($token);
- // commented so argument number can be processed correctly. See toReversePolish().
+ // commented so argument number can be processed correctly. See toReversePolish().
/*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/", $token))
{
return($this->convertFunction($token, $this->_func_args));
@@ -603,15 +603,15 @@ class Parser
// TODO: possible class value 0,1,2 check Formula.pm
// Split the range into 2 cell refs
if (preg_match('/^(\$)?([A-Ia-i]?[A-Za-z])(\$)?(\d+)\:(\$)?([A-Ia-i]?[A-Za-z])(\$)?(\d+)$/', $range)) {
- list($cell1, $cell2) = explode(':', $range);
+ [$cell1, $cell2] = explode(':', $range);
} else {
// TODO: use real error codes
throw new WriterException('Unknown range separator');
}
// Convert the cell references
- list($row1, $col1) = $this->cellToPackedRowcol($cell1);
- list($row2, $col2) = $this->cellToPackedRowcol($cell2);
+ [$row1, $col1] = $this->cellToPackedRowcol($cell1);
+ [$row2, $col2] = $this->cellToPackedRowcol($cell2);
// The ptg value depends on the class of the ptg.
if ($class == 0) {
@@ -639,20 +639,20 @@ class Parser
private function convertRange3d($token)
{
// Split the ref at the ! symbol
- list($ext_ref, $range) = explode('!', $token);
+ [$ext_ref, $range] = explode('!', $token);
// Convert the external reference part (different for BIFF8)
$ext_ref = $this->getRefIndex($ext_ref);
// Split the range into 2 cell refs
- list($cell1, $cell2) = explode(':', $range);
+ [$cell1, $cell2] = explode(':', $range);
// Convert the cell references
if (preg_match("/^(\\$)?[A-Ia-i]?[A-Za-z](\\$)?(\d+)$/", $cell1)) {
- list($row1, $col1) = $this->cellToPackedRowcol($cell1);
- list($row2, $col2) = $this->cellToPackedRowcol($cell2);
+ [$row1, $col1] = $this->cellToPackedRowcol($cell1);
+ [$row2, $col2] = $this->cellToPackedRowcol($cell2);
} else { // It's a rows range (like 26:27)
- list($row1, $col1, $row2, $col2) = $this->rangeToPackedRange($cell1 . ':' . $cell2);
+ [$row1, $col1, $row2, $col2] = $this->rangeToPackedRange($cell1 . ':' . $cell2);
}
// The ptg value depends on the class of the ptg.
@@ -672,7 +672,7 @@ class Parser
{
// Convert the cell reference
$cell_array = $this->cellToPackedRowcol($cell);
- list($row, $col) = $cell_array;
+ [$row, $col] = $cell_array;
// The ptg value depends on the class of the ptg.
$ptgRef = pack('C', $this->ptg['ptgRefA']);
@@ -691,13 +691,13 @@ class Parser
private function convertRef3d($cell)
{
// Split the ref at the ! symbol
- list($ext_ref, $cell) = explode('!', $cell);
+ [$ext_ref, $cell] = explode('!', $cell);
// Convert the external reference part (different for BIFF8)
$ext_ref = $this->getRefIndex($ext_ref);
// Convert the cell reference part
- list($row, $col) = $this->cellToPackedRowcol($cell);
+ [$row, $col] = $this->cellToPackedRowcol($cell);
// The ptg value depends on the class of the ptg.
$ptgRef = pack('C', $this->ptg['ptgRef3dA']);
@@ -749,7 +749,7 @@ class Parser
// Check if there is a sheet range eg., Sheet1:Sheet2.
if (preg_match('/:/', $ext_ref)) {
- list($sheet_name1, $sheet_name2) = explode(':', $ext_ref);
+ [$sheet_name1, $sheet_name2] = explode(':', $ext_ref);
$sheet1 = $this->getSheetIndex($sheet_name1);
if ($sheet1 == -1) {
@@ -762,7 +762,7 @@ class Parser
// Reverse max and min sheet numbers if necessary
if ($sheet1 > $sheet2) {
- list($sheet1, $sheet2) = [$sheet2, $sheet1];
+ [$sheet1, $sheet2] = [$sheet2, $sheet1];
}
} else { // Single sheet name only.
$sheet1 = $this->getSheetIndex($ext_ref);
@@ -795,7 +795,7 @@ class Parser
// Check if there is a sheet range eg., Sheet1:Sheet2.
if (preg_match('/:/', $ext_ref)) {
- list($sheet_name1, $sheet_name2) = explode(':', $ext_ref);
+ [$sheet_name1, $sheet_name2] = explode(':', $ext_ref);
$sheet1 = $this->getSheetIndex($sheet_name1);
if ($sheet1 == -1) {
@@ -808,7 +808,7 @@ class Parser
// Reverse max and min sheet numbers if necessary
if ($sheet1 > $sheet2) {
- list($sheet1, $sheet2) = [$sheet2, $sheet1];
+ [$sheet1, $sheet2] = [$sheet2, $sheet1];
}
} else { // Single sheet name only.
$sheet1 = $this->getSheetIndex($ext_ref);
@@ -826,6 +826,7 @@ class Parser
for ($i = 0; $i < $totalreferences; ++$i) {
if ($ref == $this->references[$i]) {
$index = $i;
+
break;
}
}
@@ -881,7 +882,7 @@ class Parser
private function cellToPackedRowcol($cell)
{
$cell = strtoupper($cell);
- list($row, $col, $row_rel, $col_rel) = $this->cellToRowcol($cell);
+ [$row, $col, $row_rel, $col_rel] = $this->cellToRowcol($cell);
if ($col >= 256) {
throw new WriterException("Column in: $cell greater than 255");
}
@@ -1186,13 +1187,13 @@ class Parser
$this->advance();
return $result;
- // If it's an error code
+ // If it's an error code
} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $this->currentToken) or $this->currentToken == '#N/A') {
$result = $this->createTree($this->currentToken, 'ptgErr', '');
$this->advance();
return $result;
- // If it's a negative value
+ // If it's a negative value
} elseif ($this->currentToken == '-') {
// catch "-" Term
$this->advance();
@@ -1200,7 +1201,7 @@ class Parser
$result = $this->createTree('ptgUminus', $result2, '');
return $result;
- // If it's a positive value
+ // If it's a positive value
} elseif ($this->currentToken == '+') {
// catch "+" Term
$this->advance();
@@ -1349,6 +1350,7 @@ class Parser
return $result;
}
+
throw new WriterException('Syntax error: ' . $this->currentToken . ', lookahead: ' . $this->lookAhead . ', current char: ' . $this->currentCharacter);
}
diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php
index 56e43d9d..9666114d 100644
--- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php
+++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php
@@ -601,7 +601,7 @@ class Workbook extends BIFFwriter
$colmax
);
- // (exclusive) either repeatColumns or repeatRows
+ // (exclusive) either repeatColumns or repeatRows
} elseif ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {
// Columns to repeat
if ($sheetSetup->isColumnsToRepeatAtLeftSet()) {
@@ -707,7 +707,7 @@ class Workbook extends BIFFwriter
// store the DEFINEDNAME record
$chunk .= $this->writeData($this->writeDefinedNameBiff8(pack('C', 0x07), $formulaData, $i + 1, true));
- // (exclusive) either repeatColumns or repeatRows
+ // (exclusive) either repeatColumns or repeatRows
} elseif ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {
// Columns to repeat
if ($sheetSetup->isColumnsToRepeatAtLeftSet()) {
@@ -920,15 +920,19 @@ class Workbook extends BIFFwriter
switch ($sheet->getSheetState()) {
case \PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_VISIBLE:
$ss = 0x00;
+
break;
case \PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_HIDDEN:
$ss = 0x01;
+
break;
case \PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_VERYHIDDEN:
$ss = 0x02;
+
break;
default:
$ss = 0x00;
+
break;
}
@@ -1231,7 +1235,7 @@ class Workbook extends BIFFwriter
$length = 4; // Number of bytes to follow
$header = pack('vv', $record, $length);
- /* using the same country code always for simplicity */
+ // using the same country code always for simplicity
$data = pack('vv', $this->countryCode, $this->countryCode);
return $this->writeData($header . $data);
@@ -1359,7 +1363,7 @@ class Workbook extends BIFFwriter
// and start new record data block where we start writing the string
$recordData = '';
- // 2. space remaining is greater than or equal to minimum space needed
+ // 2. space remaining is greater than or equal to minimum space needed
} else {
// initialize effective remaining space, for Unicode strings this may need to be reduced by 1, see below
$effective_space_remaining = $space_remaining;
diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php
index 0d265d8a..9c7f5627 100644
--- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php
+++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php
@@ -431,20 +431,25 @@ class Worksheet extends BIFFwriter
} else {
$this->writeString($row, $column, $cVal, $xfIndex);
}
+
break;
case Cell\DataType::TYPE_NUMERIC:
$this->writeNumber($row, $column, $cVal, $xfIndex);
+
break;
case Cell\DataType::TYPE_FORMULA:
$calculatedValue = $this->preCalculateFormulas ?
$cell->getCalculatedValue() : null;
$this->writeFormula($row, $column, $cVal, $xfIndex, $calculatedValue);
+
break;
case Cell\DataType::TYPE_BOOL:
$this->writeBoolErr($row, $column, $cVal, 0, $xfIndex);
+
break;
case Cell\DataType::TYPE_ERROR:
$this->writeBoolErr($row, $column, self::mapErrorCode($cVal), 1, $xfIndex);
+
break;
}
}
@@ -473,7 +478,7 @@ class Worksheet extends BIFFwriter
// Hyperlinks
foreach ($phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) {
- list($column, $row) = Cell::coordinateFromString($coordinate);
+ [$column, $row] = Cell::coordinateFromString($coordinate);
$url = $hyperlink->getUrl();
@@ -666,7 +671,7 @@ class Worksheet extends BIFFwriter
$length = 0x000A; // Bytes to follow
$str = StringHelper::UTF8toBIFF8UnicodeShort($str, $arrcRun);
- /* check if string is already present */
+ // check if string is already present
if (!isset($this->stringTable[$str])) {
$this->stringTable[$str] = $this->stringUnique++;
}
@@ -736,7 +741,7 @@ class Worksheet extends BIFFwriter
$str = StringHelper::UTF8toBIFF8UnicodeLong($str);
- /* check if string is already present */
+ // check if string is already present
if (!isset($this->stringTable[$str])) {
$this->stringTable[$str] = $this->stringUnique++;
}
@@ -1418,17 +1423,17 @@ class Worksheet extends BIFFwriter
$selectedCells = Cell::splitRange($this->phpSheet->getSelectedCells());
$selectedCells = $selectedCells[0];
if (count($selectedCells) == 2) {
- list($first, $last) = $selectedCells;
+ [$first, $last] = $selectedCells;
} else {
$first = $selectedCells[0];
$last = $selectedCells[0];
}
- list($colFirst, $rwFirst) = Cell::coordinateFromString($first);
+ [$colFirst, $rwFirst] = Cell::coordinateFromString($first);
$colFirst = Cell::columnIndexFromString($colFirst) - 1; // base 0 column index
--$rwFirst; // base 0 row index
- list($colLast, $rwLast) = Cell::coordinateFromString($last);
+ [$colLast, $rwLast] = Cell::coordinateFromString($last);
$colLast = Cell::columnIndexFromString($colLast) - 1; // base 0 column index
--$rwLast; // base 0 row index
@@ -1457,11 +1462,11 @@ class Worksheet extends BIFFwriter
// Swap last row/col for first row/col as necessary
if ($rwFirst > $rwLast) {
- list($rwFirst, $rwLast) = [$rwLast, $rwFirst];
+ [$rwFirst, $rwLast] = [$rwLast, $rwFirst];
}
if ($colFirst > $colLast) {
- list($colFirst, $colLast) = [$colLast, $colFirst];
+ [$colFirst, $colLast] = [$colLast, $colFirst];
}
$header = pack('vv', $record, $length);
@@ -1503,9 +1508,9 @@ class Worksheet extends BIFFwriter
// extract the row and column indexes
$range = Cell::splitRange($mergeCell);
- list($first, $last) = $range[0];
- list($firstColumn, $firstRow) = Cell::coordinateFromString($first);
- list($lastColumn, $lastRow) = Cell::coordinateFromString($last);
+ [$first, $last] = $range[0];
+ [$firstColumn, $firstRow] = Cell::coordinateFromString($first);
+ [$lastColumn, $lastRow] = Cell::coordinateFromString($last);
$recordData .= pack('vvvv', $firstRow - 1, $lastRow - 1, Cell::columnIndexFromString($firstColumn) - 1, Cell::columnIndexFromString($lastColumn) - 1);
@@ -1705,7 +1710,7 @@ class Worksheet extends BIFFwriter
{
$panes = [];
if ($freezePane = $this->phpSheet->getFreezePane()) {
- list($column, $row) = Cell::coordinateFromString($freezePane);
+ [$column, $row] = Cell::coordinateFromString($freezePane);
$panes[0] = $row - 1;
$panes[1] = Cell::columnIndexFromString($column) - 1;
} else {
@@ -2157,10 +2162,12 @@ class Worksheet extends BIFFwriter
case \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_COLUMN:
// Add to list of vertical breaks
$vbreaks[] = Cell::columnIndexFromString($coordinates[0]) - 1;
+
break;
case \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_ROW:
// Add to list of horizontal breaks
$hbreaks[] = $coordinates[1];
+
break;
case \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_NONE:
default:
@@ -2324,7 +2331,7 @@ class Worksheet extends BIFFwriter
public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1)
{
$bitmap_array = (is_resource($bitmap) ? $this->processBitmapGd($bitmap) : $this->processBitmap($bitmap));
- list($width, $height, $size, $data) = $bitmap_array;
+ [$width, $height, $size, $data] = $bitmap_array;
// Scale the frame of the image.
$width *= $scale_x;
@@ -2805,27 +2812,35 @@ class Worksheet extends BIFFwriter
switch ($dataValidation->getType()) {
case DataValidation::TYPE_NONE:
$type = 0x00;
+
break;
case DataValidation::TYPE_WHOLE:
$type = 0x01;
+
break;
case DataValidation::TYPE_DECIMAL:
$type = 0x02;
+
break;
case DataValidation::TYPE_LIST:
$type = 0x03;
+
break;
case DataValidation::TYPE_DATE:
$type = 0x04;
+
break;
case DataValidation::TYPE_TIME:
$type = 0x05;
+
break;
case DataValidation::TYPE_TEXTLENGTH:
$type = 0x06;
+
break;
case DataValidation::TYPE_CUSTOM:
$type = 0x07;
+
break;
}
@@ -2836,12 +2851,15 @@ class Worksheet extends BIFFwriter
switch ($dataValidation->getErrorStyle()) {
case DataValidation::STYLE_STOP:
$errorStyle = 0x00;
+
break;
case DataValidation::STYLE_WARNING:
$errorStyle = 0x01;
+
break;
case DataValidation::STYLE_INFORMATION:
$errorStyle = 0x02;
+
break;
}
@@ -2869,27 +2887,35 @@ class Worksheet extends BIFFwriter
switch ($dataValidation->getOperator()) {
case DataValidation::OPERATOR_BETWEEN:
$operator = 0x00;
+
break;
case DataValidation::OPERATOR_NOTBETWEEN:
$operator = 0x01;
+
break;
case DataValidation::OPERATOR_EQUAL:
$operator = 0x02;
+
break;
case DataValidation::OPERATOR_NOTEQUAL:
$operator = 0x03;
+
break;
case DataValidation::OPERATOR_GREATERTHAN:
$operator = 0x04;
+
break;
case DataValidation::OPERATOR_LESSTHAN:
$operator = 0x05;
+
break;
case DataValidation::OPERATOR_GREATERTHANOREQUAL:
$operator = 0x06;
+
break;
case DataValidation::OPERATOR_LESSTHANOREQUAL:
$operator = 0x07;
+
break;
}
@@ -3041,27 +3067,35 @@ class Worksheet extends BIFFwriter
switch ($conditional->getOperatorType()) {
case Conditional::OPERATOR_NONE:
$operatorType = 0x00;
+
break;
case Conditional::OPERATOR_EQUAL:
$operatorType = 0x03;
+
break;
case Conditional::OPERATOR_GREATERTHAN:
$operatorType = 0x05;
+
break;
case Conditional::OPERATOR_GREATERTHANOREQUAL:
$operatorType = 0x07;
+
break;
case Conditional::OPERATOR_LESSTHAN:
$operatorType = 0x06;
+
break;
case Conditional::OPERATOR_LESSTHANOREQUAL:
$operatorType = 0x08;
+
break;
case Conditional::OPERATOR_NOTEQUAL:
$operatorType = 0x04;
+
break;
case Conditional::OPERATOR_BETWEEN:
$operatorType = 0x01;
+
break;
// not OPERATOR_NOTBETWEEN 0x02
}
@@ -3225,26 +3259,32 @@ class Worksheet extends BIFFwriter
case \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE:
$dataBlockFont .= pack('C', 0x00);
$fontUnderline = 0;
+
break;
case \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE:
$dataBlockFont .= pack('C', 0x02);
$fontUnderline = 0;
+
break;
case \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLEACCOUNTING:
$dataBlockFont .= pack('C', 0x22);
$fontUnderline = 0;
+
break;
case \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE:
$dataBlockFont .= pack('C', 0x01);
$fontUnderline = 0;
+
break;
case \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLEACCOUNTING:
$dataBlockFont .= pack('C', 0x21);
$fontUnderline = 0;
+
break;
default:
$dataBlockFont .= pack('C', 0x00);
$fontUnderline = 1;
+
break;
}
// Not used (3)
@@ -3253,174 +3293,231 @@ class Worksheet extends BIFFwriter
switch ($conditional->getStyle()->getFont()->getColor()->getRGB()) {
case '000000':
$colorIdx = 0x08;
+
break;
case 'FFFFFF':
$colorIdx = 0x09;
+
break;
case 'FF0000':
$colorIdx = 0x0A;
+
break;
case '00FF00':
$colorIdx = 0x0B;
+
break;
case '0000FF':
$colorIdx = 0x0C;
+
break;
case 'FFFF00':
$colorIdx = 0x0D;
+
break;
case 'FF00FF':
$colorIdx = 0x0E;
+
break;
case '00FFFF':
$colorIdx = 0x0F;
+
break;
case '800000':
$colorIdx = 0x10;
+
break;
case '008000':
$colorIdx = 0x11;
+
break;
case '000080':
$colorIdx = 0x12;
+
break;
case '808000':
$colorIdx = 0x13;
+
break;
case '800080':
$colorIdx = 0x14;
+
break;
case '008080':
$colorIdx = 0x15;
+
break;
case 'C0C0C0':
$colorIdx = 0x16;
+
break;
case '808080':
$colorIdx = 0x17;
+
break;
case '9999FF':
$colorIdx = 0x18;
+
break;
case '993366':
$colorIdx = 0x19;
+
break;
case 'FFFFCC':
$colorIdx = 0x1A;
+
break;
case 'CCFFFF':
$colorIdx = 0x1B;
+
break;
case '660066':
$colorIdx = 0x1C;
+
break;
case 'FF8080':
$colorIdx = 0x1D;
+
break;
case '0066CC':
$colorIdx = 0x1E;
+
break;
case 'CCCCFF':
$colorIdx = 0x1F;
+
break;
case '000080':
$colorIdx = 0x20;
+
break;
case 'FF00FF':
$colorIdx = 0x21;
+
break;
case 'FFFF00':
$colorIdx = 0x22;
+
break;
case '00FFFF':
$colorIdx = 0x23;
+
break;
case '800080':
$colorIdx = 0x24;
+
break;
case '800000':
$colorIdx = 0x25;
+
break;
case '008080':
$colorIdx = 0x26;
+
break;
case '0000FF':
$colorIdx = 0x27;
+
break;
case '00CCFF':
$colorIdx = 0x28;
+
break;
case 'CCFFFF':
$colorIdx = 0x29;
+
break;
case 'CCFFCC':
$colorIdx = 0x2A;
+
break;
case 'FFFF99':
$colorIdx = 0x2B;
+
break;
case '99CCFF':
$colorIdx = 0x2C;
+
break;
case 'FF99CC':
$colorIdx = 0x2D;
+
break;
case 'CC99FF':
$colorIdx = 0x2E;
+
break;
case 'FFCC99':
$colorIdx = 0x2F;
+
break;
case '3366FF':
$colorIdx = 0x30;
+
break;
case '33CCCC':
$colorIdx = 0x31;
+
break;
case '99CC00':
$colorIdx = 0x32;
+
break;
case 'FFCC00':
$colorIdx = 0x33;
+
break;
case 'FF9900':
$colorIdx = 0x34;
+
break;
case 'FF6600':
$colorIdx = 0x35;
+
break;
case '666699':
$colorIdx = 0x36;
+
break;
case '969696':
$colorIdx = 0x37;
+
break;
case '003366':
$colorIdx = 0x38;
+
break;
case '339966':
$colorIdx = 0x39;
+
break;
case '003300':
$colorIdx = 0x3A;
+
break;
case '333300':
$colorIdx = 0x3B;
+
break;
case '993300':
$colorIdx = 0x3C;
+
break;
case '993366':
$colorIdx = 0x3D;
+
break;
case '333399':
$colorIdx = 0x3E;
+
break;
case '333333':
$colorIdx = 0x3F;
+
break;
default:
$colorIdx = 0x00;
+
break;
}
$dataBlockFont .= pack('V', $colorIdx);
@@ -3454,21 +3551,27 @@ class Worksheet extends BIFFwriter
switch ($conditional->getStyle()->getAlignment()->getHorizontal()) {
case Alignment::HORIZONTAL_GENERAL:
$blockAlign = 0;
+
break;
case Alignment::HORIZONTAL_LEFT:
$blockAlign = 1;
+
break;
case Alignment::HORIZONTAL_RIGHT:
$blockAlign = 3;
+
break;
case Alignment::HORIZONTAL_CENTER:
$blockAlign = 2;
+
break;
case Alignment::HORIZONTAL_CENTER_CONTINUOUS:
$blockAlign = 6;
+
break;
case Alignment::HORIZONTAL_JUSTIFY:
$blockAlign = 5;
+
break;
}
if ($conditional->getStyle()->getAlignment()->getWrapText() == true) {
@@ -3479,15 +3582,19 @@ class Worksheet extends BIFFwriter
switch ($conditional->getStyle()->getAlignment()->getVertical()) {
case Alignment::VERTICAL_BOTTOM:
$blockAlign = 2 << 4;
+
break;
case Alignment::VERTICAL_TOP:
$blockAlign = 0 << 4;
+
break;
case Alignment::VERTICAL_CENTER:
$blockAlign = 1 << 4;
+
break;
case Alignment::VERTICAL_JUSTIFY:
$blockAlign = 3 << 4;
+
break;
}
$blockAlign |= 0 << 7;
@@ -3514,177 +3621,233 @@ class Worksheet extends BIFFwriter
switch ($conditional->getStyle()->getBorders()->getLeft()->getBorderStyle()) {
case Border::BORDER_NONE:
$blockLineStyle |= 0x00;
+
break;
case Border::BORDER_THIN:
$blockLineStyle |= 0x01;
+
break;
case Border::BORDER_MEDIUM:
$blockLineStyle |= 0x02;
+
break;
case Border::BORDER_DASHED:
$blockLineStyle |= 0x03;
+
break;
case Border::BORDER_DOTTED:
$blockLineStyle |= 0x04;
+
break;
case Border::BORDER_THICK:
$blockLineStyle |= 0x05;
+
break;
case Border::BORDER_DOUBLE:
$blockLineStyle |= 0x06;
+
break;
case Border::BORDER_HAIR:
$blockLineStyle |= 0x07;
+
break;
case Border::BORDER_MEDIUMDASHED:
$blockLineStyle |= 0x08;
+
break;
case Border::BORDER_DASHDOT:
$blockLineStyle |= 0x09;
+
break;
case Border::BORDER_MEDIUMDASHDOT:
$blockLineStyle |= 0x0A;
+
break;
case Border::BORDER_DASHDOTDOT:
$blockLineStyle |= 0x0B;
+
break;
case Border::BORDER_MEDIUMDASHDOTDOT:
$blockLineStyle |= 0x0C;
+
break;
case Border::BORDER_SLANTDASHDOT:
$blockLineStyle |= 0x0D;
+
break;
}
switch ($conditional->getStyle()->getBorders()->getRight()->getBorderStyle()) {
case Border::BORDER_NONE:
$blockLineStyle |= 0x00 << 4;
+
break;
case Border::BORDER_THIN:
$blockLineStyle |= 0x01 << 4;
+
break;
case Border::BORDER_MEDIUM:
$blockLineStyle |= 0x02 << 4;
+
break;
case Border::BORDER_DASHED:
$blockLineStyle |= 0x03 << 4;
+
break;
case Border::BORDER_DOTTED:
$blockLineStyle |= 0x04 << 4;
+
break;
case Border::BORDER_THICK:
$blockLineStyle |= 0x05 << 4;
+
break;
case Border::BORDER_DOUBLE:
$blockLineStyle |= 0x06 << 4;
+
break;
case Border::BORDER_HAIR:
$blockLineStyle |= 0x07 << 4;
+
break;
case Border::BORDER_MEDIUMDASHED:
$blockLineStyle |= 0x08 << 4;
+
break;
case Border::BORDER_DASHDOT:
$blockLineStyle |= 0x09 << 4;
+
break;
case Border::BORDER_MEDIUMDASHDOT:
$blockLineStyle |= 0x0A << 4;
+
break;
case Border::BORDER_DASHDOTDOT:
$blockLineStyle |= 0x0B << 4;
+
break;
case Border::BORDER_MEDIUMDASHDOTDOT:
$blockLineStyle |= 0x0C << 4;
+
break;
case Border::BORDER_SLANTDASHDOT:
$blockLineStyle |= 0x0D << 4;
+
break;
}
switch ($conditional->getStyle()->getBorders()->getTop()->getBorderStyle()) {
case Border::BORDER_NONE:
$blockLineStyle |= 0x00 << 8;
+
break;
case Border::BORDER_THIN:
$blockLineStyle |= 0x01 << 8;
+
break;
case Border::BORDER_MEDIUM:
$blockLineStyle |= 0x02 << 8;
+
break;
case Border::BORDER_DASHED:
$blockLineStyle |= 0x03 << 8;
+
break;
case Border::BORDER_DOTTED:
$blockLineStyle |= 0x04 << 8;
+
break;
case Border::BORDER_THICK:
$blockLineStyle |= 0x05 << 8;
+
break;
case Border::BORDER_DOUBLE:
$blockLineStyle |= 0x06 << 8;
+
break;
case Border::BORDER_HAIR:
$blockLineStyle |= 0x07 << 8;
+
break;
case Border::BORDER_MEDIUMDASHED:
$blockLineStyle |= 0x08 << 8;
+
break;
case Border::BORDER_DASHDOT:
$blockLineStyle |= 0x09 << 8;
+
break;
case Border::BORDER_MEDIUMDASHDOT:
$blockLineStyle |= 0x0A << 8;
+
break;
case Border::BORDER_DASHDOTDOT:
$blockLineStyle |= 0x0B << 8;
+
break;
case Border::BORDER_MEDIUMDASHDOTDOT:
$blockLineStyle |= 0x0C << 8;
+
break;
case Border::BORDER_SLANTDASHDOT:
$blockLineStyle |= 0x0D << 8;
+
break;
}
switch ($conditional->getStyle()->getBorders()->getBottom()->getBorderStyle()) {
case Border::BORDER_NONE:
$blockLineStyle |= 0x00 << 12;
+
break;
case Border::BORDER_THIN:
$blockLineStyle |= 0x01 << 12;
+
break;
case Border::BORDER_MEDIUM:
$blockLineStyle |= 0x02 << 12;
+
break;
case Border::BORDER_DASHED:
$blockLineStyle |= 0x03 << 12;
+
break;
case Border::BORDER_DOTTED:
$blockLineStyle |= 0x04 << 12;
+
break;
case Border::BORDER_THICK:
$blockLineStyle |= 0x05 << 12;
+
break;
case Border::BORDER_DOUBLE:
$blockLineStyle |= 0x06 << 12;
+
break;
case Border::BORDER_HAIR:
$blockLineStyle |= 0x07 << 12;
+
break;
case Border::BORDER_MEDIUMDASHED:
$blockLineStyle |= 0x08 << 12;
+
break;
case Border::BORDER_DASHDOT:
$blockLineStyle |= 0x09 << 12;
+
break;
case Border::BORDER_MEDIUMDASHDOT:
$blockLineStyle |= 0x0A << 12;
+
break;
case Border::BORDER_DASHDOTDOT:
$blockLineStyle |= 0x0B << 12;
+
break;
case Border::BORDER_MEDIUMDASHDOTDOT:
$blockLineStyle |= 0x0C << 12;
+
break;
case Border::BORDER_SLANTDASHDOT:
$blockLineStyle |= 0x0D << 12;
+
break;
}
//@todo writeCFRule() => $blockLineStyle => Index Color for left line
@@ -3698,45 +3861,59 @@ class Worksheet extends BIFFwriter
switch ($conditional->getStyle()->getBorders()->getDiagonal()->getBorderStyle()) {
case Border::BORDER_NONE:
$blockColor |= 0x00 << 21;
+
break;
case Border::BORDER_THIN:
$blockColor |= 0x01 << 21;
+
break;
case Border::BORDER_MEDIUM:
$blockColor |= 0x02 << 21;
+
break;
case Border::BORDER_DASHED:
$blockColor |= 0x03 << 21;
+
break;
case Border::BORDER_DOTTED:
$blockColor |= 0x04 << 21;
+
break;
case Border::BORDER_THICK:
$blockColor |= 0x05 << 21;
+
break;
case Border::BORDER_DOUBLE:
$blockColor |= 0x06 << 21;
+
break;
case Border::BORDER_HAIR:
$blockColor |= 0x07 << 21;
+
break;
case Border::BORDER_MEDIUMDASHED:
$blockColor |= 0x08 << 21;
+
break;
case Border::BORDER_DASHDOT:
$blockColor |= 0x09 << 21;
+
break;
case Border::BORDER_MEDIUMDASHDOT:
$blockColor |= 0x0A << 21;
+
break;
case Border::BORDER_DASHDOTDOT:
$blockColor |= 0x0B << 21;
+
break;
case Border::BORDER_MEDIUMDASHDOTDOT:
$blockColor |= 0x0C << 21;
+
break;
case Border::BORDER_SLANTDASHDOT:
$blockColor |= 0x0D << 21;
+
break;
}
$dataBlockBorder = pack('vv', $blockLineStyle, $blockColor);
@@ -3747,417 +3924,553 @@ class Worksheet extends BIFFwriter
switch ($conditional->getStyle()->getFill()->getFillType()) {
case Fill::FILL_NONE:
$blockFillPatternStyle = 0x00;
+
break;
case Fill::FILL_SOLID:
$blockFillPatternStyle = 0x01;
+
break;
case Fill::FILL_PATTERN_MEDIUMGRAY:
$blockFillPatternStyle = 0x02;
+
break;
case Fill::FILL_PATTERN_DARKGRAY:
$blockFillPatternStyle = 0x03;
+
break;
case Fill::FILL_PATTERN_LIGHTGRAY:
$blockFillPatternStyle = 0x04;
+
break;
case Fill::FILL_PATTERN_DARKHORIZONTAL:
$blockFillPatternStyle = 0x05;
+
break;
case Fill::FILL_PATTERN_DARKVERTICAL:
$blockFillPatternStyle = 0x06;
+
break;
case Fill::FILL_PATTERN_DARKDOWN:
$blockFillPatternStyle = 0x07;
+
break;
case Fill::FILL_PATTERN_DARKUP:
$blockFillPatternStyle = 0x08;
+
break;
case Fill::FILL_PATTERN_DARKGRID:
$blockFillPatternStyle = 0x09;
+
break;
case Fill::FILL_PATTERN_DARKTRELLIS:
$blockFillPatternStyle = 0x0A;
+
break;
case Fill::FILL_PATTERN_LIGHTHORIZONTAL:
$blockFillPatternStyle = 0x0B;
+
break;
case Fill::FILL_PATTERN_LIGHTVERTICAL:
$blockFillPatternStyle = 0x0C;
+
break;
case Fill::FILL_PATTERN_LIGHTDOWN:
$blockFillPatternStyle = 0x0D;
+
break;
case Fill::FILL_PATTERN_LIGHTUP:
$blockFillPatternStyle = 0x0E;
+
break;
case Fill::FILL_PATTERN_LIGHTGRID:
$blockFillPatternStyle = 0x0F;
+
break;
case Fill::FILL_PATTERN_LIGHTTRELLIS:
$blockFillPatternStyle = 0x10;
+
break;
case Fill::FILL_PATTERN_GRAY125:
$blockFillPatternStyle = 0x11;
+
break;
case Fill::FILL_PATTERN_GRAY0625:
$blockFillPatternStyle = 0x12;
+
break;
case Fill::FILL_GRADIENT_LINEAR:
$blockFillPatternStyle = 0x00;
+
break; // does not exist in BIFF8
case Fill::FILL_GRADIENT_PATH:
$blockFillPatternStyle = 0x00;
+
break; // does not exist in BIFF8
default:
$blockFillPatternStyle = 0x00;
+
break;
}
// Color
switch ($conditional->getStyle()->getFill()->getStartColor()->getRGB()) {
case '000000':
$colorIdxBg = 0x08;
+
break;
case 'FFFFFF':
$colorIdxBg = 0x09;
+
break;
case 'FF0000':
$colorIdxBg = 0x0A;
+
break;
case '00FF00':
$colorIdxBg = 0x0B;
+
break;
case '0000FF':
$colorIdxBg = 0x0C;
+
break;
case 'FFFF00':
$colorIdxBg = 0x0D;
+
break;
case 'FF00FF':
$colorIdxBg = 0x0E;
+
break;
case '00FFFF':
$colorIdxBg = 0x0F;
+
break;
case '800000':
$colorIdxBg = 0x10;
+
break;
case '008000':
$colorIdxBg = 0x11;
+
break;
case '000080':
$colorIdxBg = 0x12;
+
break;
case '808000':
$colorIdxBg = 0x13;
+
break;
case '800080':
$colorIdxBg = 0x14;
+
break;
case '008080':
$colorIdxBg = 0x15;
+
break;
case 'C0C0C0':
$colorIdxBg = 0x16;
+
break;
case '808080':
$colorIdxBg = 0x17;
+
break;
case '9999FF':
$colorIdxBg = 0x18;
+
break;
case '993366':
$colorIdxBg = 0x19;
+
break;
case 'FFFFCC':
$colorIdxBg = 0x1A;
+
break;
case 'CCFFFF':
$colorIdxBg = 0x1B;
+
break;
case '660066':
$colorIdxBg = 0x1C;
+
break;
case 'FF8080':
$colorIdxBg = 0x1D;
+
break;
case '0066CC':
$colorIdxBg = 0x1E;
+
break;
case 'CCCCFF':
$colorIdxBg = 0x1F;
+
break;
case '000080':
$colorIdxBg = 0x20;
+
break;
case 'FF00FF':
$colorIdxBg = 0x21;
+
break;
case 'FFFF00':
$colorIdxBg = 0x22;
+
break;
case '00FFFF':
$colorIdxBg = 0x23;
+
break;
case '800080':
$colorIdxBg = 0x24;
+
break;
case '800000':
$colorIdxBg = 0x25;
+
break;
case '008080':
$colorIdxBg = 0x26;
+
break;
case '0000FF':
$colorIdxBg = 0x27;
+
break;
case '00CCFF':
$colorIdxBg = 0x28;
+
break;
case 'CCFFFF':
$colorIdxBg = 0x29;
+
break;
case 'CCFFCC':
$colorIdxBg = 0x2A;
+
break;
case 'FFFF99':
$colorIdxBg = 0x2B;
+
break;
case '99CCFF':
$colorIdxBg = 0x2C;
+
break;
case 'FF99CC':
$colorIdxBg = 0x2D;
+
break;
case 'CC99FF':
$colorIdxBg = 0x2E;
+
break;
case 'FFCC99':
$colorIdxBg = 0x2F;
+
break;
case '3366FF':
$colorIdxBg = 0x30;
+
break;
case '33CCCC':
$colorIdxBg = 0x31;
+
break;
case '99CC00':
$colorIdxBg = 0x32;
+
break;
case 'FFCC00':
$colorIdxBg = 0x33;
+
break;
case 'FF9900':
$colorIdxBg = 0x34;
+
break;
case 'FF6600':
$colorIdxBg = 0x35;
+
break;
case '666699':
$colorIdxBg = 0x36;
+
break;
case '969696':
$colorIdxBg = 0x37;
+
break;
case '003366':
$colorIdxBg = 0x38;
+
break;
case '339966':
$colorIdxBg = 0x39;
+
break;
case '003300':
$colorIdxBg = 0x3A;
+
break;
case '333300':
$colorIdxBg = 0x3B;
+
break;
case '993300':
$colorIdxBg = 0x3C;
+
break;
case '993366':
$colorIdxBg = 0x3D;
+
break;
case '333399':
$colorIdxBg = 0x3E;
+
break;
case '333333':
$colorIdxBg = 0x3F;
+
break;
default:
$colorIdxBg = 0x41;
+
break;
}
// Fg Color
switch ($conditional->getStyle()->getFill()->getEndColor()->getRGB()) {
case '000000':
$colorIdxFg = 0x08;
+
break;
case 'FFFFFF':
$colorIdxFg = 0x09;
+
break;
case 'FF0000':
$colorIdxFg = 0x0A;
+
break;
case '00FF00':
$colorIdxFg = 0x0B;
+
break;
case '0000FF':
$colorIdxFg = 0x0C;
+
break;
case 'FFFF00':
$colorIdxFg = 0x0D;
+
break;
case 'FF00FF':
$colorIdxFg = 0x0E;
+
break;
case '00FFFF':
$colorIdxFg = 0x0F;
+
break;
case '800000':
$colorIdxFg = 0x10;
+
break;
case '008000':
$colorIdxFg = 0x11;
+
break;
case '000080':
$colorIdxFg = 0x12;
+
break;
case '808000':
$colorIdxFg = 0x13;
+
break;
case '800080':
$colorIdxFg = 0x14;
+
break;
case '008080':
$colorIdxFg = 0x15;
+
break;
case 'C0C0C0':
$colorIdxFg = 0x16;
+
break;
case '808080':
$colorIdxFg = 0x17;
+
break;
case '9999FF':
$colorIdxFg = 0x18;
+
break;
case '993366':
$colorIdxFg = 0x19;
+
break;
case 'FFFFCC':
$colorIdxFg = 0x1A;
+
break;
case 'CCFFFF':
$colorIdxFg = 0x1B;
+
break;
case '660066':
$colorIdxFg = 0x1C;
+
break;
case 'FF8080':
$colorIdxFg = 0x1D;
+
break;
case '0066CC':
$colorIdxFg = 0x1E;
+
break;
case 'CCCCFF':
$colorIdxFg = 0x1F;
+
break;
case '000080':
$colorIdxFg = 0x20;
+
break;
case 'FF00FF':
$colorIdxFg = 0x21;
+
break;
case 'FFFF00':
$colorIdxFg = 0x22;
+
break;
case '00FFFF':
$colorIdxFg = 0x23;
+
break;
case '800080':
$colorIdxFg = 0x24;
+
break;
case '800000':
$colorIdxFg = 0x25;
+
break;
case '008080':
$colorIdxFg = 0x26;
+
break;
case '0000FF':
$colorIdxFg = 0x27;
+
break;
case '00CCFF':
$colorIdxFg = 0x28;
+
break;
case 'CCFFFF':
$colorIdxFg = 0x29;
+
break;
case 'CCFFCC':
$colorIdxFg = 0x2A;
+
break;
case 'FFFF99':
$colorIdxFg = 0x2B;
+
break;
case '99CCFF':
$colorIdxFg = 0x2C;
+
break;
case 'FF99CC':
$colorIdxFg = 0x2D;
+
break;
case 'CC99FF':
$colorIdxFg = 0x2E;
+
break;
case 'FFCC99':
$colorIdxFg = 0x2F;
+
break;
case '3366FF':
$colorIdxFg = 0x30;
+
break;
case '33CCCC':
$colorIdxFg = 0x31;
+
break;
case '99CC00':
$colorIdxFg = 0x32;
+
break;
case 'FFCC00':
$colorIdxFg = 0x33;
+
break;
case 'FF9900':
$colorIdxFg = 0x34;
+
break;
case 'FF6600':
$colorIdxFg = 0x35;
+
break;
case '666699':
$colorIdxFg = 0x36;
+
break;
case '969696':
$colorIdxFg = 0x37;
+
break;
case '003366':
$colorIdxFg = 0x38;
+
break;
case '339966':
$colorIdxFg = 0x39;
+
break;
case '003300':
$colorIdxFg = 0x3A;
+
break;
case '333300':
$colorIdxFg = 0x3B;
+
break;
case '993300':
$colorIdxFg = 0x3C;
+
break;
case '993366':
$colorIdxFg = 0x3D;
+
break;
case '333399':
$colorIdxFg = 0x3E;
+
break;
case '333333':
$colorIdxFg = 0x3F;
+
break;
default:
$colorIdxFg = 0x40;
+
break;
}
$dataBlockFill = pack('v', $blockFillPatternStyle);
@@ -4189,10 +4502,10 @@ class Worksheet extends BIFFwriter
if ($bFormatProt == 1) {
$data .= $dataBlockProtection;
}
- if (!is_null($operand1)) {
+ if ($operand1 !== null) {
$data .= $operand1;
}
- if (!is_null($operand2)) {
+ if ($operand2 !== null) {
$data .= $operand2;
}
$header = pack('vv', $record, strlen($data));
@@ -4224,16 +4537,16 @@ class Worksheet extends BIFFwriter
if (!is_numeric($arrCoord[0])) {
$arrCoord[0] = Cell::columnIndexFromString($arrCoord[0]);
}
- if (is_null($numColumnMin) || ($numColumnMin > $arrCoord[0])) {
+ if ($numColumnMin === null || ($numColumnMin > $arrCoord[0])) {
$numColumnMin = $arrCoord[0];
}
- if (is_null($numColumnMax) || ($numColumnMax < $arrCoord[0])) {
+ if ($numColumnMax === null || ($numColumnMax < $arrCoord[0])) {
$numColumnMax = $arrCoord[0];
}
- if (is_null($numRowMin) || ($numRowMin > $arrCoord[1])) {
+ if ($numRowMin === null || ($numRowMin > $arrCoord[1])) {
$numRowMin = $arrCoord[1];
}
- if (is_null($numRowMax) || ($numRowMax < $arrCoord[1])) {
+ if ($numRowMax === null || ($numRowMax < $arrCoord[1])) {
$numRowMax = $arrCoord[1];
}
}
diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php
index 56e7d0b1..f639fdc8 100644
--- a/src/PhpSpreadsheet/Writer/Xlsx.php
+++ b/src/PhpSpreadsheet/Writer/Xlsx.php
@@ -225,7 +225,7 @@ class Xlsx extends BaseWriter implements IWriter
//if hasMacros, add the vbaProject.bin file, Certificate file(if exists)
if ($this->spreadSheet->hasMacros()) {
$macrosCode = $this->spreadSheet->getMacrosCode();
- if (!is_null($macrosCode)) {
+ if ($macrosCode !== null) {
// we have the code ?
$zip->addFromString('xl/vbaProject.bin', $macrosCode); //allways in 'xl', allways named vbaProject.bin
if ($this->spreadSheet->hasMacrosCertificate()) {
@@ -399,6 +399,7 @@ class Xlsx extends BaseWriter implements IWriter
if ($this->spreadSheet !== null) {
return $this->spreadSheet;
}
+
throw new WriterException('No Spreadsheet object assigned.');
}
diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php
index c43ffdc9..783ed5e2 100644
--- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php
+++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php
@@ -109,7 +109,7 @@ class Chart extends WriterPart
*/
private function writeTitle(XMLWriter $objWriter, Title $title = null)
{
- if (is_null($title)) {
+ if ($title === null) {
return;
}
@@ -154,7 +154,7 @@ class Chart extends WriterPart
*/
private function writeLegend(XMLWriter $objWriter, Legend $legend = null)
{
- if (is_null($legend)) {
+ if ($legend === null) {
return;
}
@@ -210,7 +210,7 @@ class Chart extends WriterPart
*/
private function writePlotArea(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, PlotArea $plotArea, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null)
{
- if (is_null($plotArea)) {
+ if ($plotArea === null) {
return;
}
@@ -420,7 +420,7 @@ class Chart extends WriterPart
$objWriter->writeAttribute('val', 'b');
$objWriter->endElement();
- if (!is_null($xAxisLabel)) {
+ if ($xAxisLabel !== null) {
$objWriter->startElement('c:title');
$objWriter->startElement('c:tx');
$objWriter->startElement('c:rich');
@@ -533,13 +533,13 @@ class Chart extends WriterPart
$objWriter->startElement('c:scaling');
- if (!is_null($xAxis->getAxisOptionsProperty('maximum'))) {
+ if ($xAxis->getAxisOptionsProperty('maximum') !== null) {
$objWriter->startElement('c:max');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('maximum'));
$objWriter->endElement();
}
- if (!is_null($xAxis->getAxisOptionsProperty('minimum'))) {
+ if ($xAxis->getAxisOptionsProperty('minimum') !== null) {
$objWriter->startElement('c:min');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minimum'));
$objWriter->endElement();
@@ -562,7 +562,7 @@ class Chart extends WriterPart
$objWriter->startElement('c:majorGridlines');
$objWriter->startElement('c:spPr');
- if (!is_null($majorGridlines->getLineColorProperty('value'))) {
+ if ($majorGridlines->getLineColorProperty('value') !== null) {
$objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', $majorGridlines->getLineStyleProperty('width'));
$objWriter->startElement('a:solidFill');
@@ -587,7 +587,7 @@ class Chart extends WriterPart
$objWriter->endElement();
}
- if (!is_null($majorGridlines->getLineStyleProperty(['arrow', 'head', 'type']))) {
+ if ($majorGridlines->getLineStyleProperty(['arrow', 'head', 'type']) !== null) {
$objWriter->startElement('a:headEnd');
$objWriter->writeAttribute('type', $majorGridlines->getLineStyleProperty(['arrow', 'head', 'type']));
$objWriter->writeAttribute('w', $majorGridlines->getLineStyleArrowParameters('head', 'w'));
@@ -595,7 +595,7 @@ class Chart extends WriterPart
$objWriter->endElement();
}
- if (!is_null($majorGridlines->getLineStyleProperty(['arrow', 'end', 'type']))) {
+ if ($majorGridlines->getLineStyleProperty(['arrow', 'end', 'type']) !== null) {
$objWriter->startElement('a:tailEnd');
$objWriter->writeAttribute('type', $majorGridlines->getLineStyleProperty(['arrow', 'end', 'type']));
$objWriter->writeAttribute('w', $majorGridlines->getLineStyleArrowParameters('end', 'w'));
@@ -606,7 +606,7 @@ class Chart extends WriterPart
}
$objWriter->startElement('a:effectLst');
- if (!is_null($majorGridlines->getGlowSize())) {
+ if ($majorGridlines->getGlowSize() !== null) {
$objWriter->startElement('a:glow');
$objWriter->writeAttribute('rad', $majorGridlines->getGlowSize());
$objWriter->startElement("a:{$majorGridlines->getGlowColor('type')}");
@@ -618,30 +618,30 @@ class Chart extends WriterPart
$objWriter->endElement(); //end glow
}
- if (!is_null($majorGridlines->getShadowProperty('presets'))) {
+ if ($majorGridlines->getShadowProperty('presets') !== null) {
$objWriter->startElement("a:{$majorGridlines->getShadowProperty('effect')}");
- if (!is_null($majorGridlines->getShadowProperty('blur'))) {
+ if ($majorGridlines->getShadowProperty('blur') !== null) {
$objWriter->writeAttribute('blurRad', $majorGridlines->getShadowProperty('blur'));
}
- if (!is_null($majorGridlines->getShadowProperty('distance'))) {
+ if ($majorGridlines->getShadowProperty('distance') !== null) {
$objWriter->writeAttribute('dist', $majorGridlines->getShadowProperty('distance'));
}
- if (!is_null($majorGridlines->getShadowProperty('direction'))) {
+ if ($majorGridlines->getShadowProperty('direction') !== null) {
$objWriter->writeAttribute('dir', $majorGridlines->getShadowProperty('direction'));
}
- if (!is_null($majorGridlines->getShadowProperty('algn'))) {
+ if ($majorGridlines->getShadowProperty('algn') !== null) {
$objWriter->writeAttribute('algn', $majorGridlines->getShadowProperty('algn'));
}
- if (!is_null($majorGridlines->getShadowProperty(['size', 'sx']))) {
+ if ($majorGridlines->getShadowProperty(['size', 'sx']) !== null) {
$objWriter->writeAttribute('sx', $majorGridlines->getShadowProperty(['size', 'sx']));
}
- if (!is_null($majorGridlines->getShadowProperty(['size', 'sy']))) {
+ if ($majorGridlines->getShadowProperty(['size', 'sy']) !== null) {
$objWriter->writeAttribute('sy', $majorGridlines->getShadowProperty(['size', 'sy']));
}
- if (!is_null($majorGridlines->getShadowProperty(['size', 'kx']))) {
+ if ($majorGridlines->getShadowProperty(['size', 'kx']) !== null) {
$objWriter->writeAttribute('kx', $majorGridlines->getShadowProperty(['size', 'kx']));
}
- if (!is_null($majorGridlines->getShadowProperty('rotWithShape'))) {
+ if ($majorGridlines->getShadowProperty('rotWithShape') !== null) {
$objWriter->writeAttribute('rotWithShape', $majorGridlines->getShadowProperty('rotWithShape'));
}
$objWriter->startElement("a:{$majorGridlines->getShadowProperty(['color', 'type'])}");
@@ -655,7 +655,7 @@ class Chart extends WriterPart
$objWriter->endElement(); //end shadow
}
- if (!is_null($majorGridlines->getSoftEdgesSize())) {
+ if ($majorGridlines->getSoftEdgesSize() !== null) {
$objWriter->startElement('a:softEdge');
$objWriter->writeAttribute('rad', $majorGridlines->getSoftEdgesSize());
$objWriter->endElement(); //end softEdge
@@ -669,7 +669,7 @@ class Chart extends WriterPart
$objWriter->startElement('c:minorGridlines');
$objWriter->startElement('c:spPr');
- if (!is_null($minorGridlines->getLineColorProperty('value'))) {
+ if ($minorGridlines->getLineColorProperty('value') !== null) {
$objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', $minorGridlines->getLineStyleProperty('width'));
$objWriter->startElement('a:solidFill');
@@ -694,7 +694,7 @@ class Chart extends WriterPart
$objWriter->endElement();
}
- if (!is_null($minorGridlines->getLineStyleProperty(['arrow', 'head', 'type']))) {
+ if ($minorGridlines->getLineStyleProperty(['arrow', 'head', 'type']) !== null) {
$objWriter->startElement('a:headEnd');
$objWriter->writeAttribute('type', $minorGridlines->getLineStyleProperty(['arrow', 'head', 'type']));
$objWriter->writeAttribute('w', $minorGridlines->getLineStyleArrowParameters('head', 'w'));
@@ -702,7 +702,7 @@ class Chart extends WriterPart
$objWriter->endElement();
}
- if (!is_null($minorGridlines->getLineStyleProperty(['arrow', 'end', 'type']))) {
+ if ($minorGridlines->getLineStyleProperty(['arrow', 'end', 'type']) !== null) {
$objWriter->startElement('a:tailEnd');
$objWriter->writeAttribute('type', $minorGridlines->getLineStyleProperty(['arrow', 'end', 'type']));
$objWriter->writeAttribute('w', $minorGridlines->getLineStyleArrowParameters('end', 'w'));
@@ -714,7 +714,7 @@ class Chart extends WriterPart
$objWriter->startElement('a:effectLst');
- if (!is_null($minorGridlines->getGlowSize())) {
+ if ($minorGridlines->getGlowSize() !== null) {
$objWriter->startElement('a:glow');
$objWriter->writeAttribute('rad', $minorGridlines->getGlowSize());
$objWriter->startElement("a:{$minorGridlines->getGlowColor('type')}");
@@ -726,30 +726,30 @@ class Chart extends WriterPart
$objWriter->endElement(); //end glow
}
- if (!is_null($minorGridlines->getShadowProperty('presets'))) {
+ if ($minorGridlines->getShadowProperty('presets') !== null) {
$objWriter->startElement("a:{$minorGridlines->getShadowProperty('effect')}");
- if (!is_null($minorGridlines->getShadowProperty('blur'))) {
+ if ($minorGridlines->getShadowProperty('blur') !== null) {
$objWriter->writeAttribute('blurRad', $minorGridlines->getShadowProperty('blur'));
}
- if (!is_null($minorGridlines->getShadowProperty('distance'))) {
+ if ($minorGridlines->getShadowProperty('distance') !== null) {
$objWriter->writeAttribute('dist', $minorGridlines->getShadowProperty('distance'));
}
- if (!is_null($minorGridlines->getShadowProperty('direction'))) {
+ if ($minorGridlines->getShadowProperty('direction') !== null) {
$objWriter->writeAttribute('dir', $minorGridlines->getShadowProperty('direction'));
}
- if (!is_null($minorGridlines->getShadowProperty('algn'))) {
+ if ($minorGridlines->getShadowProperty('algn') !== null) {
$objWriter->writeAttribute('algn', $minorGridlines->getShadowProperty('algn'));
}
- if (!is_null($minorGridlines->getShadowProperty(['size', 'sx']))) {
+ if ($minorGridlines->getShadowProperty(['size', 'sx']) !== null) {
$objWriter->writeAttribute('sx', $minorGridlines->getShadowProperty(['size', 'sx']));
}
- if (!is_null($minorGridlines->getShadowProperty(['size', 'sy']))) {
+ if ($minorGridlines->getShadowProperty(['size', 'sy']) !== null) {
$objWriter->writeAttribute('sy', $minorGridlines->getShadowProperty(['size', 'sy']));
}
- if (!is_null($minorGridlines->getShadowProperty(['size', 'kx']))) {
+ if ($minorGridlines->getShadowProperty(['size', 'kx']) !== null) {
$objWriter->writeAttribute('kx', $minorGridlines->getShadowProperty(['size', 'kx']));
}
- if (!is_null($minorGridlines->getShadowProperty('rotWithShape'))) {
+ if ($minorGridlines->getShadowProperty('rotWithShape') !== null) {
$objWriter->writeAttribute('rotWithShape', $minorGridlines->getShadowProperty('rotWithShape'));
}
$objWriter->startElement("a:{$minorGridlines->getShadowProperty(['color', 'type'])}");
@@ -761,7 +761,7 @@ class Chart extends WriterPart
$objWriter->endElement(); //end shadow
}
- if (!is_null($minorGridlines->getSoftEdgesSize())) {
+ if ($minorGridlines->getSoftEdgesSize() !== null) {
$objWriter->startElement('a:softEdge');
$objWriter->writeAttribute('rad', $minorGridlines->getSoftEdgesSize());
$objWriter->endElement(); //end softEdge
@@ -772,7 +772,7 @@ class Chart extends WriterPart
$objWriter->endElement(); //end minorGridLines
}
- if (!is_null($yAxisLabel)) {
+ if ($yAxisLabel !== null) {
$objWriter->startElement('c:title');
$objWriter->startElement('c:tx');
$objWriter->startElement('c:rich');
@@ -831,7 +831,7 @@ class Chart extends WriterPart
$objWriter->startElement('c:spPr');
- if (!is_null($xAxis->getFillProperty('value'))) {
+ if ($xAxis->getFillProperty('value') !== null) {
$objWriter->startElement('a:solidFill');
$objWriter->startElement('a:' . $xAxis->getFillProperty('type'));
$objWriter->writeAttribute('val', $xAxis->getFillProperty('value'));
@@ -848,7 +848,7 @@ class Chart extends WriterPart
$objWriter->writeAttribute('cap', $xAxis->getLineStyleProperty('cap'));
$objWriter->writeAttribute('cmpd', $xAxis->getLineStyleProperty('compound'));
- if (!is_null($xAxis->getLineProperty('value'))) {
+ if ($xAxis->getLineProperty('value') !== null) {
$objWriter->startElement('a:solidFill');
$objWriter->startElement('a:' . $xAxis->getLineProperty('type'));
$objWriter->writeAttribute('val', $xAxis->getLineProperty('value'));
@@ -872,7 +872,7 @@ class Chart extends WriterPart
$objWriter->endElement();
}
- if (!is_null($xAxis->getLineStyleProperty(['arrow', 'head', 'type']))) {
+ if ($xAxis->getLineStyleProperty(['arrow', 'head', 'type']) !== null) {
$objWriter->startElement('a:headEnd');
$objWriter->writeAttribute('type', $xAxis->getLineStyleProperty(['arrow', 'head', 'type']));
$objWriter->writeAttribute('w', $xAxis->getLineStyleArrowWidth('head'));
@@ -880,7 +880,7 @@ class Chart extends WriterPart
$objWriter->endElement();
}
- if (!is_null($xAxis->getLineStyleProperty(['arrow', 'end', 'type']))) {
+ if ($xAxis->getLineStyleProperty(['arrow', 'end', 'type']) !== null) {
$objWriter->startElement('a:tailEnd');
$objWriter->writeAttribute('type', $xAxis->getLineStyleProperty(['arrow', 'end', 'type']));
$objWriter->writeAttribute('w', $xAxis->getLineStyleArrowWidth('end'));
@@ -892,7 +892,7 @@ class Chart extends WriterPart
$objWriter->startElement('a:effectLst');
- if (!is_null($xAxis->getGlowProperty('size'))) {
+ if ($xAxis->getGlowProperty('size') !== null) {
$objWriter->startElement('a:glow');
$objWriter->writeAttribute('rad', $xAxis->getGlowProperty('size'));
$objWriter->startElement("a:{$xAxis->getGlowProperty(['color', 'type'])}");
@@ -904,31 +904,31 @@ class Chart extends WriterPart
$objWriter->endElement();
}
- if (!is_null($xAxis->getShadowProperty('presets'))) {
+ if ($xAxis->getShadowProperty('presets') !== null) {
$objWriter->startElement("a:{$xAxis->getShadowProperty('effect')}");
- if (!is_null($xAxis->getShadowProperty('blur'))) {
+ if ($xAxis->getShadowProperty('blur') !== null) {
$objWriter->writeAttribute('blurRad', $xAxis->getShadowProperty('blur'));
}
- if (!is_null($xAxis->getShadowProperty('distance'))) {
+ if ($xAxis->getShadowProperty('distance') !== null) {
$objWriter->writeAttribute('dist', $xAxis->getShadowProperty('distance'));
}
- if (!is_null($xAxis->getShadowProperty('direction'))) {
+ if ($xAxis->getShadowProperty('direction') !== null) {
$objWriter->writeAttribute('dir', $xAxis->getShadowProperty('direction'));
}
- if (!is_null($xAxis->getShadowProperty('algn'))) {
+ if ($xAxis->getShadowProperty('algn') !== null) {
$objWriter->writeAttribute('algn', $xAxis->getShadowProperty('algn'));
}
- if (!is_null($xAxis->getShadowProperty(['size', 'sx']))) {
+ if ($xAxis->getShadowProperty(['size', 'sx']) !== null) {
$objWriter->writeAttribute('sx', $xAxis->getShadowProperty(['size', 'sx']));
}
- if (!is_null($xAxis->getShadowProperty(['size', 'sy']))) {
+ if ($xAxis->getShadowProperty(['size', 'sy']) !== null) {
$objWriter->writeAttribute('sy', $xAxis->getShadowProperty(['size', 'sy']));
}
- if (!is_null($xAxis->getShadowProperty(['size', 'kx']))) {
+ if ($xAxis->getShadowProperty(['size', 'kx']) !== null) {
$objWriter->writeAttribute('kx', $xAxis->getShadowProperty(['size', 'kx']));
}
- if (!is_null($xAxis->getShadowProperty('rotWithShape'))) {
+ if ($xAxis->getShadowProperty('rotWithShape') !== null) {
$objWriter->writeAttribute('rotWithShape', $xAxis->getShadowProperty('rotWithShape'));
}
@@ -942,7 +942,7 @@ class Chart extends WriterPart
$objWriter->endElement();
}
- if (!is_null($xAxis->getSoftEdgesSize())) {
+ if ($xAxis->getSoftEdgesSize() !== null) {
$objWriter->startElement('a:softEdge');
$objWriter->writeAttribute('rad', $xAxis->getSoftEdgesSize());
$objWriter->endElement();
@@ -956,7 +956,7 @@ class Chart extends WriterPart
$objWriter->writeAttribute('val', $id2);
$objWriter->endElement();
- if (!is_null($xAxis->getAxisOptionsProperty('horizontal_crosses_value'))) {
+ if ($xAxis->getAxisOptionsProperty('horizontal_crosses_value') !== null) {
$objWriter->startElement('c:crossesAt');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('horizontal_crosses_value'));
$objWriter->endElement();
@@ -970,13 +970,13 @@ class Chart extends WriterPart
$objWriter->writeAttribute('val', 'midCat');
$objWriter->endElement();
- if (!is_null($xAxis->getAxisOptionsProperty('major_unit'))) {
+ if ($xAxis->getAxisOptionsProperty('major_unit') !== null) {
$objWriter->startElement('c:majorUnit');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('major_unit'));
$objWriter->endElement();
}
- if (!is_null($xAxis->getAxisOptionsProperty('minor_unit'))) {
+ if ($xAxis->getAxisOptionsProperty('minor_unit') !== null) {
$objWriter->startElement('c:minorUnit');
$objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minor_unit'));
$objWriter->endElement();
@@ -1001,7 +1001,7 @@ class Chart extends WriterPart
*
* @throws WriterException
*
- * @return string|array
+ * @return array|string
*/
private static function getChartType($plotArea)
{
@@ -1038,7 +1038,7 @@ class Chart extends WriterPart
*/
private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet)
{
- if (is_null($plotGroup)) {
+ if ($plotGroup === null) {
return;
}
@@ -1048,7 +1048,7 @@ class Chart extends WriterPart
$objWriter->endElement();
}
- if (!is_null($plotGroup->getPlotGrouping())) {
+ if ($plotGroup->getPlotGrouping() !== null) {
$plotGroupingType = $plotGroup->getPlotGrouping();
$objWriter->startElement('c:grouping');
$objWriter->writeAttribute('val', $plotGroupingType);
@@ -1172,7 +1172,7 @@ class Chart extends WriterPart
$catIsMultiLevelSeries = $catIsMultiLevelSeries || $plotSeriesCategory->isMultiLevelSeries();
if (($groupType == DataSeries::TYPE_PIECHART) || ($groupType == DataSeries::TYPE_PIECHART_3D) || ($groupType == DataSeries::TYPE_DONUTCHART)) {
- if (!is_null($plotGroup->getPlotStyle())) {
+ if ($plotGroup->getPlotStyle() !== null) {
$plotStyle = $plotGroup->getPlotStyle();
if ($plotStyle) {
$objWriter->startElement('c:explosion');
@@ -1226,7 +1226,7 @@ class Chart extends WriterPart
*/
private function writePlotSeriesLabel($plotSeriesLabel, $objWriter)
{
- if (is_null($plotSeriesLabel)) {
+ if ($plotSeriesLabel === null) {
return;
}
@@ -1263,7 +1263,7 @@ class Chart extends WriterPart
*/
private function writePlotSeriesValues($plotSeriesValues, XMLWriter $objWriter, $groupType, $dataType = 'str')
{
- if (is_null($plotSeriesValues)) {
+ if ($plotSeriesValues === null) {
return;
}
@@ -1355,7 +1355,7 @@ class Chart extends WriterPart
*/
private function writeBubbles($plotSeriesValues, $objWriter)
{
- if (is_null($plotSeriesValues)) {
+ if ($plotSeriesValues === null) {
return;
}
@@ -1404,53 +1404,53 @@ class Chart extends WriterPart
{
$objWriter->startElement('c:layout');
- if (!is_null($layout)) {
+ if ($layout !== null) {
$objWriter->startElement('c:manualLayout');
$layoutTarget = $layout->getLayoutTarget();
- if (!is_null($layoutTarget)) {
+ if ($layoutTarget !== null) {
$objWriter->startElement('c:layoutTarget');
$objWriter->writeAttribute('val', $layoutTarget);
$objWriter->endElement();
}
$xMode = $layout->getXMode();
- if (!is_null($xMode)) {
+ if ($xMode !== null) {
$objWriter->startElement('c:xMode');
$objWriter->writeAttribute('val', $xMode);
$objWriter->endElement();
}
$yMode = $layout->getYMode();
- if (!is_null($yMode)) {
+ if ($yMode !== null) {
$objWriter->startElement('c:yMode');
$objWriter->writeAttribute('val', $yMode);
$objWriter->endElement();
}
$x = $layout->getXPosition();
- if (!is_null($x)) {
+ if ($x !== null) {
$objWriter->startElement('c:x');
$objWriter->writeAttribute('val', $x);
$objWriter->endElement();
}
$y = $layout->getYPosition();
- if (!is_null($y)) {
+ if ($y !== null) {
$objWriter->startElement('c:y');
$objWriter->writeAttribute('val', $y);
$objWriter->endElement();
}
$w = $layout->getWidth();
- if (!is_null($w)) {
+ if ($w !== null) {
$objWriter->startElement('c:w');
$objWriter->writeAttribute('val', $w);
$objWriter->endElement();
}
$h = $layout->getHeight();
- if (!is_null($h)) {
+ if ($h !== null) {
$objWriter->startElement('c:h');
$objWriter->writeAttribute('val', $h);
$objWriter->endElement();
diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php
index 354d4ecf..0e8ae0e0 100644
--- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php
+++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php
@@ -126,8 +126,8 @@ class Comments extends WriterPart
$objWriter->startElement('o:shapelayout');
$objWriter->writeAttribute('v:ext', 'edit');
- // o:idmap
- $objWriter->startElement('o:idmap');
+ // o:idmap
+ $objWriter->startElement('o:idmap');
$objWriter->writeAttribute('v:ext', 'edit');
$objWriter->writeAttribute('data', '1');
$objWriter->endElement();
@@ -141,13 +141,13 @@ class Comments extends WriterPart
$objWriter->writeAttribute('o:spt', '202');
$objWriter->writeAttribute('path', 'm,l,21600r21600,l21600,xe');
- // v:stroke
- $objWriter->startElement('v:stroke');
+ // v:stroke
+ $objWriter->startElement('v:stroke');
$objWriter->writeAttribute('joinstyle', 'miter');
$objWriter->endElement();
- // v:path
- $objWriter->startElement('v:path');
+ // v:path
+ $objWriter->startElement('v:path');
$objWriter->writeAttribute('gradientshapeok', 't');
$objWriter->writeAttribute('o:connecttype', 'rect');
$objWriter->endElement();
@@ -177,7 +177,7 @@ class Comments extends WriterPart
private function writeVMLComment(XMLWriter $objWriter, $pCellReference, Comment $pComment)
{
// Metadata
- list($column, $row) = Cell::coordinateFromString($pCellReference);
+ [$column, $row] = Cell::coordinateFromString($pCellReference);
$column = Cell::columnIndexFromString($column);
$id = 1024 + $column + $row;
$id = substr($id, 0, 4);
@@ -190,52 +190,52 @@ class Comments extends WriterPart
$objWriter->writeAttribute('fillcolor', '#' . $pComment->getFillColor()->getRGB());
$objWriter->writeAttribute('o:insetmode', 'auto');
- // v:fill
- $objWriter->startElement('v:fill');
+ // v:fill
+ $objWriter->startElement('v:fill');
$objWriter->writeAttribute('color2', '#' . $pComment->getFillColor()->getRGB());
$objWriter->endElement();
- // v:shadow
- $objWriter->startElement('v:shadow');
+ // v:shadow
+ $objWriter->startElement('v:shadow');
$objWriter->writeAttribute('on', 't');
$objWriter->writeAttribute('color', 'black');
$objWriter->writeAttribute('obscured', 't');
$objWriter->endElement();
- // v:path
- $objWriter->startElement('v:path');
+ // v:path
+ $objWriter->startElement('v:path');
$objWriter->writeAttribute('o:connecttype', 'none');
$objWriter->endElement();
- // v:textbox
- $objWriter->startElement('v:textbox');
+ // v:textbox
+ $objWriter->startElement('v:textbox');
$objWriter->writeAttribute('style', 'mso-direction-alt:auto');
- // div
- $objWriter->startElement('div');
+ // div
+ $objWriter->startElement('div');
$objWriter->writeAttribute('style', 'text-align:left');
$objWriter->endElement();
$objWriter->endElement();
- // x:ClientData
- $objWriter->startElement('x:ClientData');
+ // x:ClientData
+ $objWriter->startElement('x:ClientData');
$objWriter->writeAttribute('ObjectType', 'Note');
- // x:MoveWithCells
- $objWriter->writeElement('x:MoveWithCells', '');
+ // x:MoveWithCells
+ $objWriter->writeElement('x:MoveWithCells', '');
- // x:SizeWithCells
- $objWriter->writeElement('x:SizeWithCells', '');
+ // x:SizeWithCells
+ $objWriter->writeElement('x:SizeWithCells', '');
- // x:AutoFill
- $objWriter->writeElement('x:AutoFill', 'False');
+ // x:AutoFill
+ $objWriter->writeElement('x:AutoFill', 'False');
- // x:Row
- $objWriter->writeElement('x:Row', ($row - 1));
+ // x:Row
+ $objWriter->writeElement('x:Row', ($row - 1));
- // x:Column
- $objWriter->writeElement('x:Column', ($column - 1));
+ // x:Column
+ $objWriter->writeElement('x:Column', ($column - 1));
$objWriter->endElement();
diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php
index 0e2c2fe2..a34d3465 100644
--- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php
+++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php
@@ -182,6 +182,7 @@ class ContentTypes extends WriterPart
return image_type_to_mime_type($image[2]);
}
+
throw new WriterException("File $pFile does not exist");
}
diff --git a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php
index de324b6d..2a18d5c7 100644
--- a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php
+++ b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php
@@ -219,20 +219,25 @@ class DocProps extends WriterPart
switch ($propertyType) {
case 'i':
$objWriter->writeElement('vt:i4', $propertyValue);
+
break;
case 'f':
$objWriter->writeElement('vt:r8', $propertyValue);
+
break;
case 'b':
$objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false');
+
break;
case 'd':
$objWriter->startElement('vt:filetime');
$objWriter->writeRawData(date(DATE_W3C, $propertyValue));
$objWriter->endElement();
+
break;
default:
$objWriter->writeElement('vt:lpwstr', $propertyValue);
+
break;
}
diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php
index 6fc8238a..7b7ba007 100644
--- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php
+++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php
@@ -57,6 +57,7 @@ class StringTable extends WriterPart
return $aStringTable;
}
+
throw new WriterException('Invalid Worksheet object passed.');
}
@@ -200,7 +201,7 @@ class StringTable extends WriterPart
* Write Rich Text.
*
* @param XMLWriter $objWriter XML Writer
- * @param string|RichText $pRichText text string or Rich text
+ * @param RichText|string $pRichText text string or Rich text
* @param string $prefix Optional Namespace prefix
*
* @throws WriterException
@@ -235,9 +236,11 @@ class StringTable extends WriterPart
switch ($underlineType) {
case 'single':
$underlineType = 'sng';
+
break;
case 'double':
$underlineType = 'dbl';
+
break;
}
$objWriter->writeAttribute('u', $underlineType);
diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Style.php b/src/PhpSpreadsheet/Writer/Xlsx/Style.php
index 65b66d1a..911938fa 100644
--- a/src/PhpSpreadsheet/Writer/Xlsx/Style.php
+++ b/src/PhpSpreadsheet/Writer/Xlsx/Style.php
@@ -349,14 +349,17 @@ class Style extends WriterPart
case Borders::DIAGONAL_UP:
$objWriter->writeAttribute('diagonalUp', 'true');
$objWriter->writeAttribute('diagonalDown', 'false');
+
break;
case Borders::DIAGONAL_DOWN:
$objWriter->writeAttribute('diagonalUp', 'false');
$objWriter->writeAttribute('diagonalDown', 'true');
+
break;
case Borders::DIAGONAL_BOTH:
$objWriter->writeAttribute('diagonalUp', 'true');
$objWriter->writeAttribute('diagonalDown', 'true');
+
break;
}
diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php
index cd9a444b..9f1a946f 100644
--- a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php
+++ b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php
@@ -133,95 +133,95 @@ class Theme extends WriterPart
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
$objWriter->writeAttribute('name', 'Office Theme');
- // a:themeElements
- $objWriter->startElement('a:themeElements');
+ // a:themeElements
+ $objWriter->startElement('a:themeElements');
- // a:clrScheme
- $objWriter->startElement('a:clrScheme');
+ // a:clrScheme
+ $objWriter->startElement('a:clrScheme');
$objWriter->writeAttribute('name', 'Office');
- // a:dk1
- $objWriter->startElement('a:dk1');
+ // a:dk1
+ $objWriter->startElement('a:dk1');
- // a:sysClr
- $objWriter->startElement('a:sysClr');
+ // a:sysClr
+ $objWriter->startElement('a:sysClr');
$objWriter->writeAttribute('val', 'windowText');
$objWriter->writeAttribute('lastClr', '000000');
$objWriter->endElement();
$objWriter->endElement();
- // a:lt1
- $objWriter->startElement('a:lt1');
+ // a:lt1
+ $objWriter->startElement('a:lt1');
- // a:sysClr
- $objWriter->startElement('a:sysClr');
+ // a:sysClr
+ $objWriter->startElement('a:sysClr');
$objWriter->writeAttribute('val', 'window');
$objWriter->writeAttribute('lastClr', 'FFFFFF');
$objWriter->endElement();
$objWriter->endElement();
- // a:dk2
- $this->writeColourScheme($objWriter);
+ // a:dk2
+ $this->writeColourScheme($objWriter);
$objWriter->endElement();
- // a:fontScheme
- $objWriter->startElement('a:fontScheme');
+ // a:fontScheme
+ $objWriter->startElement('a:fontScheme');
$objWriter->writeAttribute('name', 'Office');
- // a:majorFont
- $objWriter->startElement('a:majorFont');
+ // a:majorFont
+ $objWriter->startElement('a:majorFont');
$this->writeFonts($objWriter, 'Cambria', self::$majorFonts);
$objWriter->endElement();
- // a:minorFont
- $objWriter->startElement('a:minorFont');
+ // a:minorFont
+ $objWriter->startElement('a:minorFont');
$this->writeFonts($objWriter, 'Calibri', self::$minorFonts);
$objWriter->endElement();
$objWriter->endElement();
- // a:fmtScheme
- $objWriter->startElement('a:fmtScheme');
+ // a:fmtScheme
+ $objWriter->startElement('a:fmtScheme');
$objWriter->writeAttribute('name', 'Office');
- // a:fillStyleLst
- $objWriter->startElement('a:fillStyleLst');
+ // a:fillStyleLst
+ $objWriter->startElement('a:fillStyleLst');
- // a:solidFill
- $objWriter->startElement('a:solidFill');
+ // a:solidFill
+ $objWriter->startElement('a:solidFill');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
$objWriter->endElement();
$objWriter->endElement();
- // a:gradFill
- $objWriter->startElement('a:gradFill');
+ // a:gradFill
+ $objWriter->startElement('a:gradFill');
$objWriter->writeAttribute('rotWithShape', '1');
- // a:gsLst
- $objWriter->startElement('a:gsLst');
+ // a:gsLst
+ $objWriter->startElement('a:gsLst');
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '0');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:tint
- $objWriter->startElement('a:tint');
+ // a:tint
+ $objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '50000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '300000');
$objWriter->endElement();
@@ -229,21 +229,21 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '35000');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:tint
- $objWriter->startElement('a:tint');
+ // a:tint
+ $objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '37000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '300000');
$objWriter->endElement();
@@ -251,21 +251,21 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '100000');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:tint
- $objWriter->startElement('a:tint');
+ // a:tint
+ $objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '15000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '350000');
$objWriter->endElement();
@@ -275,36 +275,36 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:lin
- $objWriter->startElement('a:lin');
+ // a:lin
+ $objWriter->startElement('a:lin');
$objWriter->writeAttribute('ang', '16200000');
$objWriter->writeAttribute('scaled', '1');
$objWriter->endElement();
$objWriter->endElement();
- // a:gradFill
- $objWriter->startElement('a:gradFill');
+ // a:gradFill
+ $objWriter->startElement('a:gradFill');
$objWriter->writeAttribute('rotWithShape', '1');
- // a:gsLst
- $objWriter->startElement('a:gsLst');
+ // a:gsLst
+ $objWriter->startElement('a:gsLst');
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '0');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:shade
- $objWriter->startElement('a:shade');
+ // a:shade
+ $objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '51000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '130000');
$objWriter->endElement();
@@ -312,21 +312,21 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '80000');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:shade
- $objWriter->startElement('a:shade');
+ // a:shade
+ $objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '93000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '130000');
$objWriter->endElement();
@@ -334,21 +334,21 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '100000');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:shade
- $objWriter->startElement('a:shade');
+ // a:shade
+ $objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '94000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '135000');
$objWriter->endElement();
@@ -358,8 +358,8 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:lin
- $objWriter->startElement('a:lin');
+ // a:lin
+ $objWriter->startElement('a:lin');
$objWriter->writeAttribute('ang', '16200000');
$objWriter->writeAttribute('scaled', '0');
$objWriter->endElement();
@@ -368,30 +368,30 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:lnStyleLst
- $objWriter->startElement('a:lnStyleLst');
+ // a:lnStyleLst
+ $objWriter->startElement('a:lnStyleLst');
- // a:ln
- $objWriter->startElement('a:ln');
+ // a:ln
+ $objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', '9525');
$objWriter->writeAttribute('cap', 'flat');
$objWriter->writeAttribute('cmpd', 'sng');
$objWriter->writeAttribute('algn', 'ctr');
- // a:solidFill
- $objWriter->startElement('a:solidFill');
+ // a:solidFill
+ $objWriter->startElement('a:solidFill');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:shade
- $objWriter->startElement('a:shade');
+ // a:shade
+ $objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '95000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '105000');
$objWriter->endElement();
@@ -399,56 +399,56 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:prstDash
- $objWriter->startElement('a:prstDash');
+ // a:prstDash
+ $objWriter->startElement('a:prstDash');
$objWriter->writeAttribute('val', 'solid');
$objWriter->endElement();
$objWriter->endElement();
- // a:ln
- $objWriter->startElement('a:ln');
+ // a:ln
+ $objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', '25400');
$objWriter->writeAttribute('cap', 'flat');
$objWriter->writeAttribute('cmpd', 'sng');
$objWriter->writeAttribute('algn', 'ctr');
- // a:solidFill
- $objWriter->startElement('a:solidFill');
+ // a:solidFill
+ $objWriter->startElement('a:solidFill');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
$objWriter->endElement();
$objWriter->endElement();
- // a:prstDash
- $objWriter->startElement('a:prstDash');
+ // a:prstDash
+ $objWriter->startElement('a:prstDash');
$objWriter->writeAttribute('val', 'solid');
$objWriter->endElement();
$objWriter->endElement();
- // a:ln
- $objWriter->startElement('a:ln');
+ // a:ln
+ $objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', '38100');
$objWriter->writeAttribute('cap', 'flat');
$objWriter->writeAttribute('cmpd', 'sng');
$objWriter->writeAttribute('algn', 'ctr');
- // a:solidFill
- $objWriter->startElement('a:solidFill');
+ // a:solidFill
+ $objWriter->startElement('a:solidFill');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
$objWriter->endElement();
$objWriter->endElement();
- // a:prstDash
- $objWriter->startElement('a:prstDash');
+ // a:prstDash
+ $objWriter->startElement('a:prstDash');
$objWriter->writeAttribute('val', 'solid');
$objWriter->endElement();
@@ -456,28 +456,28 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:effectStyleLst
- $objWriter->startElement('a:effectStyleLst');
+ // a:effectStyleLst
+ $objWriter->startElement('a:effectStyleLst');
- // a:effectStyle
- $objWriter->startElement('a:effectStyle');
+ // a:effectStyle
+ $objWriter->startElement('a:effectStyle');
- // a:effectLst
- $objWriter->startElement('a:effectLst');
+ // a:effectLst
+ $objWriter->startElement('a:effectLst');
- // a:outerShdw
- $objWriter->startElement('a:outerShdw');
+ // a:outerShdw
+ $objWriter->startElement('a:outerShdw');
$objWriter->writeAttribute('blurRad', '40000');
$objWriter->writeAttribute('dist', '20000');
$objWriter->writeAttribute('dir', '5400000');
$objWriter->writeAttribute('rotWithShape', '0');
- // a:srgbClr
- $objWriter->startElement('a:srgbClr');
+ // a:srgbClr
+ $objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '000000');
- // a:alpha
- $objWriter->startElement('a:alpha');
+ // a:alpha
+ $objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', '38000');
$objWriter->endElement();
@@ -489,25 +489,25 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:effectStyle
- $objWriter->startElement('a:effectStyle');
+ // a:effectStyle
+ $objWriter->startElement('a:effectStyle');
- // a:effectLst
- $objWriter->startElement('a:effectLst');
+ // a:effectLst
+ $objWriter->startElement('a:effectLst');
- // a:outerShdw
- $objWriter->startElement('a:outerShdw');
+ // a:outerShdw
+ $objWriter->startElement('a:outerShdw');
$objWriter->writeAttribute('blurRad', '40000');
$objWriter->writeAttribute('dist', '23000');
$objWriter->writeAttribute('dir', '5400000');
$objWriter->writeAttribute('rotWithShape', '0');
- // a:srgbClr
- $objWriter->startElement('a:srgbClr');
+ // a:srgbClr
+ $objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '000000');
- // a:alpha
- $objWriter->startElement('a:alpha');
+ // a:alpha
+ $objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', '35000');
$objWriter->endElement();
@@ -519,25 +519,25 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:effectStyle
- $objWriter->startElement('a:effectStyle');
+ // a:effectStyle
+ $objWriter->startElement('a:effectStyle');
- // a:effectLst
- $objWriter->startElement('a:effectLst');
+ // a:effectLst
+ $objWriter->startElement('a:effectLst');
- // a:outerShdw
- $objWriter->startElement('a:outerShdw');
+ // a:outerShdw
+ $objWriter->startElement('a:outerShdw');
$objWriter->writeAttribute('blurRad', '40000');
$objWriter->writeAttribute('dist', '23000');
$objWriter->writeAttribute('dir', '5400000');
$objWriter->writeAttribute('rotWithShape', '0');
- // a:srgbClr
- $objWriter->startElement('a:srgbClr');
+ // a:srgbClr
+ $objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '000000');
- // a:alpha
- $objWriter->startElement('a:alpha');
+ // a:alpha
+ $objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', '35000');
$objWriter->endElement();
@@ -547,15 +547,15 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:scene3d
- $objWriter->startElement('a:scene3d');
+ // a:scene3d
+ $objWriter->startElement('a:scene3d');
- // a:camera
- $objWriter->startElement('a:camera');
+ // a:camera
+ $objWriter->startElement('a:camera');
$objWriter->writeAttribute('prst', 'orthographicFront');
- // a:rot
- $objWriter->startElement('a:rot');
+ // a:rot
+ $objWriter->startElement('a:rot');
$objWriter->writeAttribute('lat', '0');
$objWriter->writeAttribute('lon', '0');
$objWriter->writeAttribute('rev', '0');
@@ -563,13 +563,13 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:lightRig
- $objWriter->startElement('a:lightRig');
+ // a:lightRig
+ $objWriter->startElement('a:lightRig');
$objWriter->writeAttribute('rig', 'threePt');
$objWriter->writeAttribute('dir', 't');
- // a:rot
- $objWriter->startElement('a:rot');
+ // a:rot
+ $objWriter->startElement('a:rot');
$objWriter->writeAttribute('lat', '0');
$objWriter->writeAttribute('lon', '0');
$objWriter->writeAttribute('rev', '1200000');
@@ -579,11 +579,11 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:sp3d
- $objWriter->startElement('a:sp3d');
+ // a:sp3d
+ $objWriter->startElement('a:sp3d');
- // a:bevelT
- $objWriter->startElement('a:bevelT');
+ // a:bevelT
+ $objWriter->startElement('a:bevelT');
$objWriter->writeAttribute('w', '63500');
$objWriter->writeAttribute('h', '25400');
$objWriter->endElement();
@@ -594,41 +594,41 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:bgFillStyleLst
- $objWriter->startElement('a:bgFillStyleLst');
+ // a:bgFillStyleLst
+ $objWriter->startElement('a:bgFillStyleLst');
- // a:solidFill
- $objWriter->startElement('a:solidFill');
+ // a:solidFill
+ $objWriter->startElement('a:solidFill');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
$objWriter->endElement();
$objWriter->endElement();
- // a:gradFill
- $objWriter->startElement('a:gradFill');
+ // a:gradFill
+ $objWriter->startElement('a:gradFill');
$objWriter->writeAttribute('rotWithShape', '1');
- // a:gsLst
- $objWriter->startElement('a:gsLst');
+ // a:gsLst
+ $objWriter->startElement('a:gsLst');
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '0');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:tint
- $objWriter->startElement('a:tint');
+ // a:tint
+ $objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '40000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '350000');
$objWriter->endElement();
@@ -636,26 +636,26 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '40000');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:tint
- $objWriter->startElement('a:tint');
+ // a:tint
+ $objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '45000');
$objWriter->endElement();
- // a:shade
- $objWriter->startElement('a:shade');
+ // a:shade
+ $objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '99000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '350000');
$objWriter->endElement();
@@ -663,21 +663,21 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '100000');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:shade
- $objWriter->startElement('a:shade');
+ // a:shade
+ $objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '20000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '255000');
$objWriter->endElement();
@@ -687,12 +687,12 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:path
- $objWriter->startElement('a:path');
+ // a:path
+ $objWriter->startElement('a:path');
$objWriter->writeAttribute('path', 'circle');
- // a:fillToRect
- $objWriter->startElement('a:fillToRect');
+ // a:fillToRect
+ $objWriter->startElement('a:fillToRect');
$objWriter->writeAttribute('l', '50000');
$objWriter->writeAttribute('t', '-80000');
$objWriter->writeAttribute('r', '50000');
@@ -703,28 +703,28 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:gradFill
- $objWriter->startElement('a:gradFill');
+ // a:gradFill
+ $objWriter->startElement('a:gradFill');
$objWriter->writeAttribute('rotWithShape', '1');
- // a:gsLst
- $objWriter->startElement('a:gsLst');
+ // a:gsLst
+ $objWriter->startElement('a:gsLst');
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '0');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:tint
- $objWriter->startElement('a:tint');
+ // a:tint
+ $objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '80000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '300000');
$objWriter->endElement();
@@ -732,21 +732,21 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:gs
- $objWriter->startElement('a:gs');
+ // a:gs
+ $objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '100000');
- // a:schemeClr
- $objWriter->startElement('a:schemeClr');
+ // a:schemeClr
+ $objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- // a:shade
- $objWriter->startElement('a:shade');
+ // a:shade
+ $objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '30000');
$objWriter->endElement();
- // a:satMod
- $objWriter->startElement('a:satMod');
+ // a:satMod
+ $objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '200000');
$objWriter->endElement();
@@ -756,12 +756,12 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:path
- $objWriter->startElement('a:path');
+ // a:path
+ $objWriter->startElement('a:path');
$objWriter->writeAttribute('path', 'circle');
- // a:fillToRect
- $objWriter->startElement('a:fillToRect');
+ // a:fillToRect
+ $objWriter->startElement('a:fillToRect');
$objWriter->writeAttribute('l', '50000');
$objWriter->writeAttribute('t', '50000');
$objWriter->writeAttribute('r', '50000');
@@ -778,11 +778,11 @@ class Theme extends WriterPart
$objWriter->endElement();
- // a:objectDefaults
- $objWriter->writeElement('a:objectDefaults', null);
+ // a:objectDefaults
+ $objWriter->writeElement('a:objectDefaults', null);
- // a:extraClrSchemeLst
- $objWriter->writeElement('a:extraClrSchemeLst', null);
+ // a:extraClrSchemeLst
+ $objWriter->writeElement('a:extraClrSchemeLst', null);
$objWriter->endElement();
diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php
index 852f7c39..a763e54e 100644
--- a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php
+++ b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php
@@ -352,7 +352,7 @@ class Workbook extends WriterPart
$range = $range[0];
// Strip any worksheet ref so we can make the cell ref absolute
if (strpos($range[0], '!') !== false) {
- list($ws, $range[0]) = explode('!', $range[0]);
+ [$ws, $range[0]] = explode('!', $range[0]);
}
$range[0] = Cell::absoluteCoordinate($range[0]);
diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
index 33555e0b..e9480998 100644
--- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
+++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
@@ -33,7 +33,7 @@ class Worksheet extends WriterPart
*/
public function writeWorksheet($pSheet = null, $pStringTable = null, $includeCharts = false)
{
- if (!is_null($pSheet)) {
+ if ($pSheet !== null) {
// Create XML writer
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
@@ -51,74 +51,75 @@ class Worksheet extends WriterPart
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
- // sheetPr
- $this->writeSheetPr($objWriter, $pSheet);
+ // sheetPr
+ $this->writeSheetPr($objWriter, $pSheet);
- // Dimension
- $this->writeDimension($objWriter, $pSheet);
+ // Dimension
+ $this->writeDimension($objWriter, $pSheet);
- // sheetViews
- $this->writeSheetViews($objWriter, $pSheet);
+ // sheetViews
+ $this->writeSheetViews($objWriter, $pSheet);
- // sheetFormatPr
- $this->writeSheetFormatPr($objWriter, $pSheet);
+ // sheetFormatPr
+ $this->writeSheetFormatPr($objWriter, $pSheet);
- // cols
- $this->writeCols($objWriter, $pSheet);
+ // cols
+ $this->writeCols($objWriter, $pSheet);
- // sheetData
- $this->writeSheetData($objWriter, $pSheet, $pStringTable);
+ // sheetData
+ $this->writeSheetData($objWriter, $pSheet, $pStringTable);
- // sheetProtection
- $this->writeSheetProtection($objWriter, $pSheet);
+ // sheetProtection
+ $this->writeSheetProtection($objWriter, $pSheet);
- // protectedRanges
- $this->writeProtectedRanges($objWriter, $pSheet);
+ // protectedRanges
+ $this->writeProtectedRanges($objWriter, $pSheet);
- // autoFilter
- $this->writeAutoFilter($objWriter, $pSheet);
+ // autoFilter
+ $this->writeAutoFilter($objWriter, $pSheet);
- // mergeCells
- $this->writeMergeCells($objWriter, $pSheet);
+ // mergeCells
+ $this->writeMergeCells($objWriter, $pSheet);
- // conditionalFormatting
- $this->writeConditionalFormatting($objWriter, $pSheet);
+ // conditionalFormatting
+ $this->writeConditionalFormatting($objWriter, $pSheet);
- // dataValidations
- $this->writeDataValidations($objWriter, $pSheet);
+ // dataValidations
+ $this->writeDataValidations($objWriter, $pSheet);
- // hyperlinks
- $this->writeHyperlinks($objWriter, $pSheet);
+ // hyperlinks
+ $this->writeHyperlinks($objWriter, $pSheet);
- // Print options
- $this->writePrintOptions($objWriter, $pSheet);
+ // Print options
+ $this->writePrintOptions($objWriter, $pSheet);
- // Page margins
- $this->writePageMargins($objWriter, $pSheet);
+ // Page margins
+ $this->writePageMargins($objWriter, $pSheet);
- // Page setup
- $this->writePageSetup($objWriter, $pSheet);
+ // Page setup
+ $this->writePageSetup($objWriter, $pSheet);
- // Header / footer
- $this->writeHeaderFooter($objWriter, $pSheet);
+ // Header / footer
+ $this->writeHeaderFooter($objWriter, $pSheet);
- // Breaks
- $this->writeBreaks($objWriter, $pSheet);
+ // Breaks
+ $this->writeBreaks($objWriter, $pSheet);
- // Drawings and/or Charts
- $this->writeDrawings($objWriter, $pSheet, $includeCharts);
+ // Drawings and/or Charts
+ $this->writeDrawings($objWriter, $pSheet, $includeCharts);
- // LegacyDrawing
- $this->writeLegacyDrawing($objWriter, $pSheet);
+ // LegacyDrawing
+ $this->writeLegacyDrawing($objWriter, $pSheet);
- // LegacyDrawingHF
- $this->writeLegacyDrawingHF($objWriter, $pSheet);
+ // LegacyDrawingHF
+ $this->writeLegacyDrawingHF($objWriter, $pSheet);
$objWriter->endElement();
// Return
return $objWriter->getData();
}
+
throw new WriterException('Invalid \\PhpOffice\\PhpSpreadsheet\\Worksheet object passed.');
}
@@ -252,7 +253,7 @@ class Worksheet extends WriterPart
// Calculate freeze coordinates
$xSplit = $ySplit = 0;
- list($xSplit, $ySplit) = Cell::coordinateFromString($topLeftCell);
+ [$xSplit, $ySplit] = Cell::coordinateFromString($topLeftCell);
$xSplit = Cell::columnIndexFromString($xSplit);
// pane
@@ -489,25 +490,25 @@ class Worksheet extends WriterPart
}
if ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT
- && !is_null($conditional->getText())) {
+ && $conditional->getText() !== null) {
$objWriter->writeAttribute('text', $conditional->getText());
}
if ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == Conditional::OPERATOR_CONTAINSTEXT
- && !is_null($conditional->getText())) {
+ && $conditional->getText() !== null) {
$objWriter->writeElement('formula', 'NOT(ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . ')))');
} elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == Conditional::OPERATOR_BEGINSWITH
- && !is_null($conditional->getText())) {
+ && $conditional->getText() !== null) {
$objWriter->writeElement('formula', 'LEFT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
} elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == Conditional::OPERATOR_ENDSWITH
- && !is_null($conditional->getText())) {
+ && $conditional->getText() !== null) {
$objWriter->writeElement('formula', 'RIGHT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
} elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == Conditional::OPERATOR_NOTCONTAINS
- && !is_null($conditional->getText())) {
+ && $conditional->getText() !== null) {
$objWriter->writeElement('formula', 'ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . '))');
} elseif ($conditional->getConditionType() == Conditional::CONDITION_CELLIS
|| $conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT
@@ -760,7 +761,7 @@ class Worksheet extends WriterPart
$range = $range[0];
// Strip any worksheet ref
if (strpos($range[0], '!') !== false) {
- list($ws, $range[0]) = explode('!', $range[0]);
+ [$ws, $range[0]] = explode('!', $range[0]);
}
$range = implode(':', $range);
@@ -849,20 +850,20 @@ class Worksheet extends WriterPart
$objWriter->writeAttribute('paperSize', $pSheet->getPageSetup()->getPaperSize());
$objWriter->writeAttribute('orientation', $pSheet->getPageSetup()->getOrientation());
- if (!is_null($pSheet->getPageSetup()->getScale())) {
+ if ($pSheet->getPageSetup()->getScale() !== null) {
$objWriter->writeAttribute('scale', $pSheet->getPageSetup()->getScale());
}
- if (!is_null($pSheet->getPageSetup()->getFitToHeight())) {
+ if ($pSheet->getPageSetup()->getFitToHeight() !== null) {
$objWriter->writeAttribute('fitToHeight', $pSheet->getPageSetup()->getFitToHeight());
} else {
$objWriter->writeAttribute('fitToHeight', '0');
}
- if (!is_null($pSheet->getPageSetup()->getFitToWidth())) {
+ if ($pSheet->getPageSetup()->getFitToWidth() !== null) {
$objWriter->writeAttribute('fitToWidth', $pSheet->getPageSetup()->getFitToWidth());
} else {
$objWriter->writeAttribute('fitToWidth', '0');
}
- if (!is_null($pSheet->getPageSetup()->getFirstPageNumber())) {
+ if ($pSheet->getPageSetup()->getFirstPageNumber() !== null) {
$objWriter->writeAttribute('firstPageNumber', $pSheet->getPageSetup()->getFirstPageNumber());
$objWriter->writeAttribute('useFirstPageNumber', '1');
}
@@ -1076,6 +1077,7 @@ class Worksheet extends WriterPart
case 's': // String
case 'b': // Boolean
$objWriter->writeAttribute('t', $mappedType);
+
break;
case 'f': // Formula
$calculatedValue = ($this->getParentWriter()->getPreCalculateFormulas()) ?
@@ -1083,6 +1085,7 @@ class Worksheet extends WriterPart
if (is_string($calculatedValue)) {
$objWriter->writeAttribute('t', 'str');
}
+
break;
case 'e': // Error
$objWriter->writeAttribute('t', $mappedType);
@@ -1134,13 +1137,16 @@ class Worksheet extends WriterPart
$objWriter->writeElement('v', '0');
}
}
+
break;
case 'n': // Numeric
// force point as decimal separator in case current locale uses comma
$objWriter->writeElement('v', str_replace(',', '.', $cellValue));
+
break;
case 'b': // Boolean
$objWriter->writeElement('v', ($cellValue ? '1' : '0'));
+
break;
case 'e': // Error
if (substr($cellValue, 0, 1) == '=') {
diff --git a/tests/PhpSpreadsheetTests/CellTest.php b/tests/PhpSpreadsheetTests/CellTest.php
index 6f03593a..9708981c 100644
--- a/tests/PhpSpreadsheetTests/CellTest.php
+++ b/tests/PhpSpreadsheetTests/CellTest.php
@@ -27,6 +27,7 @@ class CellTest extends PHPUnit_Framework_TestCase
public function testColumnIndexFromStringTooLong()
{
$cellAddress = 'ABCD';
+
try {
Cell::columnIndexFromString($cellAddress);
} catch (\Exception $e) {
@@ -41,6 +42,7 @@ class CellTest extends PHPUnit_Framework_TestCase
public function testColumnIndexFromStringTooShort()
{
$cellAddress = '';
+
try {
Cell::columnIndexFromString($cellAddress);
} catch (\Exception $e) {
@@ -87,6 +89,7 @@ class CellTest extends PHPUnit_Framework_TestCase
public function testCoordinateFromStringWithRangeAddress()
{
$cellAddress = 'A1:AI2012';
+
try {
Cell::coordinateFromString($cellAddress);
} catch (\Exception $e) {
@@ -101,6 +104,7 @@ class CellTest extends PHPUnit_Framework_TestCase
public function testCoordinateFromStringWithEmptyAddress()
{
$cellAddress = '';
+
try {
Cell::coordinateFromString($cellAddress);
} catch (\Exception $e) {
@@ -115,6 +119,7 @@ class CellTest extends PHPUnit_Framework_TestCase
public function testCoordinateFromStringWithInvalidAddress()
{
$cellAddress = 'AI';
+
try {
Cell::coordinateFromString($cellAddress);
} catch (\Exception $e) {
@@ -145,6 +150,7 @@ class CellTest extends PHPUnit_Framework_TestCase
public function testAbsoluteCoordinateFromStringWithRangeAddress()
{
$cellAddress = 'A1:AI2012';
+
try {
Cell::absoluteCoordinate($cellAddress);
} catch (\Exception $e) {
@@ -175,6 +181,7 @@ class CellTest extends PHPUnit_Framework_TestCase
public function testAbsoluteReferenceFromStringWithRangeAddress()
{
$cellAddress = 'A1:AI2012';
+
try {
Cell::absoluteReference($cellAddress);
} catch (\Exception $e) {
diff --git a/tests/PhpSpreadsheetTests/Custom/Complex.php b/tests/PhpSpreadsheetTests/Custom/Complex.php
index c2164160..37305b03 100644
--- a/tests/PhpSpreadsheetTests/Custom/Complex.php
+++ b/tests/PhpSpreadsheetTests/Custom/Complex.php
@@ -8,7 +8,7 @@ class Complex
{
private $realPart = 0;
private $imaginaryPart = 0;
- private $suffix = null;
+ private $suffix;
public static function _parseComplex($complexNumber)
{
@@ -53,7 +53,7 @@ class Complex
if ($complexParts[8] === '-') {
$complexParts[4] = -1;
}
- // ... or if we have only the real and no imaginary part (in which case our real should be the imaginary)
+ // ... or if we have only the real and no imaginary part (in which case our real should be the imaginary)
} else {
$complexParts[4] = $complexParts[1];
$complexParts[1] = 0;
@@ -71,10 +71,10 @@ class Complex
if ($imaginaryPart === null) {
if (is_array($realPart)) {
// We have an array of (potentially) real and imaginary parts, and any suffix
- list($realPart, $imaginaryPart, $suffix) = array_values($realPart) + [0.0, 0.0, 'i'];
+ [$realPart, $imaginaryPart, $suffix] = array_values($realPart) + [0.0, 0.0, 'i'];
} elseif ((is_string($realPart)) || (is_numeric($realPart))) {
// We've been given a string to parse to extract the real and imaginary parts, and any suffix
- list($realPart, $imaginaryPart, $suffix) = self::_parseComplex($realPart);
+ [$realPart, $imaginaryPart, $suffix] = self::_parseComplex($realPart);
}
}
diff --git a/tests/PhpSpreadsheetTests/Reader/OdsTest.php b/tests/PhpSpreadsheetTests/Reader/OdsTest.php
index 5c997f70..7d8b1a5e 100644
--- a/tests/PhpSpreadsheetTests/Reader/OdsTest.php
+++ b/tests/PhpSpreadsheetTests/Reader/OdsTest.php
@@ -131,9 +131,7 @@ class OdsTest extends PHPUnit_Framework_TestCase
self::assertEquals(DataType::TYPE_FORMULA, $firstSheet->getCell('C6')->getDataType()); // Formula
self::assertEquals('=TRUE()', $firstSheet->getCell('C6')->getValue()); // Formula
- /*
- * Percentage, Currency
- */
+ // Percentage, Currency
$spreadsheet = $this->loadDataFile();
@@ -201,9 +199,7 @@ class OdsTest extends PHPUnit_Framework_TestCase
self::assertEquals('http://www.phpexcel.net/', $hyperlink->getHyperlink()->getUrl());
}
- /*
- * Below some test for features not implemented yet
- */
+ // Below some test for features not implemented yet
public function testReadBoldItalicUnderline()
{
diff --git a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php
index 77009581..93c2f83b 100644
--- a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php
+++ b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php
@@ -27,6 +27,7 @@ class CodePageTest extends PHPUnit_Framework_TestCase
public function testNumberToNameWithInvalidCodePage()
{
$invalidCodePage = 12345;
+
try {
CodePage::numberToName($invalidCodePage);
} catch (Exception $e) {
@@ -40,6 +41,7 @@ class CodePageTest extends PHPUnit_Framework_TestCase
public function testNumberToNameWithUnsupportedCodePage()
{
$unsupportedCodePage = 720;
+
try {
CodePage::numberToName($unsupportedCodePage);
} catch (Exception $e) {