Upgrade to PHP-CS-Fixer 2.7

This commit is contained in:
Adrien Crivelli 2017-10-01 20:07:04 +09:00
parent e95e4dfd13
commit 4fd8e742e7
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
140 changed files with 3019 additions and 1093 deletions

View File

@ -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,
]);

505
composer.lock generated
View File

@ -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",

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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)

View File

@ -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());
}
}

View File

@ -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('<hr /><b>Roots:</b><br />');
$discriminantFormula = '=POWER(' . $_POST['B'] . ',2) - (4 * ' . $_POST['A'] . ' * ' . $_POST['C'] . ')';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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) {

View File

@ -49,7 +49,6 @@ if ($helper->isCli()) {
} ?></ul>
</li>
<?php
} ?>
</ul>
<ul class="nav navbar-nav navbar-right">

View File

@ -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

View File

@ -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

View File

@ -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));
}

View File

@ -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) {

View File

@ -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);

View File

@ -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('<b>' . $customPropertyName . ': </b>');
/* 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;
}

View File

@ -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) {

View File

@ -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('<b>Document Creator: </b>' . $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('<b>Created On: </b>' . $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('<b>Last Modified By: </b>' . $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('<b>Last Modified On: </b>' . $modifiedDate . ' at ' . $modifiedTime);
/* Read the workbook title property * */
// Read the workbook title property
$workbookTitle = $spreadsheet->getProperties()->getTitle();
$helper->log('<b>Title: </b>' . $workbookTitle);
/* Read the workbook description property * */
// Read the workbook description property
$description = $spreadsheet->getProperties()->getDescription();
$helper->log('<b>Description: </b>' . $description);
/* Read the workbook subject property * */
// Read the workbook subject property
$subject = $spreadsheet->getProperties()->getSubject();
$helper->log('<b>Subject: </b>' . $subject);
/* Read the workbook keywords property * */
// Read the workbook keywords property
$keywords = $spreadsheet->getProperties()->getKeywords();
$helper->log('<b>Keywords: </b>' . $keywords);
/* Read the workbook category property * */
// Read the workbook category property
$category = $spreadsheet->getProperties()->getCategory();
$helper->log('<b>Category: </b>' . $category);
/* Read the workbook company property * */
// Read the workbook company property
$company = $spreadsheet->getProperties()->getCompany();
$helper->log('<b>Company: </b>' . $company);
/* Read the workbook manager property * */
// Read the workbook manager property
$manager = $spreadsheet->getProperties()->getManager();
$helper->log('<b>Manager: </b>' . $manager);
$s = new \PhpOffice\PhpSpreadsheet\Helper\Sample();

View File

@ -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 . '"');

View File

@ -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'),

View File

@ -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) {
@ -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,6 +3583,7 @@ 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;
}
@ -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);
@ -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 {

View File

@ -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';

View File

@ -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;
}

View File

@ -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) {

View File

@ -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'],

View File

@ -20,6 +20,7 @@ class Exception extends PhpSpreadsheetException
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}

View File

@ -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) {

View File

@ -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;
}

View File

@ -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';

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}
}
@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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 = '')
{

View File

@ -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);

View File

@ -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);

View File

@ -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';

View File

@ -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';

View File

@ -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

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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));

View File

@ -20,6 +20,7 @@ class Exception extends PhpSpreadsheetException
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}

View File

@ -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);
}

View File

@ -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)

View File

@ -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 = [])

View File

@ -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<br />';

View File

@ -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.

View File

@ -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;

View File

@ -18,6 +18,7 @@ class Exception extends \Exception
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}

View File

@ -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

View File

@ -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
*/

View File

@ -47,7 +47,7 @@ abstract class BaseReader implements IReader
*/
protected $readFilter;
protected $fileHandle = null;
protected $fileHandle;
/**
* Read data only?

View File

@ -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;

View File

@ -20,6 +20,7 @@ class Exception extends PhpSpreadsheetException
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;
}
}
@ -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;
}
}

View File

@ -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,24 +258,31 @@ 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;
}
}
@ -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;
}
}
@ -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;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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];
}

View File

@ -19,7 +19,7 @@ class ErrorCode
*
* @param int $code
*
* @return string|bool
* @return bool|string
*/
public static function lookup($code)
{

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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'])) ||

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
@ -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.');
}

View File

@ -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;
}

View File

@ -132,6 +132,7 @@ class CodePage
case 65001:
return 'UTF-8'; // Unicode (UTF-8)
}
throw new PhpSpreadsheetException('Unknown codepage: ' . $codePage);
}
}

View File

@ -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)
{

View File

@ -18,7 +18,7 @@ class DgContainer
*/
private $lastSpId;
private $spgrContainer = null;
private $spgrContainer;
public function getDgId()
{

View File

@ -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()
{

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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

View File

@ -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

View File

@ -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 |
// +----------------------------------------------------------------------+

View File

@ -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 |
// +----------------------------------------------------------------------+

View File

@ -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);

View File

@ -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.

View File

@ -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

View File

@ -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;

View File

@ -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)
{

View File

@ -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 {

View File

@ -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;

View File

@ -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
*

View File

@ -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;

View File

@ -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

View File

@ -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';

View File

@ -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';

View File

@ -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
*

View File

@ -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);
}

View File

@ -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 {
@ -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);
}
}

Some files were not shown because too many files have changed in this diff Show More