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) ->setRiskyAllowed(true)
->setFinder($finder) ->setFinder($finder)
->setRules([ ->setRules([
'align_multiline_comment' => true,
'array_syntax' => ['syntax' => 'short'], 'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => true, 'binary_operator_spaces' => true,
'blank_line_after_namespace' => true, 'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true, 'blank_line_after_opening_tag' => true,
'blank_line_before_return' => true, 'blank_line_before_return' => true,
'blank_line_before_statement' => true,
'braces' => true, 'braces' => true,
'cast_spaces' => true, 'cast_spaces' => true,
'class_definition' => true, 'class_definition' => true,
'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE 'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true, 'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'], 'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true, 'declare_equal_normalize' => true,
'declare_strict_types' => false, // Too early to adopt strict types 'declare_strict_types' => false, // Too early to adopt strict types
'dir_constant' => true, 'dir_constant' => true,
'doctrine_annotation_array_assignment' => true,
'doctrine_annotation_braces' => true,
'doctrine_annotation_indentation' => true,
'doctrine_annotation_spaces' => true,
'elseif' => true, 'elseif' => true,
'encoding' => true, 'encoding' => true,
'ereg_to_preg' => true, 'ereg_to_preg' => true,
'full_opening_tag' => true, 'full_opening_tag' => true,
'function_declaration' => true, 'function_declaration' => true,
'function_to_constant' => true,
'function_typehint_space' => true, 'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false, // No use for that 'general_phpdoc_annotation_remove' => false, // No use for that
'hash_to_slash_comment' => true, 'hash_to_slash_comment' => true,
'header_comment' => false, // We don't use common header in all our files 'header_comment' => false, // We don't use common header in all our files
'heredoc_to_nowdoc' => false, // Not sure about this one 'heredoc_to_nowdoc' => false, // Not sure about this one
'is_null' => false, // Risky
'include' => true, 'include' => true,
'indentation_type' => true, 'indentation_type' => true,
'line_ending' => true, 'is_null' => ['use_yoda_style' => false],
'linebreak_after_opening_tag' => true, 'linebreak_after_opening_tag' => true,
'line_ending' => true,
'list_syntax' => ['syntax' => 'short'],
'lowercase_cast' => true, 'lowercase_cast' => true,
'lowercase_constants' => true, 'lowercase_constants' => true,
'lowercase_keywords' => true, 'lowercase_keywords' => true,
'magic_constant_casing' => true,
'mb_str_functions' => false, // No, too dangerous to change that 'mb_str_functions' => false, // No, too dangerous to change that
'method_argument_space' => true, 'method_argument_space' => true,
'method_separation' => true, 'method_separation' => true,
@ -53,44 +63,47 @@ return PhpCsFixer\Config::create()
'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true, 'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace 'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
'no_break_comment' => true,
'no_closing_tag' => true, 'no_closing_tag' => true,
'no_empty_comment' => true, 'no_empty_comment' => true,
'no_empty_phpdoc' => true, 'no_empty_phpdoc' => true,
'no_empty_statement' => 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_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_import_slash' => true,
'no_leading_namespace_whitespace' => true, 'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true, 'no_mixed_echo_print' => true,
'no_multiline_whitespace_around_double_arrow' => true, 'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true, 'no_multiline_whitespace_before_semicolons' => true,
'non_printable_character' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true, 'no_php4_constructor' => true,
'normalize_index_brace' => true,
'no_short_bool_cast' => true, 'no_short_bool_cast' => true,
'no_short_echo_tag' => true, 'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true, 'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true, 'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true, 'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => 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_list_call' => true,
'no_trailing_comma_in_singleline_array' => true, 'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true, 'no_trailing_whitespace_in_comment' => true,
'no_trailing_whitespace' => true,
'no_unneeded_control_parentheses' => true, 'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true, 'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true, 'no_unused_imports' => true,
'no_useless_else' => true, 'no_useless_else' => true,
'no_useless_return' => true, 'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true, 'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => 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, 'object_operator_without_whitespace' => true,
'ordered_class_elements' => false, // We prefer to keep some freedom 'ordered_class_elements' => false, // We prefer to keep some freedom
'ordered_imports' => true, '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_add_missing_param_annotation' => true,
'phpdoc_align' => false, // Waste of time 'phpdoc_align' => false, // Waste of time
'phpdoc_annotation_without_dot' => true, 'phpdoc_annotation_without_dot' => true,
@ -109,8 +122,14 @@ return PhpCsFixer\Config::create()
'phpdoc_summary' => true, 'phpdoc_summary' => true,
'phpdoc_to_comment' => true, 'phpdoc_to_comment' => true,
'phpdoc_trim' => true, 'phpdoc_trim' => true,
'phpdoc_types_order' => true,
'phpdoc_types' => true, 'phpdoc_types' => true,
'phpdoc_var_without_name' => 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, 'pow_to_exponentiation' => false,
'pre_increment' => true, 'pre_increment' => true,
'protected_to_private' => true, 'protected_to_private' => true,
@ -128,6 +147,7 @@ return PhpCsFixer\Config::create()
'single_class_element_per_statement' => true, 'single_class_element_per_statement' => true,
'single_import_per_statement' => true, 'single_import_per_statement' => true,
'single_line_after_imports' => true, 'single_line_after_imports' => true,
'single_line_comment_style' => true,
'single_quote' => true, 'single_quote' => true,
'space_after_semicolon' => true, 'space_after_semicolon' => true,
'standardize_not_equals' => true, 'standardize_not_equals' => true,
@ -141,5 +161,7 @@ return PhpCsFixer\Config::create()
'trim_array_spaces' => true, 'trim_array_spaces' => true,
'unary_operator_spaces' => true, 'unary_operator_spaces' => true,
'visibility_required' => true, 'visibility_required' => true,
'void_return' => false, // Cannot use that with PHP 5.6
'whitespace_after_comma_in_array' => true, 'whitespace_after_comma_in_array' => true,
'yoda_style' => false,
]); ]);

505
composer.lock generated
View File

@ -56,6 +56,136 @@
} }
], ],
"packages-dev": [ "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", "name": "doctrine/instantiator",
"version": "1.0.5", "version": "1.0.5",
@ -110,6 +240,60 @@
], ],
"time": "2015-06-14T21:17:01+00:00" "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", "name": "dompdf/dompdf",
"version": "v0.8.0", "version": "v0.8.0",
@ -174,53 +358,71 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v2.1.2", "version": "v2.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "c7de769d7b44f2c9de68e1f678b65efd8126f60b" "reference": "e4e93a120117e879cfc1f231fbf29274707cd834"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c7de769d7b44f2c9de68e1f678b65efd8126f60b", "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/e4e93a120117e879cfc1f231fbf29274707cd834",
"reference": "c7de769d7b44f2c9de68e1f678b65efd8126f60b", "reference": "e4e93a120117e879cfc1f231fbf29274707cd834",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"composer/semver": "^1.4",
"doctrine/annotations": "^1.2",
"ext-json": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"php": "^5.3.6 || >=7.0 <7.2", "gecko-packages/gecko-php-unit": "^2.0",
"sebastian/diff": "^1.1", "php": "^5.6 || >=7.0 <7.3",
"symfony/console": "^2.3 || ^3.0", "php-cs-fixer/diff": "^1.0",
"symfony/event-dispatcher": "^2.1 || ^3.0", "symfony/console": "^3.2",
"symfony/filesystem": "^2.4 || ^3.0", "symfony/event-dispatcher": "^3.0",
"symfony/finder": "^2.2 || ^3.0", "symfony/filesystem": "^3.0",
"symfony/polyfill-php54": "^1.0", "symfony/finder": "^3.0",
"symfony/polyfill-php55": "^1.3", "symfony/options-resolver": "^3.0",
"symfony/polyfill-xml": "^1.3", "symfony/polyfill-php70": "^1.0",
"symfony/process": "^2.3 || ^3.0", "symfony/polyfill-php72": "^1.4",
"symfony/stopwatch": "^2.5 || ^3.0" "symfony/process": "^3.0",
"symfony/stopwatch": "^3.0"
}, },
"conflict": { "conflict": {
"hhvm": "<3.9" "hhvm": "*"
}, },
"require-dev": { "require-dev": {
"gecko-packages/gecko-php-unit": "^2.0", "johnkary/phpunit-speedtrap": "^1.1",
"justinrainbow/json-schema": "^5.0", "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", "satooshi/php-coveralls": "^1.0",
"symfony/phpunit-bridge": "^3.2" "symfony/phpunit-bridge": "^3.2.2"
}, },
"suggest": { "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": [ "bin": [
"php-cs-fixer" "php-cs-fixer"
], ],
"type": "application", "type": "application",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"PhpCsFixer\\": "src/" "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/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -237,7 +439,51 @@
} }
], ],
"description": "A tool to automatically fix PHP code style", "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", "name": "ircmaxell/password-compat",
@ -515,6 +761,53 @@
"homepage": "https://github.com/PhenX/php-svg-lib", "homepage": "https://github.com/PhenX/php-svg-lib",
"time": "2016-12-13T20:25:45+00:00" "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", "name": "phpdocumentor/reflection-common",
"version": "1.0", "version": "1.0",
@ -2120,6 +2413,60 @@
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-02-21T09:12:04+00:00" "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", "name": "symfony/polyfill-mbstring",
"version": "v1.3.0", "version": "v1.3.0",
@ -2293,6 +2640,120 @@
], ],
"time": "2016-11-14T01:06:16+00:00" "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", "name": "symfony/polyfill-xml",
"version": "v1.3.0", "version": "v1.3.0",

View File

@ -157,7 +157,7 @@ $spreadsheet->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:')
$helper->log('Calculated data'); $helper->log('Calculated data');
for ($col = 'B'; $col != 'G'; ++$col) { for ($col = 'B'; $col != 'G'; ++$col) {
for ($row = 14; $row <= 41; ++$row) { 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] == '=')) { ($formula[0] == '=')) {
$helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue()); $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'); $helper->log('Calculated data');
for ($row = 1; $row <= 2; ++$row) { for ($row = 1; $row <= 2; ++$row) {
for ($col = 'A'; $col != 'C'; ++$col) { 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] == '=')) { ($formula[0] == '=')) {
$helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue()); $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'); $reader = IOFactory::createReader('Xlsx');
$spreadsheet = $reader->load(__DIR__ . '/../templates/26template.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']); $helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']);
// Export to PDF (.pdf) // Export to PDF (.pdf)

View File

@ -26,7 +26,7 @@ foreach ($spreadsheet->getWorksheetIterator() as $worksheet) {
$cellIterator = $row->getCellIterator(); $cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set $cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
foreach ($cellIterator as $cell) { foreach ($cellIterator as $cell) {
if (!is_null($cell)) { if ($cell !== null) {
$helper->log(' Cell - ' . $cell->getCoordinate() . ' - ' . $cell->getCalculatedValue()); $helper->log(' Cell - ' . $cell->getCoordinate() . ' - ' . $cell->getCalculatedValue());
} }
} }

View File

@ -26,7 +26,7 @@ if (isset($_POST['submit'])) {
if ($_POST['A'] == 0) { if ($_POST['A'] == 0) {
$helper->log('The equation is not quadratic'); $helper->log('The equation is not quadratic');
} else { } else {
/* Calculate and Display the results * */ // Calculate and Display the results
$helper->log('<hr /><b>Roots:</b><br />'); $helper->log('<hr /><b>Roots:</b><br />');
$discriminantFormula = '=POWER(' . $_POST['B'] . ',2) - (4 * ' . $_POST['A'] . ' * ' . $_POST['C'] . ')'; $discriminantFormula = '=POWER(' . $_POST['B'] . ',2) - (4 * ' . $_POST['A'] . ' * ' . $_POST['C'] . ')';

View File

@ -20,6 +20,7 @@ foreach ($inputFileNames as $inputFileName) {
if (!file_exists($inputFileName)) { if (!file_exists($inputFileName)) {
$helper->log('File ' . $inputFileNameShort . ' does not exist'); $helper->log('File ' . $inputFileNameShort . ' does not exist');
continue; continue;
} }
$reader = IOFactory::createReader($inputFileType); $reader = IOFactory::createReader($inputFileType);
@ -40,7 +41,7 @@ foreach ($inputFileNames as $inputFileName) {
natsort($chartNames); natsort($chartNames);
foreach ($chartNames as $i => $chartName) { foreach ($chartNames as $i => $chartName) {
$chart = $worksheet->getChartByName($chartName); $chart = $worksheet->getChartByName($chartName);
if (!is_null($chart->getTitle())) { if ($chart->getTitle() !== null) {
$caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"'; $caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"';
} else { } else {
$caption = 'Untitled'; $caption = 'Untitled';

View File

@ -33,6 +33,7 @@ foreach ($inputFileNames as $inputFileName) {
if (!file_exists($inputFileName)) { if (!file_exists($inputFileName)) {
$helper->log('File ' . $inputFileNameShort . ' does not exist'); $helper->log('File ' . $inputFileNameShort . ' does not exist');
continue; continue;
} }
@ -54,7 +55,7 @@ foreach ($inputFileNames as $inputFileName) {
natsort($chartNames); natsort($chartNames);
foreach ($chartNames as $i => $chartName) { foreach ($chartNames as $i => $chartName) {
$chart = $worksheet->getChartByName($chartName); $chart = $worksheet->getChartByName($chartName);
if (!is_null($chart->getTitle())) { if ($chart->getTitle() !== null) {
$caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"'; $caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"';
} else { } else {
$caption = 'Untitled'; $caption = 'Untitled';

View File

@ -41,6 +41,7 @@ foreach ($inputFileNames as $inputFileName) {
if (!file_exists($inputFileName)) { if (!file_exists($inputFileName)) {
$helper->log('File ' . $inputFileNameShort . ' does not exist'); $helper->log('File ' . $inputFileNameShort . ' does not exist');
continue; continue;
} }
@ -62,7 +63,7 @@ foreach ($inputFileNames as $inputFileName) {
natsort($chartNames); natsort($chartNames);
foreach ($chartNames as $i => $chartName) { foreach ($chartNames as $i => $chartName) {
$chart = $worksheet->getChartByName($chartName); $chart = $worksheet->getChartByName($chartName);
if (!is_null($chart->getTitle())) { if ($chart->getTitle() !== null) {
$caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"'; $caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"';
} else { } else {
$caption = 'Untitled'; $caption = 'Untitled';

View File

@ -33,6 +33,7 @@ foreach ($inputFileNames as $inputFileName) {
if (!file_exists($inputFileName)) { if (!file_exists($inputFileName)) {
$helper->log('File ' . $inputFileNameShort . ' does not exist'); $helper->log('File ' . $inputFileNameShort . ' does not exist');
continue; continue;
} }
@ -54,7 +55,7 @@ foreach ($inputFileNames as $inputFileName) {
natsort($chartNames); natsort($chartNames);
foreach ($chartNames as $i => $chartName) { foreach ($chartNames as $i => $chartName) {
$chart = $worksheet->getChartByName($chartName); $chart = $worksheet->getChartByName($chartName);
if (!is_null($chart->getTitle())) { if ($chart->getTitle() !== null) {
$caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"'; $caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"';
} else { } else {
$caption = 'Untitled'; $caption = 'Untitled';
@ -65,6 +66,7 @@ foreach ($inputFileNames as $inputFileName) {
if (file_exists($jpegFile)) { if (file_exists($jpegFile)) {
unlink($jpegFile); unlink($jpegFile);
} }
try { try {
$chart->render($jpegFile); $chart->render($jpegFile);
} catch (Exception $e) { } catch (Exception $e) {

View File

@ -49,7 +49,6 @@ if ($helper->isCli()) {
} ?></ul> } ?></ul>
</li> </li>
<?php <?php
} ?> } ?>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <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); $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); $reader = IOFactory::createReader($inputFileType);
/* Define how many rows we want for each "chunk" * */ // Define how many rows we want for each "chunk"
$chunkSize = 20; $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) { 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)); $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); $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); $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); $spreadsheet = $reader->load($inputFileName);
// Do some processing here // 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); $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); $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; $chunkSize = 20;
/* Create a new Instance of our Read Filter * */ // Create a new Instance of our Read Filter
$chunkFilter = new ChunkReadFilter(); $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); $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) { 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)); $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); $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); $spreadsheet = $reader->load($inputFileName);
// Do some processing here // 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); $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); $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; $chunkSize = 100;
/* Create a new Instance of our Read Filter * */ // Create a new Instance of our Read Filter
$chunkFilter = new ChunkReadFilter(); $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
/* and that we want to store it in contiguous rows/columns * */ // and that we want to store it in contiguous rows/columns
$reader->setReadFilter($chunkFilter) $reader->setReadFilter($chunkFilter)
->setContiguous(true); ->setContiguous(true);
/* Instantiate a new PhpSpreadsheet object manually * */ // Instantiate a new PhpSpreadsheet object manually
$spreadsheet = new Spreadsheet(); $spreadsheet = new Spreadsheet();
/* Set a sheet index * */ // Set a sheet index
$sheet = 0; $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 * */ /** $startRow is set to 2 initially because we always read the headings in row #1 * */
for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) { 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)); $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); $chunkFilter->setRows($startRow, $chunkSize);
/* Increment the worksheet index pointer for the Reader * */ // Increment the worksheet index pointer for the Reader
$reader->setSheetIndex($sheet); $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); $reader->loadIntoExisting($inputFileName, $spreadsheet);
/* Set the worksheet title (to reference the "sheet" of data that we've loaded) * */ // Set the worksheet title (to reference the "sheet" of data that we've loaded)
/* and increment the sheet index as well * */ // and increment the sheet index as well
$spreadsheet->getActiveSheet()->setTitle('Country Data #' . (++$sheet)); $spreadsheet->getActiveSheet()->setTitle('Country Data #' . (++$sheet));
} }

View File

@ -6,6 +6,7 @@ require __DIR__ . '/../Header.php';
$inputFileName = __DIR__ . '/sampleData/non-existing-file.xls'; $inputFileName = __DIR__ . '/sampleData/non-existing-file.xls';
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory to identify the format'); $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory to identify the format');
try { try {
$spreadsheet = IOFactory::load($inputFileName); $spreadsheet = IOFactory::load($inputFileName);
} catch (InvalidArgumentException $e) { } 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); $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
$reader = IOFactory::createReader($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'); $helper->log('Read the list of Worksheets in the WorkBook');
$worksheetNames = $reader->listWorksheetNames($inputFileName); $worksheetNames = $reader->listWorksheetNames($inputFileName);

View File

@ -7,40 +7,45 @@ require __DIR__ . '/../Header.php';
$inputFileType = 'Xlsx'; $inputFileType = 'Xlsx';
$inputFileName = __DIR__ . '/sampleData/example1.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); $reader = IOFactory::createReader($inputFileType);
/* Load $inputFileName to a PhpSpreadsheet Object * */ // Load $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName); $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(); $customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
/* Loop through the list of custom properties * */ // Loop through the list of custom properties
foreach ($customPropertyList as $customPropertyName) { foreach ($customPropertyList as $customPropertyName) {
$helper->log('<b>' . $customPropertyName . ': </b>'); $helper->log('<b>' . $customPropertyName . ': </b>');
/* Retrieve the property value * */ // Retrieve the property value
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customPropertyName); $propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customPropertyName);
/* Retrieve the property type * */ // Retrieve the property type
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customPropertyName); $propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customPropertyName);
/* Manipulate properties as appropriate for display purposes * */ // Manipulate properties as appropriate for display purposes
switch ($propertyType) { switch ($propertyType) {
case 'i': // integer case 'i': // integer
$propertyType = 'integer number'; $propertyType = 'integer number';
break; break;
case 'f': // float case 'f': // float
$propertyType = 'floating point number'; $propertyType = 'floating point number';
break; break;
case 's': // string case 's': // string
$propertyType = 'string'; $propertyType = 'string';
break; break;
case 'd': // date case 'd': // date
$propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A', $propertyValue); $propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A', $propertyValue);
$propertyType = 'date'; $propertyType = 'date';
break; break;
case 'b': // boolean case 'b': // boolean
$propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE'; $propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE';
$propertyType = 'boolean'; $propertyType = 'boolean';
break; break;
} }

View File

@ -7,12 +7,12 @@ require __DIR__ . '/../Header.php';
$inputFileType = 'Xlsx'; $inputFileType = 'Xlsx';
$inputFileName = __DIR__ . '/sampleData/example1.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); $reader = IOFactory::createReader($inputFileType);
/* Load $inputFileName to a PhpSpreadsheet Object * */ // Load $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName); $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(); $customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
foreach ($customPropertyList as $customPropertyName) { foreach ($customPropertyList as $customPropertyName) {

View File

@ -7,58 +7,58 @@ require __DIR__ . '/../Header.php';
$inputFileType = 'Xls'; $inputFileType = 'Xls';
$inputFileName = __DIR__ . '/sampleData/example1.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); $reader = IOFactory::createReader($inputFileType);
/* Load $inputFileName to a PhpSpreadsheet Object * */ // Load $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName); $spreadsheet = $reader->load($inputFileName);
/* Read the document's creator property * */ // Read the document's creator property
$creator = $spreadsheet->getProperties()->getCreator(); $creator = $spreadsheet->getProperties()->getCreator();
$helper->log('<b>Document Creator: </b>' . $creator); $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(); $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); $creationDate = date('l, d<\s\up>S</\s\up> F Y', $creationDatestamp);
$creationTime = date('g:i A', $creationDatestamp); $creationTime = date('g:i A', $creationDatestamp);
$helper->log('<b>Created On: </b>' . $creationDate . ' at ' . $creationTime); $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(); $modifiedBy = $spreadsheet->getProperties()->getLastModifiedBy();
$helper->log('<b>Last Modified By: </b>' . $modifiedBy); $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(); $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); $modifiedDate = date('l, d<\s\up>S</\s\up> F Y', $modifiedDatestamp);
$modifiedTime = date('g:i A', $modifiedDatestamp); $modifiedTime = date('g:i A', $modifiedDatestamp);
$helper->log('<b>Last Modified On: </b>' . $modifiedDate . ' at ' . $modifiedTime); $helper->log('<b>Last Modified On: </b>' . $modifiedDate . ' at ' . $modifiedTime);
/* Read the workbook title property * */ // Read the workbook title property
$workbookTitle = $spreadsheet->getProperties()->getTitle(); $workbookTitle = $spreadsheet->getProperties()->getTitle();
$helper->log('<b>Title: </b>' . $workbookTitle); $helper->log('<b>Title: </b>' . $workbookTitle);
/* Read the workbook description property * */ // Read the workbook description property
$description = $spreadsheet->getProperties()->getDescription(); $description = $spreadsheet->getProperties()->getDescription();
$helper->log('<b>Description: </b>' . $description); $helper->log('<b>Description: </b>' . $description);
/* Read the workbook subject property * */ // Read the workbook subject property
$subject = $spreadsheet->getProperties()->getSubject(); $subject = $spreadsheet->getProperties()->getSubject();
$helper->log('<b>Subject: </b>' . $subject); $helper->log('<b>Subject: </b>' . $subject);
/* Read the workbook keywords property * */ // Read the workbook keywords property
$keywords = $spreadsheet->getProperties()->getKeywords(); $keywords = $spreadsheet->getProperties()->getKeywords();
$helper->log('<b>Keywords: </b>' . $keywords); $helper->log('<b>Keywords: </b>' . $keywords);
/* Read the workbook category property * */ // Read the workbook category property
$category = $spreadsheet->getProperties()->getCategory(); $category = $spreadsheet->getProperties()->getCategory();
$helper->log('<b>Category: </b>' . $category); $helper->log('<b>Category: </b>' . $category);
/* Read the workbook company property * */ // Read the workbook company property
$company = $spreadsheet->getProperties()->getCompany(); $company = $spreadsheet->getProperties()->getCompany();
$helper->log('<b>Company: </b>' . $company); $helper->log('<b>Company: </b>' . $company);
/* Read the workbook manager property * */ // Read the workbook manager property
$manager = $spreadsheet->getProperties()->getManager(); $manager = $spreadsheet->getProperties()->getManager();
$helper->log('<b>Manager: </b>' . $manager); $helper->log('<b>Manager: </b>' . $manager);
$s = new \PhpOffice\PhpSpreadsheet\Helper\Sample(); $s = new \PhpOffice\PhpSpreadsheet\Helper\Sample();

View File

@ -7,17 +7,17 @@ require __DIR__ . '/../Header.php';
$inputFileType = 'Xls'; $inputFileType = 'Xls';
$inputFileName = __DIR__ . '/sampleData/example2.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); $reader = IOFactory::createReader($inputFileType);
/* Load $inputFileName to a PhpSpreadsheet Object * */ // Load $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName); $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(); $sheetCount = $spreadsheet->getSheetCount();
$helper->log('There ' . (($sheetCount == 1) ? 'is' : 'are') . ' ' . $sheetCount . ' WorkSheet' . (($sheetCount == 1) ? '' : 's') . ' in the WorkBook'); $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'); $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(); $sheetNames = $spreadsheet->getSheetNames();
foreach ($sheetNames as $sheetIndex => $sheetName) { foreach ($sheetNames as $sheetIndex => $sheetName) {
$helper->log('WorkSheet #' . $sheetIndex . ' is named "' . $sheetName . '"'); $helper->log('WorkSheet #' . $sheetIndex . ' is named "' . $sheetName . '"');

View File

@ -3,7 +3,7 @@
require_once 'Header.php'; require_once 'Header.php';
$requirements = [ $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 XML' => extension_loaded('xml'),
'PHP extension xmlwriter' => extension_loaded('xmlwriter'), 'PHP extension xmlwriter' => extension_loaded('xmlwriter'),
'PHP extension mbstring' => extension_loaded('mbstring'), 'PHP extension mbstring' => extension_loaded('mbstring'),

View File

@ -115,7 +115,7 @@ class Calculation
* *
* @var string * @var string
*/ */
public $formulaError = null; public $formulaError;
/** /**
* An array of the nested cell references accessed by the calculation engine, used for the debug log. * 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 // Identify our locale and language
$language = $locale = strtolower($locale); $language = $locale = strtolower($locale);
if (strpos($locale, '_') !== false) { if (strpos($locale, '_') !== false) {
list($language) = explode('_', $locale); [$language] = explode('_', $locale);
} }
if (count(self::$validLocaleLanguages) == 1) { if (count(self::$validLocaleLanguages) == 1) {
@ -2243,9 +2243,9 @@ class Calculation
// Retrieve the list of locale or language specific function names // Retrieve the list of locale or language specific function names
$localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($localeFunctions as $localeFunction) { foreach ($localeFunctions as $localeFunction) {
list($localeFunction) = explode('##', $localeFunction); // Strip out comments [$localeFunction] = explode('##', $localeFunction); // Strip out comments
if (strpos($localeFunction, '=') !== false) { if (strpos($localeFunction, '=') !== false) {
list($fName, $lfName) = explode('=', $localeFunction); [$fName, $lfName] = explode('=', $localeFunction);
$fName = trim($fName); $fName = trim($fName);
$lfName = trim($lfName); $lfName = trim($lfName);
if ((isset(self::$phpSpreadsheetFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) { if ((isset(self::$phpSpreadsheetFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {
@ -2268,13 +2268,14 @@ class Calculation
if (file_exists($configFile)) { if (file_exists($configFile)) {
$localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($localeSettings as $localeSetting) { foreach ($localeSettings as $localeSetting) {
list($localeSetting) = explode('##', $localeSetting); // Strip out comments [$localeSetting] = explode('##', $localeSetting); // Strip out comments
if (strpos($localeSetting, '=') !== false) { if (strpos($localeSetting, '=') !== false) {
list($settingName, $settingValue) = explode('=', $localeSetting); [$settingName, $settingValue] = explode('=', $localeSetting);
$settingName = strtoupper(trim($settingName)); $settingName = strtoupper(trim($settingName));
switch ($settingName) { switch ($settingName) {
case 'ARGUMENTSEPARATOR': case 'ARGUMENTSEPARATOR':
self::$localeArgumentSeparator = trim($settingValue); self::$localeArgumentSeparator = trim($settingValue);
break; break;
} }
} }
@ -2308,9 +2309,11 @@ class Calculation
switch ($chr) { switch ($chr) {
case '{': case '{':
$inBraces = true; $inBraces = true;
break; break;
case '}': case '}':
$inBraces = false; $inBraces = false;
break; break;
case $fromSeparator: case $fromSeparator:
if (!$inBraces) { if (!$inBraces) {
@ -2529,6 +2532,7 @@ class Calculation
'sheet' => $pCell->getWorksheet()->getTitle(), 'sheet' => $pCell->getWorksheet()->getTitle(),
'cell' => $pCell->getCoordinate(), 'cell' => $pCell->getCoordinate(),
]; ];
try { try {
$result = self::unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell)); $result = self::unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));
$cellAddress = array_pop($this->cellStack); $cellAddress = array_pop($this->cellStack);
@ -2536,6 +2540,7 @@ class Calculation
} catch (Exception $e) { } catch (Exception $e) {
$cellAddress = array_pop($this->cellStack); $cellAddress = array_pop($this->cellStack);
$this->spreadsheet->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']); $this->spreadsheet->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
throw new Calculation\Exception($e->getMessage()); 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 // 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 // Note that this function should only be called if one or both of the operand is already an array
if (!is_array($operand1)) { 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)); $operand1 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand1));
$resize = 0; $resize = 0;
} elseif (!is_array($operand2)) { } 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)); $operand2 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand2));
$resize = 0; $resize = 0;
} }
list($matrix1Rows, $matrix1Columns) = self::getMatrixDimensions($operand1); [$matrix1Rows, $matrix1Columns] = self::getMatrixDimensions($operand1);
list($matrix2Rows, $matrix2Columns) = self::getMatrixDimensions($operand2); [$matrix2Rows, $matrix2Columns] = self::getMatrixDimensions($operand2);
if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) { if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) {
$resize = 1; $resize = 1;
} }
@ -2944,7 +2949,7 @@ class Calculation
* *
* @param mixed $value First matrix operand * @param mixed $value First matrix operand
* *
* @return string|null * @return null|string
*/ */
private function showTypeDetails($value) private function showTypeDetails($value)
{ {
@ -3073,7 +3078,7 @@ class Calculation
/** /**
* @param string $formula * @param string $formula
* @param Cell|null $pCell * @param null|Cell $pCell
* *
* @return bool * @return bool
*/ */
@ -3181,18 +3186,21 @@ class Calculation
$argumentCountError = true; $argumentCountError = true;
$expectedArgumentCountString = $argMatch[1] . ' or more '; $expectedArgumentCountString = $argMatch[1] . ' or more ';
} }
break; break;
case '-': case '-':
if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) { if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) {
$argumentCountError = true; $argumentCountError = true;
$expectedArgumentCountString = 'between ' . $argMatch[1] . ' and ' . $argMatch[3]; $expectedArgumentCountString = 'between ' . $argMatch[1] . ' and ' . $argMatch[3];
} }
break; break;
case ',': case ',':
if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) { if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) {
$argumentCountError = true; $argumentCountError = true;
$expectedArgumentCountString = 'either ' . $argMatch[1] . ' or ' . $argMatch[3]; $expectedArgumentCountString = 'either ' . $argMatch[1] . ' or ' . $argMatch[3];
} }
break; break;
} }
} }
@ -3278,14 +3286,14 @@ class Calculation
$startRowColRef = $output[count($output) - 1]['value']; $startRowColRef = $output[count($output) - 1]['value'];
$rangeWS1 = ''; $rangeWS1 = '';
if (strpos('!', $startRowColRef) !== false) { if (strpos('!', $startRowColRef) !== false) {
list($rangeWS1, $startRowColRef) = explode('!', $startRowColRef); [$rangeWS1, $startRowColRef] = explode('!', $startRowColRef);
} }
if ($rangeWS1 != '') { if ($rangeWS1 != '') {
$rangeWS1 .= '!'; $rangeWS1 .= '!';
} }
$rangeWS2 = $rangeWS1; $rangeWS2 = $rangeWS1;
if (strpos('!', $val) !== false) { if (strpos('!', $val) !== false) {
list($rangeWS2, $val) = explode('!', $val); [$rangeWS2, $val] = explode('!', $val);
} }
if ($rangeWS2 != '') { if ($rangeWS2 != '') {
$rangeWS2 .= '!'; $rangeWS2 .= '!';
@ -3350,6 +3358,7 @@ class Calculation
if ((isset(self::$operators[$opCharacter])) && ($opCharacter != '%')) { if ((isset(self::$operators[$opCharacter])) && ($opCharacter != '%')) {
return $this->raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands"); return $this->raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands");
} }
break; break;
} }
// Ignore white space // Ignore white space
@ -3406,8 +3415,8 @@ class Calculation
/** /**
* @param mixed $tokens * @param mixed $tokens
* @param string|null $cellID * @param null|string $cellID
* @param Cell|null $pCell * @param null|Cell $pCell
* *
* @return bool * @return bool
*/ */
@ -3456,17 +3465,18 @@ class Calculation
case '=': // Equality case '=': // Equality
case '<>': // Inequality case '<>': // Inequality
$this->executeBinaryComparisonOperation($cellID, $operand1, $operand2, $token, $stack); $this->executeBinaryComparisonOperation($cellID, $operand1, $operand2, $token, $stack);
break; break;
// Binary Operators // Binary Operators
case ':': // Range case ':': // Range
$sheet1 = $sheet2 = ''; $sheet1 = $sheet2 = '';
if (strpos($operand1Data['reference'], '!') !== false) { if (strpos($operand1Data['reference'], '!') !== false) {
list($sheet1, $operand1Data['reference']) = explode('!', $operand1Data['reference']); [$sheet1, $operand1Data['reference']] = explode('!', $operand1Data['reference']);
} else { } else {
$sheet1 = ($pCellParent !== null) ? $pCellWorksheet->getTitle() : ''; $sheet1 = ($pCellParent !== null) ? $pCellWorksheet->getTitle() : '';
} }
if (strpos($operand2Data['reference'], '!') !== false) { if (strpos($operand2Data['reference'], '!') !== false) {
list($sheet2, $operand2Data['reference']) = explode('!', $operand2Data['reference']); [$sheet2, $operand2Data['reference']] = explode('!', $operand2Data['reference']);
} else { } else {
$sheet2 = $sheet1; $sheet2 = $sheet1;
} }
@ -3507,21 +3517,27 @@ class Calculation
} else { } else {
$stack->push('Error', Calculation\Functions::REF(), null); $stack->push('Error', Calculation\Functions::REF(), null);
} }
break; break;
case '+': // Addition case '+': // Addition
$this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'plusEquals', $stack); $this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'plusEquals', $stack);
break; break;
case '-': // Subtraction case '-': // Subtraction
$this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'minusEquals', $stack); $this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'minusEquals', $stack);
break; break;
case '*': // Multiplication case '*': // Multiplication
$this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'arrayTimesEquals', $stack); $this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'arrayTimesEquals', $stack);
break; break;
case '/': // Division case '/': // Division
$this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'arrayRightDivide', $stack); $this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'arrayRightDivide', $stack);
break; break;
case '^': // Exponential case '^': // Exponential
$this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'power', $stack); $this->executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'power', $stack);
break; break;
case '&': // Concatenation case '&': // Concatenation
// If either of the operands is a matrix, we need to treat them both as matrices // 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))) { if ((is_array($operand1)) || (is_array($operand2))) {
// Ensure that both operands are arrays/matrices // Ensure that both operands are arrays/matrices
self::checkMatrixOperands($operand1, $operand2, 2); self::checkMatrixOperands($operand1, $operand2, 2);
try { try {
// Convert operand 1 from a PHP array to a matrix // Convert operand 1 from a PHP array to a matrix
$matrix = new Shared\JAMA\Matrix($operand1); $matrix = new Shared\JAMA\Matrix($operand1);
@ -3551,6 +3568,7 @@ class Calculation
} }
$this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result)); $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result));
$stack->push('Value', $result); $stack->push('Value', $result);
break; break;
case '|': // Intersect case '|': // Intersect
$rowIntersect = array_intersect_key($operand1, $operand2); $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); $cellRef = Cell::stringFromColumnIndex(min($oCol)) . min($oRow) . ':' . Cell::stringFromColumnIndex(max($oCol)) . max($oRow);
$this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($cellIntersect)); $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($cellIntersect));
$stack->push('Value', $cellIntersect, $cellRef); $stack->push('Value', $cellIntersect, $cellRef);
break; break;
} }
@ -3583,6 +3602,7 @@ class Calculation
} }
if (is_array($arg)) { if (is_array($arg)) {
self::checkMatrixOperands($arg, $multiplier, 2); self::checkMatrixOperands($arg, $multiplier, 2);
try { try {
$matrix1 = new Shared\JAMA\Matrix($arg); $matrix1 = new Shared\JAMA\Matrix($arg);
$matrixResult = $matrix1->arrayTimesEquals($multiplier); $matrixResult = $matrix1->arrayTimesEquals($multiplier);
@ -3819,7 +3839,7 @@ class Calculation
} }
/** /**
* @param string|null $cellID * @param null|string $cellID
* @param mixed $operand1 * @param mixed $operand1
* @param mixed $operand2 * @param mixed $operand2
* @param string $operation * @param string $operation
@ -3895,6 +3915,7 @@ class Calculation
} else { } else {
$result = ($operand1 > $operand2); $result = ($operand1 > $operand2);
} }
break; break;
// Less than // Less than
case '<': case '<':
@ -3903,6 +3924,7 @@ class Calculation
} else { } else {
$result = ($operand1 < $operand2); $result = ($operand1 < $operand2);
} }
break; break;
// Equality // Equality
case '=': case '=':
@ -3911,6 +3933,7 @@ class Calculation
} else { } else {
$result = strcmp($operand1, $operand2) == 0; $result = strcmp($operand1, $operand2) == 0;
} }
break; break;
// Greater than or equal // Greater than or equal
case '>=': case '>=':
@ -3921,6 +3944,7 @@ class Calculation
} else { } else {
$result = strcmp($operand1, $operand2) >= 0; $result = strcmp($operand1, $operand2) >= 0;
} }
break; break;
// Less than or equal // Less than or equal
case '<=': case '<=':
@ -3931,6 +3955,7 @@ class Calculation
} else { } else {
$result = strcmp($operand1, $operand2) <= 0; $result = strcmp($operand1, $operand2) <= 0;
} }
break; break;
// Inequality // Inequality
case '<>': case '<>':
@ -3939,6 +3964,7 @@ class Calculation
} else { } else {
$result = strcmp($operand1, $operand2) != 0; $result = strcmp($operand1, $operand2) != 0;
} }
break; break;
} }
@ -3968,7 +3994,7 @@ class Calculation
/** /**
* @param string $matrixFunction * @param string $matrixFunction
* @param string|null $cellID * @param null|string $cellID
* @param mixed $operand1 * @param mixed $operand1
* @param mixed $operand2 * @param mixed $operand2
* @param mixed $operation * @param mixed $operation
@ -4011,14 +4037,17 @@ class Calculation
// Addition // Addition
case '+': case '+':
$result = $operand1 + $operand2; $result = $operand1 + $operand2;
break; break;
// Subtraction // Subtraction
case '-': case '-':
$result = $operand1 - $operand2; $result = $operand1 - $operand2;
break; break;
// Multiplication // Multiplication
case '*': case '*':
$result = $operand1 * $operand2; $result = $operand1 * $operand2;
break; break;
// Division // Division
case '/': case '/':
@ -4035,6 +4064,7 @@ class Calculation
// Power // Power
case '^': case '^':
$result = pow($operand1, $operand2); $result = pow($operand1, $operand2);
break; break;
} }
} }
@ -4078,7 +4108,7 @@ class Calculation
if ($pSheet !== null) { if ($pSheet !== null) {
$pSheetName = $pSheet->getTitle(); $pSheetName = $pSheet->getTitle();
if (strpos($pRange, '!') !== false) { if (strpos($pRange, '!') !== false) {
list($pSheetName, $pRange) = Worksheet::extractSheetTitle($pRange, true); [$pSheetName, $pRange] = Worksheet::extractSheetTitle($pRange, true);
$pSheet = $this->spreadsheet->getSheetByName($pSheetName); $pSheet = $this->spreadsheet->getSheetByName($pSheetName);
} }
@ -4129,7 +4159,7 @@ class Calculation
if ($pSheet !== null) { if ($pSheet !== null) {
$pSheetName = $pSheet->getTitle(); $pSheetName = $pSheet->getTitle();
if (strpos($pRange, '!') !== false) { if (strpos($pRange, '!') !== false) {
list($pSheetName, $pRange) = Worksheet::extractSheetTitle($pRange, true); [$pSheetName, $pRange] = Worksheet::extractSheetTitle($pRange, true);
$pSheet = $this->spreadsheet->getSheetByName($pSheetName); $pSheet = $this->spreadsheet->getSheetByName($pSheetName);
} }
@ -4153,7 +4183,7 @@ class Calculation
$aReferences = Cell::extractAllCellReferencesInRange($pRange); $aReferences = Cell::extractAllCellReferencesInRange($pRange);
if (!isset($aReferences[1])) { if (!isset($aReferences[1])) {
// Single cell (or single column or row) in range // 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])) { if ($pSheet->cellExists($aReferences[0])) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog); $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
} else { } else {
@ -4163,7 +4193,7 @@ class Calculation
// Extract cell data for all cells in the range // Extract cell data for all cells in the range
foreach ($aReferences as $reference) { foreach ($aReferences as $reference) {
// Extract range // Extract range
list($currentCol, $currentRow) = Cell::coordinateFromString($reference); [$currentCol, $currentRow] = Cell::coordinateFromString($reference);
if ($pSheet->cellExists($reference)) { if ($pSheet->cellExists($reference)) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog); $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
} else { } else {

View File

@ -4,7 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
abstract class Category abstract class Category
{ {
/* Function categories */ // Function categories
const CATEGORY_CUBE = 'Cube'; const CATEGORY_CUBE = 'Cube';
const CATEGORY_DATABASE = 'Database'; const CATEGORY_DATABASE = 'Database';
const CATEGORY_DATE_AND_TIME = 'Date and Time'; 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 * represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on. * the first column, 2 for the second column, and so on.
* *
* @return string|null * @return null|string
*/ */
private static function fieldExtract($database, $field) 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 * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -154,7 +154,7 @@ class Database
public static function DAVERAGE($database, $field, $criteria) public static function DAVERAGE($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -182,7 +182,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -201,7 +201,7 @@ class Database
public static function DCOUNT($database, $field, $criteria) public static function DCOUNT($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -225,7 +225,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -244,7 +244,7 @@ class Database
public static function DCOUNTA($database, $field, $criteria) public static function DCOUNTA($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -277,7 +277,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -293,7 +293,7 @@ class Database
public static function DGET($database, $field, $criteria) public static function DGET($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -321,7 +321,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -337,7 +337,7 @@ class Database
public static function DMAX($database, $field, $criteria) public static function DMAX($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -362,7 +362,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -378,7 +378,7 @@ class Database
public static function DMIN($database, $field, $criteria) public static function DMIN($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -402,7 +402,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -418,7 +418,7 @@ class Database
public static function DPRODUCT($database, $field, $criteria) public static function DPRODUCT($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -443,7 +443,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -459,7 +459,7 @@ class Database
public static function DSTDEV($database, $field, $criteria) public static function DSTDEV($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -484,7 +484,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -500,7 +500,7 @@ class Database
public static function DSTDEVP($database, $field, $criteria) public static function DSTDEVP($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -524,7 +524,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -540,7 +540,7 @@ class Database
public static function DSUM($database, $field, $criteria) public static function DSUM($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -565,7 +565,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -581,7 +581,7 @@ class Database
public static function DVAR($database, $field, $criteria) public static function DVAR($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }
@ -606,7 +606,7 @@ class Database
* A database is a list of related data in which rows of related * A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The * information are records, and columns of data are fields. The
* first row of the list contains labels for each column. * 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 * column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that * "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for * represents the position of the column within the list: 1 for
@ -622,7 +622,7 @@ class Database
public static function DVARP($database, $field, $criteria) public static function DVARP($database, $field, $criteria)
{ {
$field = self::fieldExtract($database, $field); $field = self::fieldExtract($database, $field);
if (is_null($field)) { if ($field === null) {
return null; return null;
} }

View File

@ -154,12 +154,15 @@ class DateTime
switch (Functions::getReturnDateType()) { switch (Functions::getReturnDateType()) {
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
$retValue = (float) Date::PHPToExcel(time()); $retValue = (float) Date::PHPToExcel(time());
break; break;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
$retValue = (int) time(); $retValue = (int) time();
break; break;
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
$retValue = new \DateTime(); $retValue = new \DateTime();
break; break;
} }
date_default_timezone_set($saveTimeZone); date_default_timezone_set($saveTimeZone);
@ -195,12 +198,15 @@ class DateTime
switch (Functions::getReturnDateType()) { switch (Functions::getReturnDateType()) {
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
$retValue = (float) $excelDateTime; $retValue = (float) $excelDateTime;
break; break;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
$retValue = (int) Date::excelToTimestamp($excelDateTime); $retValue = (int) Date::excelToTimestamp($excelDateTime);
break; break;
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
$retValue = Date::excelToDateTimeObject($excelDateTime); $retValue = Date::excelToDateTimeObject($excelDateTime);
break; break;
} }
date_default_timezone_set($saveTimeZone); date_default_timezone_set($saveTimeZone);
@ -681,6 +687,7 @@ class DateTime
switch ($unit) { switch ($unit) {
case 'D': case 'D':
$retVal = (int) $difference; $retVal = (int) $difference;
break; break;
case 'M': case 'M':
$retVal = (int) ($endMonths - $startMonths) + ((int) ($endYears - $startYears) * 12); $retVal = (int) ($endMonths - $startMonths) + ((int) ($endYears - $startYears) * 12);
@ -688,6 +695,7 @@ class DateTime
if ($endDays < $startDays) { if ($endDays < $startDays) {
--$retVal; --$retVal;
} }
break; break;
case 'Y': case 'Y':
$retVal = (int) ($endYears - $startYears); $retVal = (int) ($endYears - $startYears);
@ -700,6 +708,7 @@ class DateTime
// Remove end month // Remove end month
--$retVal; --$retVal;
} }
break; break;
case 'MD': case 'MD':
if ($endDays < $startDays) { if ($endDays < $startDays) {
@ -710,6 +719,7 @@ class DateTime
} else { } else {
$retVal = $endDays - $startDays; $retVal = $endDays - $startDays;
} }
break; break;
case 'YM': case 'YM':
$retVal = (int) ($endMonths - $startMonths); $retVal = (int) ($endMonths - $startMonths);
@ -720,6 +730,7 @@ class DateTime
if ($endDays < $startDays) { if ($endDays < $startDays) {
--$retVal; --$retVal;
} }
break; break;
case 'YD': case 'YD':
$retVal = (int) $difference; $retVal = (int) $difference;
@ -744,6 +755,7 @@ class DateTime
--$retVal; --$retVal;
} }
} }
break; break;
default: default:
$retVal = Functions::VALUE(); $retVal = Functions::VALUE();
@ -1183,11 +1195,13 @@ class DateTime
switch ($style) { switch ($style) {
case 1: case 1:
++$DoW; ++$DoW;
break; break;
case 2: case 2:
if ($DoW == 0) { if ($DoW == 0) {
$DoW = 7; $DoW = 7;
} }
break; break;
case 3: case 3:
if ($DoW == 0) { if ($DoW == 0) {
@ -1195,6 +1209,7 @@ class DateTime
} }
$firstDay = 0; $firstDay = 0;
--$DoW; --$DoW;
break; break;
} }
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_EXCEL) { if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_EXCEL) {

View File

@ -805,7 +805,7 @@ class Engineering
*/ */
private static function nbrConversionFormat($xVal, $places) private static function nbrConversionFormat($xVal, $places)
{ {
if (!is_null($places)) { if ($places !== null) {
if (is_numeric($places)) { if (is_numeric($places)) {
$places = (int) $places; $places = (int) $places;
} else { } else {
@ -846,8 +846,8 @@ class Engineering
*/ */
public static function BESSELI($x, $ord) public static function BESSELI($x, $ord)
{ {
$x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x); $x = ($x === null) ? 0.0 : Functions::flattenSingleValue($x);
$ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord); $ord = ($ord === null) ? 0.0 : Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) { if ((is_numeric($x)) && (is_numeric($ord))) {
$ord = floor($ord); $ord = floor($ord);
@ -900,8 +900,8 @@ class Engineering
*/ */
public static function BESSELJ($x, $ord) public static function BESSELJ($x, $ord)
{ {
$x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x); $x = ($x === null) ? 0.0 : Functions::flattenSingleValue($x);
$ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord); $ord = ($ord === null) ? 0.0 : Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) { if ((is_numeric($x)) && (is_numeric($ord))) {
$ord = floor($ord); $ord = floor($ord);
@ -993,8 +993,8 @@ class Engineering
*/ */
public static function BESSELK($x, $ord) public static function BESSELK($x, $ord)
{ {
$x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x); $x = ($x === null) ? 0.0 : Functions::flattenSingleValue($x);
$ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord); $ord = ($ord === null) ? 0.0 : Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) { if ((is_numeric($x)) && (is_numeric($ord))) {
if (($ord < 0) || ($x == 0.0)) { if (($ord < 0) || ($x == 0.0)) {
@ -1004,9 +1004,11 @@ class Engineering
switch (floor($ord)) { switch (floor($ord)) {
case 0: case 0:
$fBk = self::besselK0($x); $fBk = self::besselK0($x);
break; break;
case 1: case 1:
$fBk = self::besselK1($x); $fBk = self::besselK1($x);
break; break;
default: default:
$fTox = 2 / $x; $fTox = 2 / $x;
@ -1080,8 +1082,8 @@ class Engineering
*/ */
public static function BESSELY($x, $ord) public static function BESSELY($x, $ord)
{ {
$x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x); $x = ($x === null) ? 0.0 : Functions::flattenSingleValue($x);
$ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord); $ord = ($ord === null) ? 0.0 : Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) { if ((is_numeric($x)) && (is_numeric($ord))) {
if (($ord < 0) || ($x == 0.0)) { if (($ord < 0) || ($x == 0.0)) {
@ -1091,9 +1093,11 @@ class Engineering
switch (floor($ord)) { switch (floor($ord)) {
case 0: case 0:
$fBy = self::besselY0($x); $fBy = self::besselY0($x);
break; break;
case 1: case 1:
$fBy = self::besselY1($x); $fBy = self::besselY1($x);
break; break;
default: default:
$fTox = 2 / $x; $fTox = 2 / $x;
@ -1757,9 +1761,9 @@ class Engineering
*/ */
public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i') public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i')
{ {
$realNumber = (is_null($realNumber)) ? 0.0 : Functions::flattenSingleValue($realNumber); $realNumber = ($realNumber === null) ? 0.0 : Functions::flattenSingleValue($realNumber);
$imaginary = (is_null($imaginary)) ? 0.0 : Functions::flattenSingleValue($imaginary); $imaginary = ($imaginary === null) ? 0.0 : Functions::flattenSingleValue($imaginary);
$suffix = (is_null($suffix)) ? 'i' : Functions::flattenSingleValue($suffix); $suffix = ($suffix === null) ? 'i' : Functions::flattenSingleValue($suffix);
if (((is_numeric($realNumber)) && (is_numeric($imaginary))) && if (((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
(($suffix == 'i') || ($suffix == 'j') || ($suffix == '')) (($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))
@ -1943,7 +1947,7 @@ class Engineering
* *
* @param string $complexNumber the complex number for which you want the cosine * @param string $complexNumber the complex number for which you want the cosine
* *
* @return string|float * @return float|string
*/ */
public static function IMCOS($complexNumber) public static function IMCOS($complexNumber)
{ {
@ -1974,7 +1978,7 @@ class Engineering
* *
* @param string $complexNumber the complex number for which you want the sine * @param string $complexNumber the complex number for which you want the sine
* *
* @return string|float * @return float|string
*/ */
public static function IMSIN($complexNumber) public static function IMSIN($complexNumber)
{ {
@ -2444,7 +2448,7 @@ class Engineering
$upper = Functions::flattenSingleValue($upper); $upper = Functions::flattenSingleValue($upper);
if (is_numeric($lower)) { if (is_numeric($lower)) {
if (is_null($upper)) { if ($upper === null) {
return self::erfVal($lower); return self::erfVal($lower);
} }
if (is_numeric($upper)) { if (is_numeric($upper)) {
@ -2544,7 +2548,7 @@ class Engineering
{ {
$conversionGroups = []; $conversionGroups = [];
foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) { foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) {
if ((is_null($group)) || ($conversionGroup['Group'] == $group)) { if (($group === null) || ($conversionGroup['Group'] == $group)) {
$conversionGroups[$conversionGroup['Group']][] = $conversionUnit; $conversionGroups[$conversionGroup['Group']][] = $conversionUnit;
} }
} }
@ -2563,7 +2567,7 @@ class Engineering
{ {
$conversionGroups = []; $conversionGroups = [];
foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) { foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) {
if ((is_null($group)) || ($conversionGroup['Group'] == $group)) { if (($group === null) || ($conversionGroup['Group'] == $group)) {
$conversionGroups[$conversionGroup['Group']][] = [ $conversionGroups[$conversionGroup['Group']][] = [
'unit' => $conversionUnit, 'unit' => $conversionUnit,
'description' => $conversionGroup['Unit Name'], 'description' => $conversionGroup['Unit Name'],

View File

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

View File

@ -94,12 +94,15 @@ class Financial
case 2: case 2:
case 4: case 4:
$daysPerYear = 360; $daysPerYear = 360;
break; break;
case 3: case 3:
$daysPerYear = 365; $daysPerYear = 365;
break; break;
case 1: case 1:
$daysPerYear = (DateTime::isLeapYear($year)) ? 366 : 365; $daysPerYear = (DateTime::isLeapYear($year)) ? 366 : 365;
break; break;
default: default:
return Functions::NAN(); return Functions::NAN();
@ -163,9 +166,9 @@ class Financial
$firstinterest = Functions::flattenSingleValue($firstinterest); $firstinterest = Functions::flattenSingleValue($firstinterest);
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$rate = Functions::flattenSingleValue($rate); $rate = Functions::flattenSingleValue($rate);
$par = (is_null($par)) ? 1000 : Functions::flattenSingleValue($par); $par = ($par === null) ? 1000 : Functions::flattenSingleValue($par);
$frequency = (is_null($frequency)) ? 1 : Functions::flattenSingleValue($frequency); $frequency = ($frequency === null) ? 1 : Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : Functions::flattenSingleValue($basis); $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis);
// Validate // Validate
if ((is_numeric($rate)) && (is_numeric($par))) { if ((is_numeric($rate)) && (is_numeric($par))) {
@ -220,8 +223,8 @@ class Financial
$issue = Functions::flattenSingleValue($issue); $issue = Functions::flattenSingleValue($issue);
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$rate = Functions::flattenSingleValue($rate); $rate = Functions::flattenSingleValue($rate);
$par = (is_null($par)) ? 1000 : Functions::flattenSingleValue($par); $par = ($par === null) ? 1000 : Functions::flattenSingleValue($par);
$basis = (is_null($basis)) ? 0 : Functions::flattenSingleValue($basis); $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis);
// Validate // Validate
if ((is_numeric($rate)) && (is_numeric($par))) { if ((is_numeric($rate)) && (is_numeric($par))) {
@ -289,7 +292,7 @@ class Financial
$salvage = Functions::flattenSingleValue($salvage); $salvage = Functions::flattenSingleValue($salvage);
$period = floor(Functions::flattenSingleValue($period)); $period = floor(Functions::flattenSingleValue($period));
$rate = Functions::flattenSingleValue($rate); $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: // The depreciation coefficients are:
// Life of assets (1/rate) Depreciation coefficient // Life of assets (1/rate) Depreciation coefficient
@ -374,7 +377,7 @@ class Financial
$salvage = Functions::flattenSingleValue($salvage); $salvage = Functions::flattenSingleValue($salvage);
$period = Functions::flattenSingleValue($period); $period = Functions::flattenSingleValue($period);
$rate = Functions::flattenSingleValue($rate); $rate = Functions::flattenSingleValue($rate);
$basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis); $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
$fOneRate = $cost * $rate; $fOneRate = $cost * $rate;
$fCostDelta = $cost - $salvage; $fCostDelta = $cost - $salvage;
@ -442,7 +445,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency); $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))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -505,7 +508,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency); $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))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -585,7 +588,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency); $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))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -649,7 +652,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency); $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))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -710,7 +713,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency); $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))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -787,7 +790,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency); $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))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -1128,7 +1131,7 @@ class Financial
$fraction = (int) Functions::flattenSingleValue($fraction); $fraction = (int) Functions::flattenSingleValue($fraction);
// Validate parameters // Validate parameters
if (is_null($fractional_dollar) || $fraction < 0) { if ($fractional_dollar === null || $fraction < 0) {
return Functions::NAN(); return Functions::NAN();
} }
if ($fraction == 0) { if ($fraction == 0) {
@ -1166,7 +1169,7 @@ class Financial
$fraction = (int) Functions::flattenSingleValue($fraction); $fraction = (int) Functions::flattenSingleValue($fraction);
// Validate parameters // Validate parameters
if (is_null($decimal_dollar) || $fraction < 0) { if ($decimal_dollar === null || $fraction < 0) {
return Functions::NAN(); return Functions::NAN();
} }
if ($fraction == 0) { if ($fraction == 0) {
@ -1247,7 +1250,7 @@ class Financial
} }
// Calculate // 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; return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate;
} }
@ -1584,7 +1587,7 @@ class Financial
} }
// Calculate // Calculate
if (!is_null($rate) && $rate != 0) { if ($rate !== null && $rate != 0) {
if ($pmt == 0 && $pv == 0) { if ($pmt == 0 && $pv == 0) {
return Functions::NAN(); return Functions::NAN();
} }
@ -1653,7 +1656,7 @@ class Financial
} }
// Calculate // 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); 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); $yield = (float) Functions::flattenSingleValue($yield);
$redemption = (float) Functions::flattenSingleValue($redemption); $redemption = (float) Functions::flattenSingleValue($redemption);
$frequency = (int) Functions::flattenSingleValue($frequency); $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))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -1887,7 +1890,7 @@ class Financial
} }
// Calculate // 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); 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); $nper = (int) Functions::flattenSingleValue($nper);
$pmt = Functions::flattenSingleValue($pmt); $pmt = Functions::flattenSingleValue($pmt);
$pv = Functions::flattenSingleValue($pv); $pv = Functions::flattenSingleValue($pv);
$fv = (is_null($fv)) ? 0.0 : Functions::flattenSingleValue($fv); $fv = ($fv === null) ? 0.0 : Functions::flattenSingleValue($fv);
$type = (is_null($type)) ? 0 : (int) Functions::flattenSingleValue($type); $type = ($type === null) ? 0 : (int) Functions::flattenSingleValue($type);
$guess = (is_null($guess)) ? 0.1 : Functions::flattenSingleValue($guess); $guess = ($guess === null) ? 0.1 : Functions::flattenSingleValue($guess);
$rate = $guess; $rate = $guess;
if (abs($rate) < self::FINANCIAL_PRECISION) { if (abs($rate) < self::FINANCIAL_PRECISION) {

View File

@ -26,7 +26,7 @@ PARTLY BASED ON:
*/ */
class FormulaParser class FormulaParser
{ {
/* Character constants */ // Character constants
const QUOTE_DOUBLE = '"'; const QUOTE_DOUBLE = '"';
const QUOTE_SINGLE = '\''; const QUOTE_SINGLE = '\'';
const BRACKET_CLOSE = ']'; const BRACKET_CLOSE = ']';
@ -68,7 +68,7 @@ class FormulaParser
public function __construct($pFormula = '') public function __construct($pFormula = '')
{ {
// Check parameters // Check parameters
if (is_null($pFormula)) { if ($pFormula === null) {
throw new Exception('Invalid parameter passed: formula'); throw new Exception('Invalid parameter passed: formula');
} }
@ -102,6 +102,7 @@ class FormulaParser
if (isset($this->tokens[$pId])) { if (isset($this->tokens[$pId])) {
return $this->tokens[$pId]; return $this->tokens[$pId];
} }
throw new Exception("Token with id $pId does not exist."); throw new Exception("Token with id $pId does not exist.");
} }
@ -170,6 +171,7 @@ class FormulaParser
$value .= $this->formula[$index]; $value .= $this->formula[$index];
} }
++$index; ++$index;
continue; continue;
} }
@ -188,6 +190,7 @@ class FormulaParser
$value .= $this->formula[$index]; $value .= $this->formula[$index];
} }
++$index; ++$index;
continue; continue;
} }
@ -200,6 +203,7 @@ class FormulaParser
} }
$value .= $this->formula[$index]; $value .= $this->formula[$index];
++$index; ++$index;
continue; continue;
} }
@ -213,6 +217,7 @@ class FormulaParser
$tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND, FormulaToken::TOKEN_SUBTYPE_ERROR); $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND, FormulaToken::TOKEN_SUBTYPE_ERROR);
$value = ''; $value = '';
} }
continue; continue;
} }
@ -222,6 +227,7 @@ class FormulaParser
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula[$index]) != 0) { if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula[$index]) != 0) {
$value .= $this->formula[$index]; $value .= $this->formula[$index];
++$index; ++$index;
continue; continue;
} }
} }
@ -238,6 +244,7 @@ class FormulaParser
} }
$inString = true; $inString = true;
++$index; ++$index;
continue; continue;
} }
@ -249,6 +256,7 @@ class FormulaParser
} }
$inPath = true; $inPath = true;
++$index; ++$index;
continue; continue;
} }
@ -256,6 +264,7 @@ class FormulaParser
$inRange = true; $inRange = true;
$value .= self::BRACKET_OPEN; $value .= self::BRACKET_OPEN;
++$index; ++$index;
continue; continue;
} }
@ -268,6 +277,7 @@ class FormulaParser
$inError = true; $inError = true;
$value .= self::ERROR_START; $value .= self::ERROR_START;
++$index; ++$index;
continue; continue;
} }
@ -288,6 +298,7 @@ class FormulaParser
$stack[] = clone $tmp; $stack[] = clone $tmp;
++$index; ++$index;
continue; continue;
} }
@ -310,6 +321,7 @@ class FormulaParser
$stack[] = clone $tmp; $stack[] = clone $tmp;
++$index; ++$index;
continue; continue;
} }
@ -330,6 +342,7 @@ class FormulaParser
$tokens1[] = $tmp; $tokens1[] = $tmp;
++$index; ++$index;
continue; continue;
} }
@ -344,6 +357,7 @@ class FormulaParser
while (($this->formula[$index] == self::WHITESPACE) && ($index < $formulaLength)) { while (($this->formula[$index] == self::WHITESPACE) && ($index < $formulaLength)) {
++$index; ++$index;
} }
continue; continue;
} }
@ -356,6 +370,7 @@ class FormulaParser
} }
$tokens1[] = new FormulaToken(substr($this->formula, $index, 2), FormulaToken::TOKEN_TYPE_OPERATORINFIX, FormulaToken::TOKEN_SUBTYPE_LOGICAL); $tokens1[] = new FormulaToken(substr($this->formula, $index, 2), FormulaToken::TOKEN_TYPE_OPERATORINFIX, FormulaToken::TOKEN_SUBTYPE_LOGICAL);
$index += 2; $index += 2;
continue; continue;
} }
} }
@ -368,6 +383,7 @@ class FormulaParser
} }
$tokens1[] = new FormulaToken($this->formula[$index], FormulaToken::TOKEN_TYPE_OPERATORINFIX); $tokens1[] = new FormulaToken($this->formula[$index], FormulaToken::TOKEN_TYPE_OPERATORINFIX);
++$index; ++$index;
continue; continue;
} }
@ -379,6 +395,7 @@ class FormulaParser
} }
$tokens1[] = new FormulaToken($this->formula[$index], FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX); $tokens1[] = new FormulaToken($this->formula[$index], FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
++$index; ++$index;
continue; continue;
} }
@ -395,6 +412,7 @@ class FormulaParser
$stack[] = clone $tmp; $stack[] = clone $tmp;
} }
++$index; ++$index;
continue; continue;
} }
@ -416,6 +434,7 @@ class FormulaParser
$tokens1[] = new FormulaToken(',', FormulaToken::TOKEN_TYPE_ARGUMENT); $tokens1[] = new FormulaToken(',', FormulaToken::TOKEN_TYPE_ARGUMENT);
} }
++$index; ++$index;
continue; continue;
} }
@ -432,6 +451,7 @@ class FormulaParser
$tokens1[] = $tmp; $tokens1[] = $tmp;
++$index; ++$index;
continue; continue;
} }
@ -460,16 +480,17 @@ class FormulaParser
$nextToken = null; $nextToken = null;
} }
if (is_null($token)) { if ($token === null) {
continue; continue;
} }
if ($token->getTokenType() != FormulaToken::TOKEN_TYPE_WHITESPACE) { if ($token->getTokenType() != FormulaToken::TOKEN_TYPE_WHITESPACE) {
$tokens2[] = $token; $tokens2[] = $token;
continue; continue;
} }
if (is_null($previousToken)) { if ($previousToken === null) {
continue; continue;
} }
@ -481,7 +502,7 @@ class FormulaParser
continue; continue;
} }
if (is_null($nextToken)) { if ($nextToken === null) {
continue; continue;
} }
@ -514,7 +535,7 @@ class FormulaParser
$nextToken = null; $nextToken = null;
} }
if (is_null($token)) { if ($token === null) {
continue; continue;
} }
@ -533,6 +554,7 @@ class FormulaParser
} }
$this->tokens[] = $token; $this->tokens[] = $token;
continue; continue;
} }
@ -551,6 +573,7 @@ class FormulaParser
} }
$this->tokens[] = $token; $this->tokens[] = $token;
continue; continue;
} }
@ -565,6 +588,7 @@ class FormulaParser
} }
$this->tokens[] = $token; $this->tokens[] = $token;
continue; continue;
} }
@ -581,6 +605,7 @@ class FormulaParser
} }
$this->tokens[] = $token; $this->tokens[] = $token;
continue; continue;
} }

View File

@ -27,7 +27,7 @@ PARTLY BASED ON:
class FormulaToken class FormulaToken
{ {
/* Token types */ // Token types
const TOKEN_TYPE_NOOP = 'Noop'; const TOKEN_TYPE_NOOP = 'Noop';
const TOKEN_TYPE_OPERAND = 'Operand'; const TOKEN_TYPE_OPERAND = 'Operand';
const TOKEN_TYPE_FUNCTION = 'Function'; const TOKEN_TYPE_FUNCTION = 'Function';
@ -39,7 +39,7 @@ class FormulaToken
const TOKEN_TYPE_WHITESPACE = 'Whitespace'; const TOKEN_TYPE_WHITESPACE = 'Whitespace';
const TOKEN_TYPE_UNKNOWN = 'Unknown'; const TOKEN_TYPE_UNKNOWN = 'Unknown';
/* Token subtypes */ // Token subtypes
const TOKEN_SUBTYPE_NOTHING = 'Nothing'; const TOKEN_SUBTYPE_NOTHING = 'Nothing';
const TOKEN_SUBTYPE_START = 'Start'; const TOKEN_SUBTYPE_START = 'Start';
const TOKEN_SUBTYPE_STOP = 'Stop'; const TOKEN_SUBTYPE_STOP = 'Stop';

View File

@ -278,7 +278,7 @@ class Functions
return '=' . $condition; return '=' . $condition;
} }
preg_match('/([<>=]+)(.*)/', $condition, $matches); preg_match('/([<>=]+)(.*)/', $condition, $matches);
list(, $operator, $operand) = $matches; [, $operator, $operand] = $matches;
if (!is_numeric($operand)) { if (!is_numeric($operand)) {
$operand = str_replace('"', '""', $operand); $operand = str_replace('"', '""', $operand);
@ -319,11 +319,11 @@ class Functions
*/ */
public static function isBlank($value = null) public static function isBlank($value = null)
{ {
if (!is_null($value)) { if ($value !== null) {
$value = self::flattenSingleValue($value); $value = self::flattenSingleValue($value);
} }
return is_null($value); return $value === null;
} }
/** /**
@ -377,7 +377,7 @@ class Functions
* *
* @param mixed $value Value to check * @param mixed $value Value to check
* *
* @return string|bool * @return bool|string
*/ */
public static function isEven($value = null) public static function isEven($value = null)
{ {
@ -397,7 +397,7 @@ class Functions
* *
* @param mixed $value Value to check * @param mixed $value Value to check
* *
* @return string|bool * @return bool|string
*/ */
public static function isOdd($value = null) public static function isOdd($value = null)
{ {
@ -505,6 +505,7 @@ class Functions
if ((strlen($value) > 0) && ($value[0] == '#')) { if ((strlen($value) > 0) && ($value[0] == '#')) {
return $value; return $value;
} }
break; break;
} }

View File

@ -60,7 +60,7 @@ class Logical
* *
* @param mixed ...$args Data values * @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) public static function logicalAnd(...$args)
{ {
@ -117,7 +117,7 @@ class Logical
* *
* @param mixed $args Data values * @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) public static function logicalOr(...$args)
{ {
@ -227,9 +227,9 @@ class Logical
*/ */
public static function statementIf($condition = true, $returnIfTrue = 0, $returnIfFalse = false) public static function statementIf($condition = true, $returnIfTrue = 0, $returnIfFalse = false)
{ {
$condition = (is_null($condition)) ? true : (bool) Functions::flattenSingleValue($condition); $condition = ($condition === null) ? true : (bool) Functions::flattenSingleValue($condition);
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : Functions::flattenSingleValue($returnIfTrue); $returnIfTrue = ($returnIfTrue === null) ? 0 : Functions::flattenSingleValue($returnIfTrue);
$returnIfFalse = (is_null($returnIfFalse)) ? false : Functions::flattenSingleValue($returnIfFalse); $returnIfFalse = ($returnIfFalse === null) ? false : Functions::flattenSingleValue($returnIfFalse);
return ($condition) ? $returnIfTrue : $returnIfFalse; return ($condition) ? $returnIfTrue : $returnIfFalse;
} }
@ -249,8 +249,8 @@ class Logical
*/ */
public static function IFERROR($testValue = '', $errorpart = '') public static function IFERROR($testValue = '', $errorpart = '')
{ {
$testValue = (is_null($testValue)) ? '' : Functions::flattenSingleValue($testValue); $testValue = ($testValue === null) ? '' : Functions::flattenSingleValue($testValue);
$errorpart = (is_null($errorpart)) ? '' : Functions::flattenSingleValue($errorpart); $errorpart = ($errorpart === null) ? '' : Functions::flattenSingleValue($errorpart);
return self::statementIf(Functions::isError($testValue), $errorpart, $testValue); return self::statementIf(Functions::isError($testValue), $errorpart, $testValue);
} }

View File

@ -91,7 +91,7 @@ class LookupRef
*/ */
public static function COLUMN($cellAddress = null) public static function COLUMN($cellAddress = null)
{ {
if (is_null($cellAddress) || trim($cellAddress) === '') { if ($cellAddress === null || trim($cellAddress) === '') {
return 0; return 0;
} }
@ -103,10 +103,10 @@ class LookupRef
} }
} else { } else {
if (strpos($cellAddress, '!') !== false) { if (strpos($cellAddress, '!') !== false) {
list($sheet, $cellAddress) = explode('!', $cellAddress); [$sheet, $cellAddress] = explode('!', $cellAddress);
} }
if (strpos($cellAddress, ':') !== false) { if (strpos($cellAddress, ':') !== false) {
list($startAddress, $endAddress) = explode(':', $cellAddress); [$startAddress, $endAddress] = explode(':', $cellAddress);
$startAddress = preg_replace('/[^a-z]/i', '', $startAddress); $startAddress = preg_replace('/[^a-z]/i', '', $startAddress);
$endAddress = preg_replace('/[^a-z]/i', '', $endAddress); $endAddress = preg_replace('/[^a-z]/i', '', $endAddress);
$returnValue = []; $returnValue = [];
@ -137,7 +137,7 @@ class LookupRef
*/ */
public static function COLUMNS($cellAddress = null) public static function COLUMNS($cellAddress = null)
{ {
if (is_null($cellAddress) || $cellAddress === '') { if ($cellAddress === null || $cellAddress === '') {
return 1; return 1;
} elseif (!is_array($cellAddress)) { } elseif (!is_array($cellAddress)) {
return Functions::VALUE(); return Functions::VALUE();
@ -145,7 +145,7 @@ class LookupRef
reset($cellAddress); reset($cellAddress);
$isMatrix = (is_numeric(key($cellAddress))); $isMatrix = (is_numeric(key($cellAddress)));
list($columns, $rows) = Calculation::_getMatrixDimensions($cellAddress); [$columns, $rows] = Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) { if ($isMatrix) {
return $rows; return $rows;
@ -172,7 +172,7 @@ class LookupRef
*/ */
public static function ROW($cellAddress = null) public static function ROW($cellAddress = null)
{ {
if (is_null($cellAddress) || trim($cellAddress) === '') { if ($cellAddress === null || trim($cellAddress) === '') {
return 0; return 0;
} }
@ -184,10 +184,10 @@ class LookupRef
} }
} else { } else {
if (strpos($cellAddress, '!') !== false) { if (strpos($cellAddress, '!') !== false) {
list($sheet, $cellAddress) = explode('!', $cellAddress); [$sheet, $cellAddress] = explode('!', $cellAddress);
} }
if (strpos($cellAddress, ':') !== false) { if (strpos($cellAddress, ':') !== false) {
list($startAddress, $endAddress) = explode(':', $cellAddress); [$startAddress, $endAddress] = explode(':', $cellAddress);
$startAddress = preg_replace('/[^0-9]/', '', $startAddress); $startAddress = preg_replace('/[^0-9]/', '', $startAddress);
$endAddress = preg_replace('/[^0-9]/', '', $endAddress); $endAddress = preg_replace('/[^0-9]/', '', $endAddress);
$returnValue = []; $returnValue = [];
@ -197,7 +197,7 @@ class LookupRef
return $returnValue; return $returnValue;
} }
list($cellAddress) = explode(':', $cellAddress); [$cellAddress] = explode(':', $cellAddress);
return (int) preg_replace('/[^0-9]/', '', $cellAddress); return (int) preg_replace('/[^0-9]/', '', $cellAddress);
} }
@ -218,7 +218,7 @@ class LookupRef
*/ */
public static function ROWS($cellAddress = null) public static function ROWS($cellAddress = null)
{ {
if (is_null($cellAddress) || $cellAddress === '') { if ($cellAddress === null || $cellAddress === '') {
return 1; return 1;
} elseif (!is_array($cellAddress)) { } elseif (!is_array($cellAddress)) {
return Functions::VALUE(); return Functions::VALUE();
@ -226,7 +226,7 @@ class LookupRef
reset($cellAddress); reset($cellAddress);
$isMatrix = (is_numeric(key($cellAddress))); $isMatrix = (is_numeric(key($cellAddress)));
list($columns, $rows) = Calculation::_getMatrixDimensions($cellAddress); [$columns, $rows] = Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) { if ($isMatrix) {
return $columns; return $columns;
@ -251,8 +251,8 @@ class LookupRef
*/ */
public static function HYPERLINK($linkURL = '', $displayName = null, Cell $pCell = null) public static function HYPERLINK($linkURL = '', $displayName = null, Cell $pCell = null)
{ {
$linkURL = (is_null($linkURL)) ? '' : Functions::flattenSingleValue($linkURL); $linkURL = ($linkURL === null) ? '' : Functions::flattenSingleValue($linkURL);
$displayName = (is_null($displayName)) ? '' : Functions::flattenSingleValue($displayName); $displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName);
if ((!is_object($pCell)) || (trim($linkURL) == '')) { if ((!is_object($pCell)) || (trim($linkURL) == '')) {
return Functions::REF(); return Functions::REF();
@ -289,24 +289,24 @@ class LookupRef
public static function INDIRECT($cellAddress = null, Cell $pCell = null) public static function INDIRECT($cellAddress = null, Cell $pCell = null)
{ {
$cellAddress = Functions::flattenSingleValue($cellAddress); $cellAddress = Functions::flattenSingleValue($cellAddress);
if (is_null($cellAddress) || $cellAddress === '') { if ($cellAddress === null || $cellAddress === '') {
return Functions::REF(); return Functions::REF();
} }
$cellAddress1 = $cellAddress; $cellAddress1 = $cellAddress;
$cellAddress2 = null; $cellAddress2 = null;
if (strpos($cellAddress, ':') !== false) { if (strpos($cellAddress, ':') !== false) {
list($cellAddress1, $cellAddress2) = explode(':', $cellAddress); [$cellAddress1, $cellAddress2] = explode(':', $cellAddress);
} }
if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) || 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)) { if (!preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $cellAddress1, $matches)) {
return Functions::REF(); return Functions::REF();
} }
if (strpos($cellAddress, '!') !== false) { if (strpos($cellAddress, '!') !== false) {
list($sheetName, $cellAddress) = explode('!', $cellAddress); [$sheetName, $cellAddress] = explode('!', $cellAddress);
$sheetName = trim($sheetName, "'"); $sheetName = trim($sheetName, "'");
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName); $pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
} else { } else {
@ -317,7 +317,7 @@ class LookupRef
} }
if (strpos($cellAddress, '!') !== false) { if (strpos($cellAddress, '!') !== false) {
list($sheetName, $cellAddress) = explode('!', $cellAddress); [$sheetName, $cellAddress] = explode('!', $cellAddress);
$sheetName = trim($sheetName, "'"); $sheetName = trim($sheetName, "'");
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName); $pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
} else { } else {
@ -375,16 +375,16 @@ class LookupRef
$sheetName = null; $sheetName = null;
if (strpos($cellAddress, '!')) { if (strpos($cellAddress, '!')) {
list($sheetName, $cellAddress) = explode('!', $cellAddress); [$sheetName, $cellAddress] = explode('!', $cellAddress);
$sheetName = trim($sheetName, "'"); $sheetName = trim($sheetName, "'");
} }
if (strpos($cellAddress, ':')) { if (strpos($cellAddress, ':')) {
list($startCell, $endCell) = explode(':', $cellAddress); [$startCell, $endCell] = explode(':', $cellAddress);
} else { } else {
$startCell = $endCell = $cellAddress; $startCell = $endCell = $cellAddress;
} }
list($startCellColumn, $startCellRow) = Cell::coordinateFromString($startCell); [$startCellColumn, $startCellRow] = Cell::coordinateFromString($startCell);
list($endCellColumn, $endCellRow) = Cell::coordinateFromString($endCell); [$endCellColumn, $endCellRow] = Cell::coordinateFromString($endCell);
$startCellRow += $rows; $startCellRow += $rows;
$startCellColumn = Cell::columnIndexFromString($startCellColumn) - 1; $startCellColumn = Cell::columnIndexFromString($startCellColumn) - 1;
@ -488,7 +488,7 @@ class LookupRef
{ {
$lookupArray = Functions::flattenArray($lookupArray); $lookupArray = Functions::flattenArray($lookupArray);
$lookupValue = Functions::flattenSingleValue($lookupValue); $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 // MATCH is not case sensitive
$lookupValue = strtolower($lookupValue); $lookupValue = strtolower($lookupValue);
@ -513,7 +513,7 @@ class LookupRef
foreach ($lookupArray as $i => $lookupArrayValue) { foreach ($lookupArray as $i => $lookupArrayValue) {
// check the type of the value // check the type of the value
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) && if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
(!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue)) (!is_bool($lookupArrayValue)) && ($lookupArrayValue !== null)
) { ) {
return Functions::NA(); return Functions::NA();
} }
@ -521,7 +521,7 @@ class LookupRef
if (is_string($lookupArrayValue)) { if (is_string($lookupArrayValue)) {
$lookupArray[$i] = strtolower($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); $lookupArray = array_slice($lookupArray, 0, $i - 1);
} }
} }
@ -850,7 +850,7 @@ class LookupRef
$lookupColumns = count($lookup_vector[array_shift($l)]); $lookupColumns = count($lookup_vector[array_shift($l)]);
} }
if (is_null($result_vector)) { if ($result_vector === null) {
$result_vector = $lookup_vector; $result_vector = $lookup_vector;
} }
$resultRows = count($result_vector); $resultRows = count($result_vector);

View File

@ -108,7 +108,7 @@ class MathTrig
$number = Functions::flattenSingleValue($number); $number = Functions::flattenSingleValue($number);
$significance = Functions::flattenSingleValue($significance); $significance = Functions::flattenSingleValue($significance);
if ((is_null($significance)) && if (($significance === null) &&
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) { (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) {
$significance = $number / abs($number); $significance = $number / abs($number);
} }
@ -182,7 +182,7 @@ class MathTrig
{ {
$number = Functions::flattenSingleValue($number); $number = Functions::flattenSingleValue($number);
if (is_null($number)) { if ($number === null) {
return 0; return 0;
} elseif (is_bool($number)) { } elseif (is_bool($number)) {
$number = (int) $number; $number = (int) $number;
@ -293,7 +293,7 @@ class MathTrig
$number = Functions::flattenSingleValue($number); $number = Functions::flattenSingleValue($number);
$significance = Functions::flattenSingleValue($significance); $significance = Functions::flattenSingleValue($significance);
if ((is_null($significance)) && if (($significance === null) &&
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) { (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) {
$significance = $number / abs($number); $significance = $number / abs($number);
} }
@ -409,7 +409,7 @@ class MathTrig
{ {
$number = Functions::flattenSingleValue($number); $number = Functions::flattenSingleValue($number);
if (is_null($number)) { if ($number === null) {
return 0; return 0;
} elseif (is_bool($number)) { } elseif (is_bool($number)) {
return (int) $number; return (int) $number;
@ -493,7 +493,7 @@ class MathTrig
public static function logBase($number = null, $base = 10) public static function logBase($number = null, $base = 10)
{ {
$number = Functions::flattenSingleValue($number); $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))) { if ((!is_numeric($base)) || (!is_numeric($number))) {
return Functions::VALUE(); return Functions::VALUE();
@ -778,7 +778,7 @@ class MathTrig
{ {
$number = Functions::flattenSingleValue($number); $number = Functions::flattenSingleValue($number);
if (is_null($number)) { if ($number === null) {
return 1; return 1;
} elseif (is_bool($number)) { } elseif (is_bool($number)) {
return 1; return 1;
@ -850,7 +850,7 @@ class MathTrig
foreach (Functions::flattenArray($args) as $arg) { foreach (Functions::flattenArray($args) as $arg) {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = $arg; $returnValue = $arg;
} else { } else {
$returnValue *= $arg; $returnValue *= $arg;
@ -859,7 +859,7 @@ class MathTrig
} }
// Return // Return
if (is_null($returnValue)) { if ($returnValue === null) {
return 0; return 0;
} }
@ -890,7 +890,7 @@ class MathTrig
foreach (Functions::flattenArray($args) as $arg) { foreach (Functions::flattenArray($args) as $arg) {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = ($arg == 0) ? 0 : $arg; $returnValue = ($arg == 0) ? 0 : $arg;
} else { } else {
if (($returnValue == 0) || ($arg == 0)) { if (($returnValue == 0) || ($arg == 0)) {
@ -929,7 +929,7 @@ class MathTrig
public static function ROMAN($aValue, $style = 0) public static function ROMAN($aValue, $style = 0)
{ {
$aValue = Functions::flattenSingleValue($aValue); $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)) { if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) {
return Functions::VALUE(); return Functions::VALUE();
} }
@ -1110,7 +1110,7 @@ class MathTrig
return array_filter( return array_filter(
$args, $args,
function ($index) use ($cellReference) { function ($index) use ($cellReference) {
list(, $row, $column) = explode('.', $index); [, $row, $column] = explode('.', $index);
return $cellReference->getWorksheet()->getRowDimension($row)->getVisible() && return $cellReference->getWorksheet()->getRowDimension($row)->getVisible() &&
$cellReference->getWorksheet()->getColumnDimension($column)->getVisible(); $cellReference->getWorksheet()->getColumnDimension($column)->getVisible();

View File

@ -26,12 +26,12 @@ class Statistical
$array1 = Functions::flattenArray($array1); $array1 = Functions::flattenArray($array1);
$array2 = Functions::flattenArray($array2); $array2 = Functions::flattenArray($array2);
foreach ($array1 as $key => $value) { 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]); unset($array1[$key], $array2[$key]);
} }
} }
foreach ($array2 as $key => $value) { 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]); unset($array1[$key], $array2[$key]);
} }
} }
@ -719,7 +719,7 @@ class Statistical
} }
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = abs($arg - $aMean); $returnValue = abs($arg - $aMean);
} else { } else {
$returnValue += abs($arg - $aMean); $returnValue += abs($arg - $aMean);
@ -765,7 +765,7 @@ class Statistical
} }
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = $arg; $returnValue = $arg;
} else { } else {
$returnValue += $arg; $returnValue += $arg;
@ -812,7 +812,7 @@ class Statistical
} elseif (is_string($arg)) { } elseif (is_string($arg)) {
$arg = 0; $arg = 0;
} }
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = $arg; $returnValue = $arg;
} else { } else {
$returnValue += $arg; $returnValue += $arg;
@ -863,7 +863,7 @@ class Statistical
} }
$testCondition = '=' . $arg . $condition; $testCondition = '=' . $arg . $condition;
if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) { if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
if ((is_null($returnValue)) || ($arg > $returnValue)) { if (($returnValue === null) || ($arg > $returnValue)) {
$returnValue += $arg; $returnValue += $arg;
++$aCount; ++$aCount;
} }
@ -1155,7 +1155,7 @@ class Statistical
*/ */
public static function CORREL($yValues, $xValues = null) 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(); return Functions::VALUE();
} }
if (!self::checkTrendArrays($yValues, $xValues)) { if (!self::checkTrendArrays($yValues, $xValues)) {
@ -1261,7 +1261,7 @@ class Statistical
$aArgs = Functions::flattenArray($args); $aArgs = Functions::flattenArray($args);
foreach ($aArgs as $arg) { foreach ($aArgs as $arg) {
// Is it a blank cell? // Is it a blank cell?
if ((is_null($arg)) || ((is_string($arg)) && ($arg == ''))) { if (($arg === null) || ((is_string($arg)) && ($arg == ''))) {
++$returnValue; ++$returnValue;
} }
} }
@ -1491,7 +1491,7 @@ class Statistical
$arg = (int) $arg; $arg = (int) $arg;
} }
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2); $returnValue = pow(($arg - $aMean), 2);
} else { } else {
$returnValue += pow(($arg - $aMean), 2); $returnValue += pow(($arg - $aMean), 2);
@ -1501,7 +1501,7 @@ class Statistical
} }
// Return // Return
if (is_null($returnValue)) { if ($returnValue === null) {
return Functions::NAN(); return Functions::NAN();
} }
@ -1803,7 +1803,7 @@ class Statistical
$yValues = Functions::flattenArray($yValues); $yValues = Functions::flattenArray($yValues);
$xValues = Functions::flattenArray($xValues); $xValues = Functions::flattenArray($xValues);
$newValues = Functions::flattenArray($newValues); $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); $bestFitExponential = Trend::calculate(Trend::TREND_EXPONENTIAL, $yValues, $xValues, $const);
if (empty($newValues)) { if (empty($newValues)) {
@ -1850,7 +1850,7 @@ class Statistical
if ($arg <= 0) { if ($arg <= 0) {
return Functions::NAN(); return Functions::NAN();
} }
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = (1 / $arg); $returnValue = (1 / $arg);
} else { } else {
$returnValue += (1 / $arg); $returnValue += (1 / $arg);
@ -2042,9 +2042,9 @@ class Statistical
*/ */
public static function LINEST($yValues, $xValues = null, $const = true, $stats = false) public static function LINEST($yValues, $xValues = null, $const = true, $stats = false)
{ {
$const = (is_null($const)) ? true : (bool) Functions::flattenSingleValue($const); $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const);
$stats = (is_null($stats)) ? false : (bool) Functions::flattenSingleValue($stats); $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats);
if (is_null($xValues)) { if ($xValues === null) {
$xValues = range(1, count(Functions::flattenArray($yValues))); $xValues = range(1, count(Functions::flattenArray($yValues)));
} }
@ -2105,9 +2105,9 @@ class Statistical
*/ */
public static function LOGEST($yValues, $xValues = null, $const = true, $stats = false) public static function LOGEST($yValues, $xValues = null, $const = true, $stats = false)
{ {
$const = (is_null($const)) ? true : (bool) Functions::flattenSingleValue($const); $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const);
$stats = (is_null($stats)) ? false : (bool) Functions::flattenSingleValue($stats); $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats);
if (is_null($xValues)) { if ($xValues === null) {
$xValues = range(1, count(Functions::flattenArray($yValues))); $xValues = range(1, count(Functions::flattenArray($yValues)));
} }
@ -2240,13 +2240,13 @@ class Statistical
foreach ($aArgs as $arg) { foreach ($aArgs as $arg) {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if ((is_null($returnValue)) || ($arg > $returnValue)) { if (($returnValue === null) || ($arg > $returnValue)) {
$returnValue = $arg; $returnValue = $arg;
} }
} }
} }
if (is_null($returnValue)) { if ($returnValue === null) {
return 0; return 0;
} }
@ -2281,13 +2281,13 @@ class Statistical
} elseif (is_string($arg)) { } elseif (is_string($arg)) {
$arg = 0; $arg = 0;
} }
if ((is_null($returnValue)) || ($arg > $returnValue)) { if (($returnValue === null) || ($arg > $returnValue)) {
$returnValue = $arg; $returnValue = $arg;
} }
} }
} }
if (is_null($returnValue)) { if ($returnValue === null) {
return 0; return 0;
} }
@ -2327,7 +2327,7 @@ class Statistical
} }
$testCondition = '=' . $arg . $condition; $testCondition = '=' . $arg . $condition;
if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) { if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
if ((is_null($returnValue)) || ($arg > $returnValue)) { if (($returnValue === null) || ($arg > $returnValue)) {
$returnValue = $arg; $returnValue = $arg;
} }
} }
@ -2403,13 +2403,13 @@ class Statistical
foreach ($aArgs as $arg) { foreach ($aArgs as $arg) {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if ((is_null($returnValue)) || ($arg < $returnValue)) { if (($returnValue === null) || ($arg < $returnValue)) {
$returnValue = $arg; $returnValue = $arg;
} }
} }
} }
if (is_null($returnValue)) { if ($returnValue === null) {
return 0; return 0;
} }
@ -2444,13 +2444,13 @@ class Statistical
} elseif (is_string($arg)) { } elseif (is_string($arg)) {
$arg = 0; $arg = 0;
} }
if ((is_null($returnValue)) || ($arg < $returnValue)) { if (($returnValue === null) || ($arg < $returnValue)) {
$returnValue = $arg; $returnValue = $arg;
} }
} }
} }
if (is_null($returnValue)) { if ($returnValue === null) {
return 0; return 0;
} }
@ -2490,7 +2490,7 @@ class Statistical
} }
$testCondition = '=' . $arg . $condition; $testCondition = '=' . $arg . $condition;
if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) { if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
if ((is_null($returnValue)) || ($arg < $returnValue)) { if (($returnValue === null) || ($arg < $returnValue)) {
$returnValue = $arg; $returnValue = $arg;
} }
} }
@ -2512,6 +2512,7 @@ class Statistical
if ((string) $value['value'] == (string) $datum) { if ((string) $value['value'] == (string) $datum) {
++$frequencyArray[$key]['frequency']; ++$frequencyArray[$key]['frequency'];
$found = true; $found = true;
break; break;
} }
} }
@ -2780,7 +2781,7 @@ class Statistical
{ {
$valueSet = Functions::flattenArray($valueSet); $valueSet = Functions::flattenArray($valueSet);
$value = Functions::flattenSingleValue($value); $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) { foreach ($valueSet as $key => $valueEntry) {
if (!is_numeric($valueEntry)) { if (!is_numeric($valueEntry)) {
@ -2934,7 +2935,7 @@ class Statistical
{ {
$value = Functions::flattenSingleValue($value); $value = Functions::flattenSingleValue($value);
$valueSet = Functions::flattenArray($valueSet); $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) { foreach ($valueSet as $key => $valueEntry) {
if (!is_numeric($valueEntry)) { if (!is_numeric($valueEntry)) {
@ -3151,7 +3152,7 @@ class Statistical
$returnValue = null; $returnValue = null;
$aMean = self::AVERAGE($aArgs); $aMean = self::AVERAGE($aArgs);
if (!is_null($aMean)) { if ($aMean !== null) {
$aCount = -1; $aCount = -1;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) && if ((is_bool($arg)) &&
@ -3160,7 +3161,7 @@ class Statistical
} }
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2); $returnValue = pow(($arg - $aMean), 2);
} else { } else {
$returnValue += pow(($arg - $aMean), 2); $returnValue += pow(($arg - $aMean), 2);
@ -3199,7 +3200,7 @@ class Statistical
$returnValue = null; $returnValue = null;
$aMean = self::AVERAGEA($aArgs); $aMean = self::AVERAGEA($aArgs);
if (!is_null($aMean)) { if ($aMean !== null) {
$aCount = -1; $aCount = -1;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) && if ((is_bool($arg)) &&
@ -3212,7 +3213,7 @@ class Statistical
} elseif (is_string($arg)) { } elseif (is_string($arg)) {
$arg = 0; $arg = 0;
} }
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2); $returnValue = pow(($arg - $aMean), 2);
} else { } else {
$returnValue += pow(($arg - $aMean), 2); $returnValue += pow(($arg - $aMean), 2);
@ -3251,7 +3252,7 @@ class Statistical
$returnValue = null; $returnValue = null;
$aMean = self::AVERAGE($aArgs); $aMean = self::AVERAGE($aArgs);
if (!is_null($aMean)) { if ($aMean !== null) {
$aCount = 0; $aCount = 0;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) && if ((is_bool($arg)) &&
@ -3260,7 +3261,7 @@ class Statistical
} }
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2); $returnValue = pow(($arg - $aMean), 2);
} else { } else {
$returnValue += pow(($arg - $aMean), 2); $returnValue += pow(($arg - $aMean), 2);
@ -3298,7 +3299,7 @@ class Statistical
$returnValue = null; $returnValue = null;
$aMean = self::AVERAGEA($aArgs); $aMean = self::AVERAGEA($aArgs);
if (!is_null($aMean)) { if ($aMean !== null) {
$aCount = 0; $aCount = 0;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) && if ((is_bool($arg)) &&
@ -3311,7 +3312,7 @@ class Statistical
} elseif (is_string($arg)) { } elseif (is_string($arg)) {
$arg = 0; $arg = 0;
} }
if (is_null($returnValue)) { if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2); $returnValue = pow(($arg - $aMean), 2);
} else { } else {
$returnValue += pow(($arg - $aMean), 2); $returnValue += pow(($arg - $aMean), 2);
@ -3504,7 +3505,7 @@ class Statistical
$yValues = Functions::flattenArray($yValues); $yValues = Functions::flattenArray($yValues);
$xValues = Functions::flattenArray($xValues); $xValues = Functions::flattenArray($xValues);
$newValues = Functions::flattenArray($newValues); $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); $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues, $const);
if (empty($newValues)) { if (empty($newValues)) {
@ -3815,7 +3816,7 @@ class Statistical
$m0 = Functions::flattenSingleValue($m0); $m0 = Functions::flattenSingleValue($m0);
$sigma = Functions::flattenSingleValue($sigma); $sigma = Functions::flattenSingleValue($sigma);
if (is_null($sigma)) { if ($sigma === null) {
$sigma = self::STDEV($dataSet); $sigma = self::STDEV($dataSet);
} }
$n = count($dataSet); $n = count($dataSet);

View File

@ -155,7 +155,7 @@ class TextData
public static function DOLLAR($value = 0, $decimals = 2) public static function DOLLAR($value = 0, $decimals = 2)
{ {
$value = Functions::flattenSingleValue($value); $value = Functions::flattenSingleValue($value);
$decimals = is_null($decimals) ? 0 : Functions::flattenSingleValue($decimals); $decimals = $decimals === null ? 0 : Functions::flattenSingleValue($decimals);
// Validate parameters // Validate parameters
if (!is_numeric($value) || !is_numeric($decimals)) { if (!is_numeric($value) || !is_numeric($decimals)) {
@ -500,7 +500,7 @@ class TextData
* *
* @param mixed $testValue Value to check * @param mixed $testValue Value to check
* *
* @return string|null * @return null|string
*/ */
public static function RETURNSTRING($testValue = '') public static function RETURNSTRING($testValue = '')
{ {

View File

@ -205,6 +205,7 @@ class Cell
switch ($pDataType) { switch ($pDataType) {
case Cell\DataType::TYPE_NULL: case Cell\DataType::TYPE_NULL:
$this->value = $pValue; $this->value = $pValue;
break; break;
case Cell\DataType::TYPE_STRING2: case Cell\DataType::TYPE_STRING2:
$pDataType = Cell\DataType::TYPE_STRING; $pDataType = Cell\DataType::TYPE_STRING;
@ -214,18 +215,23 @@ class Cell
case Cell\DataType::TYPE_INLINE: case Cell\DataType::TYPE_INLINE:
// Rich text // Rich text
$this->value = Cell\DataType::checkString($pValue); $this->value = Cell\DataType::checkString($pValue);
break; break;
case Cell\DataType::TYPE_NUMERIC: case Cell\DataType::TYPE_NUMERIC:
$this->value = (float) $pValue; $this->value = (float) $pValue;
break; break;
case Cell\DataType::TYPE_FORMULA: case Cell\DataType::TYPE_FORMULA:
$this->value = (string) $pValue; $this->value = (string) $pValue;
break; break;
case Cell\DataType::TYPE_BOOL: case Cell\DataType::TYPE_BOOL:
$this->value = (bool) $pValue; $this->value = (bool) $pValue;
break; break;
case Cell\DataType::TYPE_ERROR: case Cell\DataType::TYPE_ERROR:
$this->value = Cell\DataType::checkErrorCode($pValue); $this->value = Cell\DataType::checkErrorCode($pValue);
break; break;
default: default:
throw new Exception('Invalid datatype: ' . $pDataType); throw new Exception('Invalid datatype: ' . $pDataType);
@ -265,6 +271,7 @@ class Cell
return $this->calculatedValue; // Fallback for calculations referencing external files. return $this->calculatedValue; // Fallback for calculations referencing external files.
} }
$result = '#N/A'; $result = '#N/A';
throw new Calculation\Exception( throw new Calculation\Exception(
$this->getWorksheet()->getTitle() . '!' . $this->getCoordinate() . ' -> ' . $ex->getMessage() $this->getWorksheet()->getTitle() . '!' . $this->getCoordinate() . ' -> ' . $ex->getMessage()
); );
@ -493,7 +500,7 @@ class Cell
{ {
if ($mergeRange = $this->getMergeRange()) { if ($mergeRange = $this->getMergeRange()) {
$mergeRange = self::splitRange($mergeRange); $mergeRange = self::splitRange($mergeRange);
list($startCell) = $mergeRange[0]; [$startCell] = $mergeRange[0];
if ($this->getCoordinate() === $startCell) { if ($this->getCoordinate() === $startCell) {
return true; return true;
} }
@ -551,7 +558,7 @@ class Cell
*/ */
public function isInRange($pRange) public function isInRange($pRange)
{ {
list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange); [$rangeStart, $rangeEnd] = self::rangeBoundaries($pRange);
// Translate properties // Translate properties
$myColumn = self::columnIndexFromString($this->getColumn()); $myColumn = self::columnIndexFromString($this->getColumn());
@ -601,7 +608,7 @@ class Cell
$worksheet = ''; $worksheet = '';
$cellAddress = explode('!', $pCoordinateString); $cellAddress = explode('!', $pCoordinateString);
if (count($cellAddress) > 1) { if (count($cellAddress) > 1) {
list($worksheet, $pCoordinateString) = $cellAddress; [$worksheet, $pCoordinateString] = $cellAddress;
} }
if ($worksheet > '') { if ($worksheet > '') {
$worksheet .= '!'; $worksheet .= '!';
@ -636,14 +643,14 @@ class Cell
$worksheet = ''; $worksheet = '';
$cellAddress = explode('!', $pCoordinateString); $cellAddress = explode('!', $pCoordinateString);
if (count($cellAddress) > 1) { if (count($cellAddress) > 1) {
list($worksheet, $pCoordinateString) = $cellAddress; [$worksheet, $pCoordinateString] = $cellAddress;
} }
if ($worksheet > '') { if ($worksheet > '') {
$worksheet .= '!'; $worksheet .= '!';
} }
// Create absolute coordinate // Create absolute coordinate
list($column, $row) = self::coordinateFromString($pCoordinateString); [$column, $row] = self::coordinateFromString($pCoordinateString);
$column = ltrim($column, '$'); $column = ltrim($column, '$');
$row = ltrim($row, '$'); $row = ltrim($row, '$');
@ -727,7 +734,7 @@ class Cell
if (strpos($pRange, ':') === false) { if (strpos($pRange, ':') === false) {
$rangeA = $rangeB = $pRange; $rangeA = $rangeB = $pRange;
} else { } else {
list($rangeA, $rangeB) = explode(':', $pRange); [$rangeA, $rangeB] = explode(':', $pRange);
} }
// Calculate range outer borders // Calculate range outer borders
@ -751,7 +758,7 @@ class Cell
public static function rangeDimension($pRange) public static function rangeDimension($pRange)
{ {
// Calculate range outer borders // 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)]; return [($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1)];
} }
@ -778,7 +785,7 @@ class Cell
if (strpos($pRange, ':') === false) { if (strpos($pRange, ':') === false) {
$rangeA = $rangeB = $pRange; $rangeA = $rangeB = $pRange;
} else { } else {
list($rangeA, $rangeB) = explode(':', $pRange); [$rangeA, $rangeB] = explode(':', $pRange);
} }
return [self::coordinateFromString($rangeA), self::coordinateFromString($rangeB)]; return [self::coordinateFromString($rangeA), self::coordinateFromString($rangeB)];
@ -828,6 +835,7 @@ class Cell
return $_indexCache[$pString]; return $_indexCache[$pString];
} }
} }
throw new Exception('Column string index can not be ' . ((isset($pString[0])) ? 'longer than 3 characters' : 'empty')); 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? // Single cell?
if (strpos($cellBlock, ':') === false && strpos($cellBlock, ',') === false) { if (strpos($cellBlock, ':') === false && strpos($cellBlock, ',') === false) {
$returnValue[] = $cellBlock; $returnValue[] = $cellBlock;
continue; continue;
} }
@ -883,11 +892,12 @@ class Cell
// Single cell? // Single cell?
if (!isset($range[1])) { if (!isset($range[1])) {
$returnValue[] = $range[0]; $returnValue[] = $range[0];
continue; continue;
} }
// Range... // Range...
list($rangeStart, $rangeEnd) = $range; [$rangeStart, $rangeEnd] = $range;
sscanf($rangeStart, '%[A-Z]%d', $startCol, $startRow); sscanf($rangeStart, '%[A-Z]%d', $startCol, $startRow);
sscanf($rangeEnd, '%[A-Z]%d', $endCol, $endRow); sscanf($rangeEnd, '%[A-Z]%d', $endCol, $endRow);
++$endCol; ++$endCol;
@ -942,7 +952,7 @@ class Cell
$hashedValues = []; $hashedValues = [];
foreach ($pCoordCollection as $coord => $value) { foreach ($pCoordCollection as $coord => $value) {
list($column, $row) = self::coordinateFromString($coord); [$column, $row] = self::coordinateFromString($coord);
$row = (int) (ltrim($row, '$')); $row = (int) (ltrim($row, '$'));
$hashCode = $column . '-' . (is_object($value) ? $value->getHashCode() : $value); $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' // 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)) { if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
// Convert value to number // Convert value to number
list($h, $m) = explode(':', $value); [$h, $m] = explode(':', $value);
$days = $h / 24 + $m / 1440; $days = $h / 24 + $m / 1440;
$cell->setValueExplicit($days, DataType::TYPE_NUMERIC); $cell->setValueExplicit($days, DataType::TYPE_NUMERIC);
// Set style // Set style
@ -130,7 +130,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
// Check for time with seconds '9:45:59', '09:45:59' // 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)) { if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) {
// Convert value to number // Convert value to number
list($h, $m, $s) = explode(':', $value); [$h, $m, $s] = explode(':', $value);
$days = $h / 24 + $m / 1440 + $s / 86400; $days = $h / 24 + $m / 1440 + $s / 86400;
// Convert value to number // Convert value to number
$cell->setValueExplicit($days, DataType::TYPE_NUMERIC); $cell->setValueExplicit($days, DataType::TYPE_NUMERIC);

View File

@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
class DataType class DataType
{ {
/* Data types */ // Data types
const TYPE_STRING2 = 'str'; const TYPE_STRING2 = 'str';
const TYPE_STRING = 's'; const TYPE_STRING = 's';
const TYPE_FORMULA = 'f'; const TYPE_FORMULA = 'f';

View File

@ -4,7 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Cell;
class DataValidation class DataValidation
{ {
/* Data validation types */ // Data validation types
const TYPE_NONE = 'none'; const TYPE_NONE = 'none';
const TYPE_CUSTOM = 'custom'; const TYPE_CUSTOM = 'custom';
const TYPE_DATE = 'date'; const TYPE_DATE = 'date';
@ -14,12 +14,12 @@ class DataValidation
const TYPE_TIME = 'time'; const TYPE_TIME = 'time';
const TYPE_WHOLE = 'whole'; const TYPE_WHOLE = 'whole';
/* Data validation error styles */ // Data validation error styles
const STYLE_STOP = 'stop'; const STYLE_STOP = 'stop';
const STYLE_WARNING = 'warning'; const STYLE_WARNING = 'warning';
const STYLE_INFORMATION = 'information'; const STYLE_INFORMATION = 'information';
/* Data validation operators */ // Data validation operators
const OPERATOR_BETWEEN = 'between'; const OPERATOR_BETWEEN = 'between';
const OPERATOR_EQUAL = 'equal'; const OPERATOR_EQUAL = 'equal';
const OPERATOR_GREATERTHAN = 'greaterThan'; const OPERATOR_GREATERTHAN = 'greaterThan';

View File

@ -416,10 +416,10 @@ class Chart
public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null) public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null)
{ {
$this->topLeftCellRef = $cell; $this->topLeftCellRef = $cell;
if (!is_null($xOffset)) { if ($xOffset !== null) {
$this->setTopLeftXOffset($xOffset); $this->setTopLeftXOffset($xOffset);
} }
if (!is_null($yOffset)) { if ($yOffset !== null) {
$this->setTopLeftYOffset($yOffset); $this->setTopLeftYOffset($yOffset);
} }
@ -474,11 +474,11 @@ class Chart
*/ */
public function setTopLeftOffset($xOffset, $yOffset) public function setTopLeftOffset($xOffset, $yOffset)
{ {
if (!is_null($xOffset)) { if ($xOffset !== null) {
$this->setTopLeftXOffset($xOffset); $this->setTopLeftXOffset($xOffset);
} }
if (!is_null($yOffset)) { if ($yOffset !== null) {
$this->setTopLeftYOffset($yOffset); $this->setTopLeftYOffset($yOffset);
} }
@ -534,10 +534,10 @@ class Chart
public function setBottomRightPosition($cell, $xOffset = null, $yOffset = null) public function setBottomRightPosition($cell, $xOffset = null, $yOffset = null)
{ {
$this->bottomRightCellRef = $cell; $this->bottomRightCellRef = $cell;
if (!is_null($xOffset)) { if ($xOffset !== null) {
$this->setBottomRightXOffset($xOffset); $this->setBottomRightXOffset($xOffset);
} }
if (!is_null($yOffset)) { if ($yOffset !== null) {
$this->setBottomRightYOffset($yOffset); $this->setBottomRightYOffset($yOffset);
} }
@ -585,11 +585,11 @@ class Chart
*/ */
public function setBottomRightOffset($xOffset, $yOffset) public function setBottomRightOffset($xOffset, $yOffset)
{ {
if (!is_null($xOffset)) { if ($xOffset !== null) {
$this->setBottomRightXOffset($xOffset); $this->setBottomRightXOffset($xOffset);
} }
if (!is_null($yOffset)) { if ($yOffset !== null) {
$this->setBottomRightYOffset($yOffset); $this->setBottomRightYOffset($yOffset);
} }
@ -643,7 +643,7 @@ class Chart
public function render($outputDestination = null) public function render($outputDestination = null)
{ {
$libraryName = Settings::getChartRendererName(); $libraryName = Settings::getChartRendererName();
if (is_null($libraryName)) { if ($libraryName === null) {
return false; return false;
} }
// Ensure that data series values are up-to-date before we render // 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) 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; ($line_width !== null) ? $this->lineStyleProperties['width'] = $this->getExcelPointsWidth((float) $line_width) : null;
(!is_null($compound_type)) ? $this->lineStyleProperties['compound'] = (string) $compound_type : null; ($compound_type !== null) ? $this->lineStyleProperties['compound'] = (string) $compound_type : null;
(!is_null($dash_type)) ? $this->lineStyleProperties['dash'] = (string) $dash_type : null; ($dash_type !== null) ? $this->lineStyleProperties['dash'] = (string) $dash_type : null;
(!is_null($cap_type)) ? $this->lineStyleProperties['cap'] = (string) $cap_type : null; ($cap_type !== null) ? $this->lineStyleProperties['cap'] = (string) $cap_type : null;
(!is_null($join_type)) ? $this->lineStyleProperties['join'] = (string) $join_type : null; ($join_type !== null) ? $this->lineStyleProperties['join'] = (string) $join_type : null;
(!is_null($head_arrow_type)) ? $this->lineStyleProperties['arrow']['head']['type'] = (string) $head_arrow_type : null; ($head_arrow_type !== null) ? $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; ($head_arrow_size !== null) ? $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; ($end_arrow_type !== null) ? $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; ($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) $this->setShadowPresetsProperties((int) $sh_presets)
->setShadowColor( ->setShadowColor(
is_null($sh_color_value) ? $this->shadowProperties['color']['value'] : $sh_color_value, $sh_color_value === null ? $this->shadowProperties['color']['value'] : $sh_color_value,
is_null($sh_color_alpha) ? (int) $this->shadowProperties['color']['alpha'] : $sh_color_alpha, $sh_color_alpha === null ? (int) $this->shadowProperties['color']['alpha'] : $sh_color_alpha,
is_null($sh_color_type) ? $this->shadowProperties['color']['type'] : $sh_color_type $sh_color_type === null ? $this->shadowProperties['color']['type'] : $sh_color_type
) )
->setShadowBlur($sh_blur) ->setShadowBlur($sh_blur)
->setShadowAngle($sh_angle) ->setShadowAngle($sh_angle)
@ -481,9 +481,9 @@ class Axis extends Properties
{ {
$this->setGlowSize($size) $this->setGlowSize($size)
->setGlowColor( ->setGlowColor(
is_null($color_value) ? $this->glowProperties['color']['value'] : $color_value, $color_value === null ? $this->glowProperties['color']['value'] : $color_value,
is_null($color_alpha) ? (int) $this->glowProperties['color']['alpha'] : $color_alpha, $color_alpha === null ? (int) $this->glowProperties['color']['alpha'] : $color_alpha,
is_null($color_type) ? $this->glowProperties['color']['type'] : $color_type $color_type === null ? $this->glowProperties['color']['type'] : $color_type
); );
} }
@ -508,7 +508,7 @@ class Axis extends Properties
*/ */
private function setGlowSize($size) private function setGlowSize($size)
{ {
if (!is_null($size)) { if ($size !== null) {
$this->glowProperties['size'] = $this->getExcelPointsWidth($size); $this->glowProperties['size'] = $this->getExcelPointsWidth($size);
} }
@ -538,7 +538,7 @@ class Axis extends Properties
*/ */
public function setSoftEdges($size) public function setSoftEdges($size)
{ {
if (!is_null($size)) { if ($size !== null) {
$softEdges['size'] = (string) $this->getExcelPointsWidth($size); $softEdges['size'] = (string) $this->getExcelPointsWidth($size);
} }
} }

View File

@ -123,19 +123,19 @@ class DataSeries
$this->plotOrder = $plotOrder; $this->plotOrder = $plotOrder;
$keys = array_keys($plotValues); $keys = array_keys($plotValues);
$this->plotValues = $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(); $plotLabel[$keys[0]] = new DataSeriesValues();
} }
$this->plotLabel = $plotLabel; $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(); $plotCategory[$keys[0]] = new DataSeriesValues();
} }
$this->plotCategory = $plotCategory; $this->plotCategory = $plotCategory;
$this->smoothLine = $smoothLine; $this->smoothLine = $smoothLine;
$this->plotStyle = $plotStyle; $this->plotStyle = $plotStyle;
if (is_null($plotDirection)) { if ($plotDirection === null) {
$plotDirection = self::DIRECTION_COL; $plotDirection = self::DIRECTION_COL;
} }
$this->plotDirection = $plotDirection; $this->plotDirection = $plotDirection;

View File

@ -234,7 +234,7 @@ class DataSeriesValues
/** /**
* Identify if the Data Series is a multi-level or a simple series. * Identify if the Data Series is a multi-level or a simple series.
* *
* @return bool|null * @return null|bool
*/ */
public function isMultiLevelSeries() public function isMultiLevelSeries()
{ {
@ -324,7 +324,7 @@ class DataSeriesValues
} else { } else {
$cellRange = explode('!', $this->dataSource); $cellRange = explode('!', $this->dataSource);
if (count($cellRange) > 1) { if (count($cellRange) > 1) {
list(, $cellRange) = $cellRange; [, $cellRange] = $cellRange;
} }
$dimensions = Cell::rangeDimension(str_replace('$', '', $cellRange)); $dimensions = Cell::rangeDimension(str_replace('$', '', $cellRange));

View File

@ -20,6 +20,7 @@ class Exception extends PhpSpreadsheetException
$e = new self($string, $code); $e = new self($string, $code);
$e->line = $line; $e->line = $line;
$e->file = $file; $e->file = $file;
throw $e; 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) 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(); $this->activateObject();
(!is_null($line_width)) ($line_width !== null)
? $this->lineProperties['style']['width'] = $this->getExcelPointsWidth((float) $line_width) ? $this->lineProperties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
: null; : null;
(!is_null($compound_type)) ($compound_type !== null)
? $this->lineProperties['style']['compound'] = (string) $compound_type ? $this->lineProperties['style']['compound'] = (string) $compound_type
: null; : null;
(!is_null($dash_type)) ($dash_type !== null)
? $this->lineProperties['style']['dash'] = (string) $dash_type ? $this->lineProperties['style']['dash'] = (string) $dash_type
: null; : null;
(!is_null($cap_type)) ($cap_type !== null)
? $this->lineProperties['style']['cap'] = (string) $cap_type ? $this->lineProperties['style']['cap'] = (string) $cap_type
: null; : null;
(!is_null($join_type)) ($join_type !== null)
? $this->lineProperties['style']['join'] = (string) $join_type ? $this->lineProperties['style']['join'] = (string) $join_type
: null; : null;
(!is_null($head_arrow_type)) ($head_arrow_type !== null)
? $this->lineProperties['style']['arrow']['head']['type'] = (string) $head_arrow_type ? $this->lineProperties['style']['arrow']['head']['type'] = (string) $head_arrow_type
: null; : null;
(!is_null($head_arrow_size)) ($head_arrow_size !== null)
? $this->lineProperties['style']['arrow']['head']['size'] = (string) $head_arrow_size ? $this->lineProperties['style']['arrow']['head']['size'] = (string) $head_arrow_size
: null; : null;
(!is_null($end_arrow_type)) ($end_arrow_type !== null)
? $this->lineProperties['style']['arrow']['end']['type'] = (string) $end_arrow_type ? $this->lineProperties['style']['arrow']['end']['type'] = (string) $end_arrow_type
: null; : null;
(!is_null($end_arrow_size)) ($end_arrow_size !== null)
? $this->lineProperties['style']['arrow']['end']['size'] = (string) $end_arrow_size ? $this->lineProperties['style']['arrow']['end']['size'] = (string) $end_arrow_size
: null; : null;
} }
@ -249,13 +249,13 @@ class GridLines extends Properties
*/ */
private function setGlowColor($color, $alpha, $type) private function setGlowColor($color, $alpha, $type)
{ {
if (!is_null($color)) { if ($color !== null) {
$this->glowProperties['color']['value'] = (string) $color; $this->glowProperties['color']['value'] = (string) $color;
} }
if (!is_null($alpha)) { if ($alpha !== null) {
$this->glowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha); $this->glowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
} }
if (!is_null($type)) { if ($type !== null) {
$this->glowProperties['color']['type'] = (string) $type; $this->glowProperties['color']['type'] = (string) $type;
} }
@ -291,9 +291,9 @@ class GridLines extends Properties
$this->activateObject() $this->activateObject()
->setShadowPresetsProperties((int) $sh_presets) ->setShadowPresetsProperties((int) $sh_presets)
->setShadowColor( ->setShadowColor(
is_null($sh_color_value) ? $this->shadowProperties['color']['value'] : $sh_color_value, $sh_color_value === null ? $this->shadowProperties['color']['value'] : $sh_color_value,
is_null($sh_color_alpha) ? (int) $this->shadowProperties['color']['alpha'] : $this->getTrueAlpha($sh_color_alpha), $sh_color_alpha === null ? (int) $this->shadowProperties['color']['alpha'] : $this->getTrueAlpha($sh_color_alpha),
is_null($sh_color_type) ? $this->shadowProperties['color']['type'] : $sh_color_type $sh_color_type === null ? $this->shadowProperties['color']['type'] : $sh_color_type
) )
->setShadowBlur($sh_blur) ->setShadowBlur($sh_blur)
->setShadowAngle($sh_angle) ->setShadowAngle($sh_angle)
@ -357,13 +357,13 @@ class GridLines extends Properties
*/ */
private function setShadowColor($color, $alpha, $type) private function setShadowColor($color, $alpha, $type)
{ {
if (!is_null($color)) { if ($color !== null) {
$this->shadowProperties['color']['value'] = (string) $color; $this->shadowProperties['color']['value'] = (string) $color;
} }
if (!is_null($alpha)) { if ($alpha !== null) {
$this->shadowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha); $this->shadowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
} }
if (!is_null($type)) { if ($type !== null) {
$this->shadowProperties['color']['type'] = (string) $type; $this->shadowProperties['color']['type'] = (string) $type;
} }
@ -438,7 +438,7 @@ class GridLines extends Properties
*/ */
public function setSoftEdgesSize($size) public function setSoftEdgesSize($size)
{ {
if (!is_null($size)) { if ($size !== null) {
$this->activateObject(); $this->activateObject();
$softEdges['size'] = (string) $this->getExcelPointsWidth($size); $softEdges['size'] = (string) $this->getExcelPointsWidth($size);
} }

View File

@ -46,13 +46,13 @@ class Legend
* *
* @var Layout * @var Layout
*/ */
private $layout = null; private $layout;
/** /**
* Create a new Legend. * Create a new Legend.
* *
* @param string $position * @param string $position
* @param Layout|null $layout * @param null|Layout $layout
* @param bool $overlay * @param bool $overlay
*/ */
public function __construct($position = self::POSITION_RIGHT, Layout $layout = null, $overlay = false) public function __construct($position = self::POSITION_RIGHT, Layout $layout = null, $overlay = false)

View File

@ -11,7 +11,7 @@ class PlotArea
* *
* @var Layout * @var Layout
*/ */
private $layout = null; private $layout;
/** /**
* Plot Series. * Plot Series.
@ -23,7 +23,7 @@ class PlotArea
/** /**
* Create a new PlotArea. * Create a new PlotArea.
* *
* @param Layout|null $layout * @param null|Layout $layout
* @param array $plotSeries * @param array $plotSeries
*/ */
public function __construct(Layout $layout = null, array $plotSeries = []) public function __construct(Layout $layout = null, array $plotSeries = [])

View File

@ -42,7 +42,7 @@ class JpGraph
private function formatPointMarker($seriesPlot, $markerID) private function formatPointMarker($seriesPlot, $markerID)
{ {
$plotMarkKeys = array_keys(self::$markSet); $plotMarkKeys = array_keys(self::$markSet);
if (is_null($markerID)) { if ($markerID === null) {
// Use default plot marker (next marker in the series) // Use default plot marker (next marker in the series)
self::$plotMark %= count(self::$markSet); self::$plotMark %= count(self::$markSet);
$seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$plotMark++]]); $seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$plotMark++]]);
@ -69,7 +69,7 @@ class JpGraph
private function formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '') private function formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '')
{ {
$datasetLabelFormatCode = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode(); $datasetLabelFormatCode = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode();
if (!is_null($datasetLabelFormatCode)) { if ($datasetLabelFormatCode !== null) {
// Retrieve any label formatting code // Retrieve any label formatting code
$datasetLabelFormatCode = stripslashes($datasetLabelFormatCode); $datasetLabelFormatCode = stripslashes($datasetLabelFormatCode);
} }
@ -85,7 +85,7 @@ class JpGraph
} }
} else { } else {
// Format labels according to any formatting code // Format labels according to any formatting code
if (!is_null($datasetLabelFormatCode)) { if ($datasetLabelFormatCode !== null) {
$datasetLabels[$i] = NumberFormat::toFormattedString($datasetLabel, $datasetLabelFormatCode); $datasetLabels[$i] = NumberFormat::toFormattedString($datasetLabel, $datasetLabelFormatCode);
} }
} }
@ -128,9 +128,9 @@ class JpGraph
private function getCaption($captionElement) private function getCaption($captionElement)
{ {
// Read any caption // 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 // 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 we do, it could be a plain string or an array
if (is_array($caption)) { if (is_array($caption)) {
// Implode an array to a plain string // Implode an array to a plain string
@ -144,7 +144,7 @@ class JpGraph
private function renderTitle() private function renderTitle()
{ {
$title = $this->getCaption($this->chart->getTitle()); $title = $this->getCaption($this->chart->getTitle());
if (!is_null($title)) { if ($title !== null) {
$this->graph->title->Set($title); $this->graph->title->Set($title);
} }
} }
@ -152,17 +152,19 @@ class JpGraph
private function renderLegend() private function renderLegend()
{ {
$legend = $this->chart->getLegend(); $legend = $this->chart->getLegend();
if (!is_null($legend)) { if ($legend !== null) {
$legendPosition = $legend->getPosition(); $legendPosition = $legend->getPosition();
$legendOverlay = $legend->getOverlay(); $legendOverlay = $legend->getOverlay();
switch ($legendPosition) { switch ($legendPosition) {
case 'r': case 'r':
$this->graph->legend->SetPos(0.01, 0.5, 'right', 'center'); // right $this->graph->legend->SetPos(0.01, 0.5, 'right', 'center'); // right
$this->graph->legend->SetColumns(1); $this->graph->legend->SetColumns(1);
break; break;
case 'l': case 'l':
$this->graph->legend->SetPos(0.01, 0.5, 'left', 'center'); // left $this->graph->legend->SetPos(0.01, 0.5, 'left', 'center'); // left
$this->graph->legend->SetColumns(1); $this->graph->legend->SetColumns(1);
break; break;
case 't': case 't':
$this->graph->legend->SetPos(0.5, 0.01, 'center', 'top'); // top $this->graph->legend->SetPos(0.5, 0.01, 'center', 'top'); // top
@ -173,6 +175,7 @@ class JpGraph
default: default:
$this->graph->legend->SetPos(0.01, 0.01, 'right', 'top'); // top-right $this->graph->legend->SetPos(0.01, 0.01, 'right', 'top'); // top-right
$this->graph->legend->SetColumns(1); $this->graph->legend->SetColumns(1);
break; break;
} }
} else { } else {
@ -192,9 +195,9 @@ class JpGraph
$reverse = ($rotation == 'bar') ? true : false; $reverse = ($rotation == 'bar') ? true : false;
$xAxisLabel = $this->chart->getXAxisLabel(); $xAxisLabel = $this->chart->getXAxisLabel();
if (!is_null($xAxisLabel)) { if ($xAxisLabel !== null) {
$title = $this->getCaption($xAxisLabel); $title = $this->getCaption($xAxisLabel);
if (!is_null($title)) { if ($title !== null) {
$this->graph->xaxis->SetTitle($title, 'center'); $this->graph->xaxis->SetTitle($title, 'center');
$this->graph->xaxis->title->SetMargin(35); $this->graph->xaxis->title->SetMargin(35);
if ($reverse) { if ($reverse) {
@ -205,9 +208,9 @@ class JpGraph
} }
$yAxisLabel = $this->chart->getYAxisLabel(); $yAxisLabel = $this->chart->getYAxisLabel();
if (!is_null($yAxisLabel)) { if ($yAxisLabel !== null) {
$title = $this->getCaption($yAxisLabel); $title = $this->getCaption($yAxisLabel);
if (!is_null($title)) { if ($title !== null) {
$this->graph->yaxis->SetTitle($title, 'center'); $this->graph->yaxis->SetTitle($title, 'center');
if ($reverse) { if ($reverse) {
$this->graph->yaxis->title->SetAngle(0); $this->graph->yaxis->title->SetAngle(0);
@ -402,7 +405,7 @@ class JpGraph
$seriesPlot->link->SetColor(self::$colourSet[self::$plotColour]); $seriesPlot->link->SetColor(self::$colourSet[self::$plotColour]);
} elseif ($scatterStyle == 'smoothMarker') { } elseif ($scatterStyle == 'smoothMarker') {
$spline = new Spline($dataValuesY, $dataValuesX); $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 = new LinePlot($splineDataX, $splineDataY);
$lplot->SetColor(self::$colourSet[self::$plotColour]); $lplot->SetColor(self::$colourSet[self::$plotColour]);
@ -706,24 +709,29 @@ class JpGraph
// no break // no break
case 'areaChart': case 'areaChart':
$this->renderPlotLine($i, true, true, $dimensions); $this->renderPlotLine($i, true, true, $dimensions);
break; break;
case 'bar3DChart': case 'bar3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'barChart': case 'barChart':
$this->renderPlotBar($i, $dimensions); $this->renderPlotBar($i, $dimensions);
break; break;
case 'line3DChart': case 'line3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'lineChart': case 'lineChart':
$this->renderPlotLine($i, false, true, $dimensions); $this->renderPlotLine($i, false, true, $dimensions);
break; break;
case 'scatterChart': case 'scatterChart':
$this->renderPlotScatter($i, false); $this->renderPlotScatter($i, false);
break; break;
case 'bubbleChart': case 'bubbleChart':
$this->renderPlotScatter($i, true); $this->renderPlotScatter($i, true);
break; break;
default: default:
$this->graph = null; $this->graph = null;
@ -771,48 +779,58 @@ class JpGraph
// no break // no break
case 'areaChart': case 'areaChart':
$this->renderAreaChart($groupCount, $dimensions); $this->renderAreaChart($groupCount, $dimensions);
break; break;
case 'bar3DChart': case 'bar3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'barChart': case 'barChart':
$this->renderBarChart($groupCount, $dimensions); $this->renderBarChart($groupCount, $dimensions);
break; break;
case 'line3DChart': case 'line3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'lineChart': case 'lineChart':
$this->renderLineChart($groupCount, $dimensions); $this->renderLineChart($groupCount, $dimensions);
break; break;
case 'pie3DChart': case 'pie3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'pieChart': case 'pieChart':
$this->renderPieChart($groupCount, $dimensions, false, false); $this->renderPieChart($groupCount, $dimensions, false, false);
break; break;
case 'doughnut3DChart': case 'doughnut3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'doughnutChart': case 'doughnutChart':
$this->renderPieChart($groupCount, $dimensions, true, true); $this->renderPieChart($groupCount, $dimensions, true, true);
break; break;
case 'scatterChart': case 'scatterChart':
$this->renderScatterChart($groupCount); $this->renderScatterChart($groupCount);
break; break;
case 'bubbleChart': case 'bubbleChart':
$this->renderBubbleChart($groupCount); $this->renderBubbleChart($groupCount);
break; break;
case 'radarChart': case 'radarChart':
$this->renderRadarChart($groupCount); $this->renderRadarChart($groupCount);
break; break;
case 'surface3DChart': case 'surface3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'surfaceChart': case 'surfaceChart':
$this->renderContourChart($groupCount, $dimensions); $this->renderContourChart($groupCount, $dimensions);
break; break;
case 'stockChart': case 'stockChart':
$this->renderStockChart($groupCount); $this->renderStockChart($groupCount);
break; break;
default: default:
echo $chartType . ' is not yet implemented<br />'; echo $chartType . ' is not yet implemented<br />';

View File

@ -9,14 +9,14 @@ class Title
* *
* @var string * @var string
*/ */
private $caption = null; private $caption;
/** /**
* Title Layout. * Title Layout.
* *
* @var Layout * @var Layout
*/ */
private $layout = null; private $layout;
/** /**
* Create a new Title. * Create a new Title.

View File

@ -26,14 +26,14 @@ class Cells
* *
* @var Cell * @var Cell
*/ */
private $currentCell = null; private $currentCell;
/** /**
* Coordinate of the currently active Cell. * Coordinate of the currently active Cell.
* *
* @var string * @var string
*/ */
private $currentCoordinate = null; private $currentCoordinate;
/** /**
* Flag indicating whether the currently active Cell requires saving. * Flag indicating whether the currently active Cell requires saving.
@ -54,7 +54,7 @@ class Cells
* *
* @var string * @var string
*/ */
private $cachePrefix = null; private $cachePrefix;
/** /**
* Initialise this new cell collection. * Initialise this new cell collection.
@ -121,7 +121,7 @@ class Cells
*/ */
public function delete($pCoord) public function delete($pCoord)
{ {
if ($pCoord === $this->currentCoordinate && !is_null($this->currentCell)) { if ($pCoord === $this->currentCoordinate && $this->currentCell !== null) {
$this->currentCell->detach(); $this->currentCell->detach();
$this->currentCoordinate = null; $this->currentCoordinate = null;
$this->currentCell = null; $this->currentCell = null;
@ -321,6 +321,7 @@ class Cells
$stored = $newCollection->cache->setMultiple($newValues); $stored = $newCollection->cache->setMultiple($newValues);
if (!$stored) { if (!$stored) {
$newCollection->__destruct(); $newCollection->__destruct();
throw new PhpSpreadsheetException('Failed to copy cells in cache'); 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); $stored = $this->cache->set($this->cachePrefix . $this->currentCoordinate, $this->currentCell);
if (!$stored) { if (!$stored) {
$this->__destruct(); $this->__destruct();
throw new PhpSpreadsheetException("Failed to store cell {$this->currentCoordinate} in cache"); throw new PhpSpreadsheetException("Failed to store cell {$this->currentCoordinate} in cache");
} }
$this->currentCellIsDirty = false; $this->currentCellIsDirty = false;
@ -446,7 +448,7 @@ class Cells
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells()
{ {
if (!is_null($this->currentCell)) { if ($this->currentCell !== null) {
$this->currentCell->detach(); $this->currentCell->detach();
$this->currentCell = null; $this->currentCell = null;
$this->currentCoordinate = null; $this->currentCoordinate = null;

View File

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

View File

@ -211,27 +211,34 @@ class IOFactory
case 'xltx': // Excel (OfficeOpenXML) Template case 'xltx': // Excel (OfficeOpenXML) Template
case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded) case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
$extensionType = 'Xlsx'; $extensionType = 'Xlsx';
break; break;
case 'xls': // Excel (BIFF) Spreadsheet case 'xls': // Excel (BIFF) Spreadsheet
case 'xlt': // Excel (BIFF) Template case 'xlt': // Excel (BIFF) Template
$extensionType = 'Xls'; $extensionType = 'Xls';
break; break;
case 'ods': // Open/Libre Offic Calc case 'ods': // Open/Libre Offic Calc
case 'ots': // Open/Libre Offic Calc Template case 'ots': // Open/Libre Offic Calc Template
$extensionType = 'Ods'; $extensionType = 'Ods';
break; break;
case 'slk': case 'slk':
$extensionType = 'Slk'; $extensionType = 'Slk';
break; break;
case 'xml': // Excel 2003 SpreadSheetML case 'xml': // Excel 2003 SpreadSheetML
$extensionType = 'Xml'; $extensionType = 'Xml';
break; break;
case 'gnumeric': case 'gnumeric':
$extensionType = 'Gnumeric'; $extensionType = 'Gnumeric';
break; break;
case 'htm': case 'htm':
case 'html': case 'html':
$extensionType = 'Html'; $extensionType = 'Html';
break; break;
case 'csv': case 'csv':
// Do nothing // Do nothing

View File

@ -46,7 +46,7 @@ class NamedRange
* @param Worksheet $pWorksheet * @param Worksheet $pWorksheet
* @param string $pRange * @param string $pRange
* @param bool $pLocalOnly * @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 * @throws Exception
*/ */
@ -186,7 +186,7 @@ class NamedRange
/** /**
* Get scope. * Get scope.
* *
* @return Worksheet|null * @return null|Worksheet
*/ */
public function getScope() public function getScope()
{ {
@ -196,7 +196,7 @@ class NamedRange
/** /**
* Set scope. * Set scope.
* *
* @param Worksheet|null $value * @param null|Worksheet $value
* *
* @return NamedRange * @return NamedRange
*/ */
@ -212,7 +212,7 @@ class NamedRange
* Resolve a named range to a regular cell range. * Resolve a named range to a regular cell range.
* *
* @param string $pNamedRange Named 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 * @return NamedRange
*/ */

View File

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

View File

@ -20,7 +20,7 @@ class Csv extends BaseReader implements IReader
* *
* @var string * @var string
*/ */
private $delimiter = null; private $delimiter;
/** /**
* Enclosure. * Enclosure.
@ -91,22 +91,27 @@ class Csv extends BaseReader implements IReader
case 'UTF-8': case 'UTF-8':
fgets($this->fileHandle, 4) == "\xEF\xBB\xBF" ? fgets($this->fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($this->fileHandle, 3) : fseek($this->fileHandle, 0); fseek($this->fileHandle, 3) : fseek($this->fileHandle, 0);
break; break;
case 'UTF-16LE': case 'UTF-16LE':
fgets($this->fileHandle, 3) == "\xFF\xFE" ? fgets($this->fileHandle, 3) == "\xFF\xFE" ?
fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0); fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0);
break; break;
case 'UTF-16BE': case 'UTF-16BE':
fgets($this->fileHandle, 3) == "\xFE\xFF" ? fgets($this->fileHandle, 3) == "\xFE\xFF" ?
fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0); fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0);
break; break;
case 'UTF-32LE': case 'UTF-32LE':
fgets($this->fileHandle, 5) == "\xFF\xFE\x00\x00" ? fgets($this->fileHandle, 5) == "\xFF\xFE\x00\x00" ?
fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0); fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0);
break; break;
case 'UTF-32BE': case 'UTF-32BE':
fgets($this->fileHandle, 5) == "\x00\x00\xFE\xFF" ? fgets($this->fileHandle, 5) == "\x00\x00\xFE\xFF" ?
fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0); fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0);
break; break;
default: default:
break; break;

View File

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

View File

@ -34,7 +34,7 @@ class Gnumeric extends BaseReader implements IReader
*/ */
private $expressions = []; private $expressions = [];
private $referenceHelper = null; private $referenceHelper;
/** /**
* Create a new Gnumeric. * Create a new Gnumeric.
@ -141,6 +141,7 @@ class Gnumeric extends BaseReader implements IReader
} elseif ($xml->name == 'gnm:MaxRow' && $xml->nodeType == XMLReader::ELEMENT) { } elseif ($xml->name == 'gnm:MaxRow' && $xml->nodeType == XMLReader::ELEMENT) {
$xml->read(); // Move onto the value node $xml->read(); // Move onto the value node
$tmpInfo['totalRows'] = (int) $xml->value + 1; $tmpInfo['totalRows'] = (int) $xml->value + 1;
break; break;
} }
} }
@ -228,21 +229,26 @@ class Gnumeric extends BaseReader implements IReader
switch ($propertyName) { switch ($propertyName) {
case 'title': case 'title':
$docProps->setTitle(trim($propertyValue)); $docProps->setTitle(trim($propertyValue));
break; break;
case 'subject': case 'subject':
$docProps->setSubject(trim($propertyValue)); $docProps->setSubject(trim($propertyValue));
break; break;
case 'creator': case 'creator':
$docProps->setCreator(trim($propertyValue)); $docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue)); $docProps->setLastModifiedBy(trim($propertyValue));
break; break;
case 'date': case 'date':
$creationDate = strtotime(trim($propertyValue)); $creationDate = strtotime(trim($propertyValue));
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
$docProps->setModified($creationDate); $docProps->setModified($creationDate);
break; break;
case 'description': case 'description':
$docProps->setDescription(trim($propertyValue)); $docProps->setDescription(trim($propertyValue));
break; break;
} }
} }
@ -256,29 +262,36 @@ class Gnumeric extends BaseReader implements IReader
switch ($propertyName) { switch ($propertyName) {
case 'keyword': case 'keyword':
$docProps->setKeywords(trim($propertyValue)); $docProps->setKeywords(trim($propertyValue));
break; break;
case 'initial-creator': case 'initial-creator':
$docProps->setCreator(trim($propertyValue)); $docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue)); $docProps->setLastModifiedBy(trim($propertyValue));
break; break;
case 'creation-date': case 'creation-date':
$creationDate = strtotime(trim($propertyValue)); $creationDate = strtotime(trim($propertyValue));
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
$docProps->setModified($creationDate); $docProps->setModified($creationDate);
break; break;
case 'user-defined': case 'user-defined':
list(, $attrName) = explode(':', $attributes['name']); [, $attrName] = explode(':', $attributes['name']);
switch ($attrName) { switch ($attrName) {
case 'publisher': case 'publisher':
$docProps->setCompany(trim($propertyValue)); $docProps->setCompany(trim($propertyValue));
break; break;
case 'category': case 'category':
$docProps->setCategory(trim($propertyValue)); $docProps->setCategory(trim($propertyValue));
break; break;
case 'manager': case 'manager':
$docProps->setManager(trim($propertyValue)); $docProps->setManager(trim($propertyValue));
break; break;
} }
break; break;
} }
} }
@ -290,25 +303,32 @@ class Gnumeric extends BaseReader implements IReader
switch ($propertyName) { switch ($propertyName) {
case 'title': case 'title':
$docProps->setTitle(trim($propertyValue)); $docProps->setTitle(trim($propertyValue));
break; break;
case 'comments': case 'comments':
$docProps->setDescription(trim($propertyValue)); $docProps->setDescription(trim($propertyValue));
break; break;
case 'keywords': case 'keywords':
$docProps->setKeywords(trim($propertyValue)); $docProps->setKeywords(trim($propertyValue));
break; break;
case 'category': case 'category':
$docProps->setCategory(trim($propertyValue)); $docProps->setCategory(trim($propertyValue));
break; break;
case 'manager': case 'manager':
$docProps->setManager(trim($propertyValue)); $docProps->setManager(trim($propertyValue));
break; break;
case 'author': case 'author':
$docProps->setCreator(trim($propertyValue)); $docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue)); $docProps->setLastModifiedBy(trim($propertyValue));
break; break;
case 'company': case 'company':
$docProps->setCompany(trim($propertyValue)); $docProps->setCompany(trim($propertyValue));
break; break;
} }
} }
@ -339,26 +359,33 @@ class Gnumeric extends BaseReader implements IReader
switch ($marginAttributes['PrefUnit']) { switch ($marginAttributes['PrefUnit']) {
case 'mm': case 'mm':
$marginSize = (int) ($marginAttributes['Points']) / 100; $marginSize = (int) ($marginAttributes['Points']) / 100;
break; break;
} }
switch ($key) { switch ($key) {
case 'top': case 'top':
$spreadsheet->getActiveSheet()->getPageMargins()->setTop($marginSize); $spreadsheet->getActiveSheet()->getPageMargins()->setTop($marginSize);
break; break;
case 'bottom': case 'bottom':
$spreadsheet->getActiveSheet()->getPageMargins()->setBottom($marginSize); $spreadsheet->getActiveSheet()->getPageMargins()->setBottom($marginSize);
break; break;
case 'left': case 'left':
$spreadsheet->getActiveSheet()->getPageMargins()->setLeft($marginSize); $spreadsheet->getActiveSheet()->getPageMargins()->setLeft($marginSize);
break; break;
case 'right': case 'right':
$spreadsheet->getActiveSheet()->getPageMargins()->setRight($marginSize); $spreadsheet->getActiveSheet()->getPageMargins()->setRight($marginSize);
break; break;
case 'header': case 'header':
$spreadsheet->getActiveSheet()->getPageMargins()->setHeader($marginSize); $spreadsheet->getActiveSheet()->getPageMargins()->setHeader($marginSize);
break; break;
case 'footer': case 'footer':
$spreadsheet->getActiveSheet()->getPageMargins()->setFooter($marginSize); $spreadsheet->getActiveSheet()->getPageMargins()->setFooter($marginSize);
break; break;
} }
} }
@ -412,22 +439,28 @@ class Gnumeric extends BaseReader implements IReader
switch ($ValueType) { switch ($ValueType) {
case '10': // NULL case '10': // NULL
$type = Cell\DataType::TYPE_NULL; $type = Cell\DataType::TYPE_NULL;
break; break;
case '20': // Boolean case '20': // Boolean
$type = Cell\DataType::TYPE_BOOL; $type = Cell\DataType::TYPE_BOOL;
$cell = ($cell == 'TRUE') ? true : false; $cell = ($cell == 'TRUE') ? true : false;
break; break;
case '30': // Integer case '30': // Integer
$cell = (int) $cell; $cell = (int) $cell;
// Excel 2007+ doesn't differentiate between integer and float, so set the value and dropthru to the next (numeric) case // 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 case '40': // Float
$type = Cell\DataType::TYPE_NUMERIC; $type = Cell\DataType::TYPE_NUMERIC;
break; break;
case '50': // Error case '50': // Error
$type = Cell\DataType::TYPE_ERROR; $type = Cell\DataType::TYPE_ERROR;
break; break;
case '60': // String case '60': // String
$type = Cell\DataType::TYPE_STRING; $type = Cell\DataType::TYPE_STRING;
break; break;
case '70': // Cell Range case '70': // Cell Range
case '80': // Array case '80': // Array
@ -470,37 +503,47 @@ class Gnumeric extends BaseReader implements IReader
switch ($styleAttributes['HAlign']) { switch ($styleAttributes['HAlign']) {
case '1': case '1':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_GENERAL; $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_GENERAL;
break; break;
case '2': case '2':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_LEFT; $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_LEFT;
break; break;
case '4': case '4':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_RIGHT; $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_RIGHT;
break; break;
case '8': case '8':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER; $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER;
break; break;
case '16': case '16':
case '64': case '64':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER_CONTINUOUS; $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER_CONTINUOUS;
break; break;
case '32': case '32':
$styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_JUSTIFY; $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_JUSTIFY;
break; break;
} }
switch ($styleAttributes['VAlign']) { switch ($styleAttributes['VAlign']) {
case '1': case '1':
$styleArray['alignment']['vertical'] = Alignment::VERTICAL_TOP; $styleArray['alignment']['vertical'] = Alignment::VERTICAL_TOP;
break; break;
case '2': case '2':
$styleArray['alignment']['vertical'] = Alignment::VERTICAL_BOTTOM; $styleArray['alignment']['vertical'] = Alignment::VERTICAL_BOTTOM;
break; break;
case '4': case '4':
$styleArray['alignment']['vertical'] = Alignment::VERTICAL_CENTER; $styleArray['alignment']['vertical'] = Alignment::VERTICAL_CENTER;
break; break;
case '8': case '8':
$styleArray['alignment']['vertical'] = Alignment::VERTICAL_JUSTIFY; $styleArray['alignment']['vertical'] = Alignment::VERTICAL_JUSTIFY;
break; break;
} }
@ -519,63 +562,83 @@ class Gnumeric extends BaseReader implements IReader
switch ($shade) { switch ($shade) {
case '1': case '1':
$styleArray['fill']['fillType'] = Fill::FILL_SOLID; $styleArray['fill']['fillType'] = Fill::FILL_SOLID;
break; break;
case '2': case '2':
$styleArray['fill']['fillType'] = Fill::FILL_GRADIENT_LINEAR; $styleArray['fill']['fillType'] = Fill::FILL_GRADIENT_LINEAR;
break; break;
case '3': case '3':
$styleArray['fill']['fillType'] = Fill::FILL_GRADIENT_PATH; $styleArray['fill']['fillType'] = Fill::FILL_GRADIENT_PATH;
break; break;
case '4': case '4':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKDOWN; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKDOWN;
break; break;
case '5': case '5':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKGRAY; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKGRAY;
break; break;
case '6': case '6':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKGRID; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKGRID;
break; break;
case '7': case '7':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKHORIZONTAL; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKHORIZONTAL;
break; break;
case '8': case '8':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKTRELLIS; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKTRELLIS;
break; break;
case '9': case '9':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKUP; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKUP;
break; break;
case '10': case '10':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKVERTICAL; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKVERTICAL;
break; break;
case '11': case '11':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_GRAY0625; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_GRAY0625;
break; break;
case '12': case '12':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_GRAY125; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_GRAY125;
break; break;
case '13': case '13':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTDOWN; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTDOWN;
break; break;
case '14': case '14':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTGRAY; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTGRAY;
break; break;
case '15': case '15':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTGRID; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTGRID;
break; break;
case '16': case '16':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTHORIZONTAL; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTHORIZONTAL;
break; break;
case '17': case '17':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTTRELLIS; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTTRELLIS;
break; break;
case '18': case '18':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTUP; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTUP;
break; break;
case '19': case '19':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTVERTICAL; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTVERTICAL;
break; break;
case '20': case '20':
$styleArray['fill']['fillType'] = Fill::FILL_PATTERN_MEDIUMGRAY; $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_MEDIUMGRAY;
break; break;
} }
} }
@ -589,26 +652,33 @@ class Gnumeric extends BaseReader implements IReader
switch ($fontAttributes['Underline']) { switch ($fontAttributes['Underline']) {
case '1': case '1':
$styleArray['font']['underline'] = Font::UNDERLINE_SINGLE; $styleArray['font']['underline'] = Font::UNDERLINE_SINGLE;
break; break;
case '2': case '2':
$styleArray['font']['underline'] = Font::UNDERLINE_DOUBLE; $styleArray['font']['underline'] = Font::UNDERLINE_DOUBLE;
break; break;
case '3': case '3':
$styleArray['font']['underline'] = Font::UNDERLINE_SINGLEACCOUNTING; $styleArray['font']['underline'] = Font::UNDERLINE_SINGLEACCOUNTING;
break; break;
case '4': case '4':
$styleArray['font']['underline'] = Font::UNDERLINE_DOUBLEACCOUNTING; $styleArray['font']['underline'] = Font::UNDERLINE_DOUBLEACCOUNTING;
break; break;
default: default:
$styleArray['font']['underline'] = Font::UNDERLINE_NONE; $styleArray['font']['underline'] = Font::UNDERLINE_NONE;
break; break;
} }
switch ($fontAttributes['Script']) { switch ($fontAttributes['Script']) {
case '1': case '1':
$styleArray['font']['superscript'] = true; $styleArray['font']['superscript'] = true;
break; break;
case '-1': case '-1':
$styleArray['font']['subscript'] = true; $styleArray['font']['subscript'] = true;
break; break;
} }
@ -749,45 +819,59 @@ class Gnumeric extends BaseReader implements IReader
switch ($borderAttributes['Style']) { switch ($borderAttributes['Style']) {
case '0': case '0':
$styleArray['borderStyle'] = Border::BORDER_NONE; $styleArray['borderStyle'] = Border::BORDER_NONE;
break; break;
case '1': case '1':
$styleArray['borderStyle'] = Border::BORDER_THIN; $styleArray['borderStyle'] = Border::BORDER_THIN;
break; break;
case '2': case '2':
$styleArray['borderStyle'] = Border::BORDER_MEDIUM; $styleArray['borderStyle'] = Border::BORDER_MEDIUM;
break; break;
case '3': case '3':
$styleArray['borderStyle'] = Border::BORDER_SLANTDASHDOT; $styleArray['borderStyle'] = Border::BORDER_SLANTDASHDOT;
break; break;
case '4': case '4':
$styleArray['borderStyle'] = Border::BORDER_DASHED; $styleArray['borderStyle'] = Border::BORDER_DASHED;
break; break;
case '5': case '5':
$styleArray['borderStyle'] = Border::BORDER_THICK; $styleArray['borderStyle'] = Border::BORDER_THICK;
break; break;
case '6': case '6':
$styleArray['borderStyle'] = Border::BORDER_DOUBLE; $styleArray['borderStyle'] = Border::BORDER_DOUBLE;
break; break;
case '7': case '7':
$styleArray['borderStyle'] = Border::BORDER_DOTTED; $styleArray['borderStyle'] = Border::BORDER_DOTTED;
break; break;
case '8': case '8':
$styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHED; $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHED;
break; break;
case '9': case '9':
$styleArray['borderStyle'] = Border::BORDER_DASHDOT; $styleArray['borderStyle'] = Border::BORDER_DASHDOT;
break; break;
case '10': case '10':
$styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOT; $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOT;
break; break;
case '11': case '11':
$styleArray['borderStyle'] = Border::BORDER_DASHDOTDOT; $styleArray['borderStyle'] = Border::BORDER_DASHDOTDOT;
break; break;
case '12': case '12':
$styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOTDOT; $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOTDOT;
break; break;
case '13': case '13':
$styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOTDOT; $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOTDOT;
break; break;
} }
@ -804,7 +888,7 @@ class Gnumeric extends BaseReader implements IReader
private static function parseGnumericColour($gnmColour) 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); $gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2);
$gnmG = substr(str_pad($gnmG, 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); $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); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
break; break;
case 'title': case 'title':
$this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
$sheet->setTitle($cellContent, true, false); $sheet->setTitle($cellContent, true, false);
$cellContent = ''; $cellContent = '';
break; break;
case 'span': case 'span':
case 'div': case 'div':
@ -312,6 +314,7 @@ class Html extends BaseReader implements IReader
if ($cellContent > '') { if ($cellContent > '') {
$cellContent .= ' '; $cellContent .= ' ';
} }
break; break;
case 'hr': case 'hr':
$this->flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
@ -324,6 +327,7 @@ class Html extends BaseReader implements IReader
} }
++$row; ++$row;
// Add a break after a horizontal rule, simply by allowing the code to dropthru // Add a break after a horizontal rule, simply by allowing the code to dropthru
// no break
case 'br': case 'br':
if ($this->tableLevel > 0) { if ($this->tableLevel > 0) {
// If we're inside a table, replace with a \n // 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); $this->flushCell($sheet, $column, $row, $cellContent);
++$row; ++$row;
} }
break; break;
case 'a': case 'a':
foreach ($attributeArray as $attributeName => $attributeValue) { foreach ($attributeArray as $attributeName => $attributeValue) {
@ -342,11 +347,13 @@ class Html extends BaseReader implements IReader
if (isset($this->formats[$child->nodeName])) { if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
} }
break; break;
} }
} }
$cellContent .= ' '; $cellContent .= ' ';
$this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
break; break;
case 'h1': case 'h1':
case 'h2': case 'h2':
@ -376,6 +383,7 @@ class Html extends BaseReader implements IReader
++$row; ++$row;
$column = 'A'; $column = 'A';
} }
break; break;
case 'li': case 'li':
if ($this->tableLevel > 0) { if ($this->tableLevel > 0) {
@ -391,6 +399,7 @@ class Html extends BaseReader implements IReader
$this->flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
$column = 'A'; $column = 'A';
} }
break; break;
case 'table': case 'table':
$this->flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
@ -405,16 +414,19 @@ class Html extends BaseReader implements IReader
} else { } else {
++$row; ++$row;
} }
break; break;
case 'thead': case 'thead':
case 'tbody': case 'tbody':
$this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
break; break;
case 'tr': case 'tr':
$column = $this->getTableStartColumn(); $column = $this->getTableStartColumn();
$cellContent = ''; $cellContent = '';
$this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
++$row; ++$row;
break; break;
case 'th': case 'th':
case 'td': case 'td':
@ -429,7 +441,7 @@ class Html extends BaseReader implements IReader
$this->flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
if (isset($attributeArray['rowspan']) && isset($attributeArray['colspan'])) { if (isset($attributeArray['rowspan'], $attributeArray['colspan'])) {
//create merging rowspan and colspan //create merging rowspan and colspan
$columnTo = $column; $columnTo = $column;
for ($i = 0; $i < $attributeArray['colspan'] - 1; ++$i) { for ($i = 0; $i < $attributeArray['colspan'] - 1; ++$i) {
@ -467,6 +479,7 @@ class Html extends BaseReader implements IReader
); );
} }
++$column; ++$column;
break; break;
case 'body': case 'body':
$row = 1; $row = 1;
@ -474,6 +487,7 @@ class Html extends BaseReader implements IReader
$content = ''; $content = '';
$this->tableLevel = 0; $this->tableLevel = 0;
$this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
break; break;
default: default:
$this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
@ -610,9 +624,11 @@ class Html extends BaseReader implements IReader
switch (trim($value[0])) { switch (trim($value[0])) {
case 'background-color': case 'background-color':
$sheet->getStyle($column . $row)->applyFromArray(['fill' => ['fillType' => Fill::FILL_SOLID, 'color' => ['rgb' => "{$style_color}"]]]); $sheet->getStyle($column . $row)->applyFromArray(['fill' => ['fillType' => Fill::FILL_SOLID, 'color' => ['rgb' => "{$style_color}"]]]);
break; break;
case 'color': case 'color':
$sheet->getStyle($column . $row)->applyFromArray(['font' => ['color' => ['rgb' => "$style_color}"]]]); $sheet->getStyle($column . $row)->applyFromArray(['font' => ['color' => ['rgb' => "$style_color}"]]]);
break; break;
} }
} }

View File

@ -70,6 +70,7 @@ class Ods extends BaseReader implements IReader
$manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']); $manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']);
if ($manifestAttributes->{'full-path'} == '/') { if ($manifestAttributes->{'full-path'} == '/') {
$mimeType = (string) $manifestAttributes->{'media-type'}; $mimeType = (string) $manifestAttributes->{'media-type'};
break; break;
} }
} }
@ -284,9 +285,7 @@ class Ods extends BaseReader implements IReader
throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.'); throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.');
} }
/* // Meta
* Meta
*/
$xml = simplexml_load_string( $xml = simplexml_load_string(
$this->securityScan($zip->getFromName('meta.xml')), $this->securityScan($zip->getFromName('meta.xml')),
@ -307,21 +306,26 @@ class Ods extends BaseReader implements IReader
switch ($propertyName) { switch ($propertyName) {
case 'title': case 'title':
$docProps->setTitle($propertyValue); $docProps->setTitle($propertyValue);
break; break;
case 'subject': case 'subject':
$docProps->setSubject($propertyValue); $docProps->setSubject($propertyValue);
break; break;
case 'creator': case 'creator':
$docProps->setCreator($propertyValue); $docProps->setCreator($propertyValue);
$docProps->setLastModifiedBy($propertyValue); $docProps->setLastModifiedBy($propertyValue);
break; break;
case 'date': case 'date':
$creationDate = strtotime($propertyValue); $creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
$docProps->setModified($creationDate); $docProps->setModified($creationDate);
break; break;
case 'description': case 'description':
$docProps->setDescription($propertyValue); $docProps->setDescription($propertyValue);
break; break;
} }
} }
@ -335,13 +339,16 @@ class Ods extends BaseReader implements IReader
switch ($propertyName) { switch ($propertyName) {
case 'initial-creator': case 'initial-creator':
$docProps->setCreator($propertyValue); $docProps->setCreator($propertyValue);
break; break;
case 'keyword': case 'keyword':
$docProps->setKeywords($propertyValue); $docProps->setKeywords($propertyValue);
break; break;
case 'creation-date': case 'creation-date':
$creationDate = strtotime($propertyValue); $creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
break; break;
case 'user-defined': case 'user-defined':
$propertyValueType = Properties::PROPERTY_TYPE_STRING; $propertyValueType = Properties::PROPERTY_TYPE_STRING;
@ -353,14 +360,17 @@ class Ods extends BaseReader implements IReader
case 'date': case 'date':
$propertyValue = Properties::convertProperty($propertyValue, 'date'); $propertyValue = Properties::convertProperty($propertyValue, 'date');
$propertyValueType = Properties::PROPERTY_TYPE_DATE; $propertyValueType = Properties::PROPERTY_TYPE_DATE;
break; break;
case 'boolean': case 'boolean':
$propertyValue = Properties::convertProperty($propertyValue, 'bool'); $propertyValue = Properties::convertProperty($propertyValue, 'bool');
$propertyValueType = Properties::PROPERTY_TYPE_BOOLEAN; $propertyValueType = Properties::PROPERTY_TYPE_BOOLEAN;
break; break;
case 'float': case 'float':
$propertyValue = Properties::convertProperty($propertyValue, 'r4'); $propertyValue = Properties::convertProperty($propertyValue, 'r4');
$propertyValueType = Properties::PROPERTY_TYPE_FLOAT; $propertyValueType = Properties::PROPERTY_TYPE_FLOAT;
break; break;
default: default:
$propertyValueType = Properties::PROPERTY_TYPE_STRING; $propertyValueType = Properties::PROPERTY_TYPE_STRING;
@ -368,14 +378,13 @@ class Ods extends BaseReader implements IReader
} }
} }
$docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType);
break; break;
} }
} }
} }
/* // Content
* Content
*/
$dom = new \DOMDocument('1.01', 'UTF-8'); $dom = new \DOMDocument('1.01', 'UTF-8');
$dom->loadXML( $dom->loadXML(
@ -459,11 +468,12 @@ class Ods extends BaseReader implements IReader
$columnID = 'A'; $columnID = 'A';
foreach ($childNode->childNodes as $key => $cellData) { foreach ($childNode->childNodes as $key => $cellData) {
/* @var \DOMElement $cellData */ // @var \DOMElement $cellData
if ($this->getReadFilter() !== null) { if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
++$columnID; ++$columnID;
continue; continue;
} }
} }
@ -540,6 +550,7 @@ class Ods extends BaseReader implements IReader
case 'boolean': case 'boolean':
$type = DataType::TYPE_BOOL; $type = DataType::TYPE_BOOL;
$dataValue = ($allCellDataText == 'TRUE') ? true : false; $dataValue = ($allCellDataText == 'TRUE') ? true : false;
break; break;
case 'percentage': case 'percentage':
$type = DataType::TYPE_NUMERIC; $type = DataType::TYPE_NUMERIC;
@ -549,6 +560,7 @@ class Ods extends BaseReader implements IReader
$dataValue = (int) $dataValue; $dataValue = (int) $dataValue;
} }
$formatting = NumberFormat::FORMAT_PERCENTAGE_00; $formatting = NumberFormat::FORMAT_PERCENTAGE_00;
break; break;
case 'currency': case 'currency':
$type = DataType::TYPE_NUMERIC; $type = DataType::TYPE_NUMERIC;
@ -558,6 +570,7 @@ class Ods extends BaseReader implements IReader
$dataValue = (int) $dataValue; $dataValue = (int) $dataValue;
} }
$formatting = NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; $formatting = NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
break; break;
case 'float': case 'float':
$type = DataType::TYPE_NUMERIC; $type = DataType::TYPE_NUMERIC;
@ -570,6 +583,7 @@ class Ods extends BaseReader implements IReader
$dataValue = (float) $dataValue; $dataValue = (float) $dataValue;
} }
} }
break; break;
case 'date': case 'date':
$type = DataType::TYPE_NUMERIC; $type = DataType::TYPE_NUMERIC;
@ -577,7 +591,7 @@ class Ods extends BaseReader implements IReader
$dateObj = new DateTime($value, $GMT); $dateObj = new DateTime($value, $GMT);
$dateObj->setTimeZone($timezoneObj); $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') $dateObj->format('Y m d H i s')
); );
@ -598,6 +612,7 @@ class Ods extends BaseReader implements IReader
} else { } else {
$formatting = NumberFormat::FORMAT_DATE_XLSX15; $formatting = NumberFormat::FORMAT_DATE_XLSX15;
} }
break; break;
case 'time': case 'time':
$type = DataType::TYPE_NUMERIC; $type = DataType::TYPE_NUMERIC;
@ -610,6 +625,7 @@ class Ods extends BaseReader implements IReader
) )
); );
$formatting = NumberFormat::FORMAT_DATE_TIME4; $formatting = NumberFormat::FORMAT_DATE_TIME4;
break; break;
default: default:
$dataValue = null; $dataValue = null;
@ -729,6 +745,7 @@ class Ods extends BaseReader implements IReader
++$columnID; ++$columnID;
} }
$rowID += $rowRepeats; $rowID += $rowRepeats;
break; break;
} }
} }

View File

@ -149,10 +149,12 @@ class Slk extends BaseReader implements IReader
case 'C': case 'C':
case 'X': case 'X':
$columnIndex = substr($rowDatum, 1) - 1; $columnIndex = substr($rowDatum, 1) - 1;
break; break;
case 'R': case 'R':
case 'Y': case 'Y':
$rowIndex = substr($rowDatum, 1); $rowIndex = substr($rowDatum, 1);
break; break;
} }
@ -239,13 +241,16 @@ class Slk extends BaseReader implements IReader
switch ($rowDatum[0]) { switch ($rowDatum[0]) {
case 'P': case 'P':
$formatArray['numberFormat']['formatCode'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1)); $formatArray['numberFormat']['formatCode'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1));
break; break;
case 'E': case 'E':
case 'F': case 'F':
$formatArray['font']['name'] = substr($rowDatum, 1); $formatArray['font']['name'] = substr($rowDatum, 1);
break; break;
case 'L': case 'L':
$formatArray['font']['size'] = substr($rowDatum, 1); $formatArray['font']['size'] = substr($rowDatum, 1);
break; break;
case 'S': case 'S':
$styleSettings = substr($rowDatum, 1); $styleSettings = substr($rowDatum, 1);
@ -253,24 +258,31 @@ class Slk extends BaseReader implements IReader
switch ($styleSettings[$i]) { switch ($styleSettings[$i]) {
case 'I': case 'I':
$formatArray['font']['italic'] = true; $formatArray['font']['italic'] = true;
break; break;
case 'D': case 'D':
$formatArray['font']['bold'] = true; $formatArray['font']['bold'] = true;
break; break;
case 'T': case 'T':
$formatArray['borders']['top']['borderStyle'] = Border::BORDER_THIN; $formatArray['borders']['top']['borderStyle'] = Border::BORDER_THIN;
break; break;
case 'B': case 'B':
$formatArray['borders']['bottom']['borderStyle'] = Border::BORDER_THIN; $formatArray['borders']['bottom']['borderStyle'] = Border::BORDER_THIN;
break; break;
case 'L': case 'L':
$formatArray['borders']['left']['borderStyle'] = Border::BORDER_THIN; $formatArray['borders']['left']['borderStyle'] = Border::BORDER_THIN;
break; break;
case 'R': case 'R':
$formatArray['borders']['right']['borderStyle'] = Border::BORDER_THIN; $formatArray['borders']['right']['borderStyle'] = Border::BORDER_THIN;
break; break;
} }
} }
break; break;
} }
} }
@ -284,13 +296,16 @@ class Slk extends BaseReader implements IReader
case 'C': case 'C':
case 'X': case 'X':
$column = substr($rowDatum, 1); $column = substr($rowDatum, 1);
break; break;
case 'R': case 'R':
case 'Y': case 'Y':
$row = substr($rowDatum, 1); $row = substr($rowDatum, 1);
break; break;
case 'K': case 'K':
$cellData = substr($rowDatum, 1); $cellData = substr($rowDatum, 1);
break; break;
case 'E': case 'E':
$cellDataFormula = '=' . substr($rowDatum, 1); $cellDataFormula = '=' . substr($rowDatum, 1);
@ -336,6 +351,7 @@ class Slk extends BaseReader implements IReader
// Then rebuild the formula string // Then rebuild the formula string
$cellDataFormula = implode('"', $temp); $cellDataFormula = implode('"', $temp);
$hasCalculatedValue = true; $hasCalculatedValue = true;
break; break;
} }
} }
@ -357,16 +373,20 @@ class Slk extends BaseReader implements IReader
case 'C': case 'C':
case 'X': case 'X':
$column = substr($rowDatum, 1); $column = substr($rowDatum, 1);
break; break;
case 'R': case 'R':
case 'Y': case 'Y':
$row = substr($rowDatum, 1); $row = substr($rowDatum, 1);
break; break;
case 'P': case 'P':
$formatStyle = $rowDatum; $formatStyle = $rowDatum;
break; break;
case 'W': case 'W':
list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1)); [$startCol, $endCol, $columnWidth] = explode(' ', substr($rowDatum, 1));
break; break;
case 'S': case 'S':
$styleSettings = substr($rowDatum, 1); $styleSettings = substr($rowDatum, 1);
@ -374,24 +394,31 @@ class Slk extends BaseReader implements IReader
switch ($styleSettings[$i]) { switch ($styleSettings[$i]) {
case 'I': case 'I':
$styleData['font']['italic'] = true; $styleData['font']['italic'] = true;
break; break;
case 'D': case 'D':
$styleData['font']['bold'] = true; $styleData['font']['bold'] = true;
break; break;
case 'T': case 'T':
$styleData['borders']['top']['borderStyle'] = Border::BORDER_THIN; $styleData['borders']['top']['borderStyle'] = Border::BORDER_THIN;
break; break;
case 'B': case 'B':
$styleData['borders']['bottom']['borderStyle'] = Border::BORDER_THIN; $styleData['borders']['bottom']['borderStyle'] = Border::BORDER_THIN;
break; break;
case 'L': case 'L':
$styleData['borders']['left']['borderStyle'] = Border::BORDER_THIN; $styleData['borders']['left']['borderStyle'] = Border::BORDER_THIN;
break; break;
case 'R': case 'R':
$styleData['borders']['right']['borderStyle'] = Border::BORDER_THIN; $styleData['borders']['right']['borderStyle'] = Border::BORDER_THIN;
break; break;
} }
} }
break; break;
} }
} }
@ -424,10 +451,12 @@ class Slk extends BaseReader implements IReader
case 'C': case 'C':
case 'X': case 'X':
$column = substr($rowDatum, 1); $column = substr($rowDatum, 1);
break; break;
case 'R': case 'R':
case 'Y': case 'Y':
$row = substr($rowDatum, 1); $row = substr($rowDatum, 1);
break; break;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ class Color
if ($color <= 0x07 || $color >= 0x40) { if ($color <= 0x07 || $color >= 0x40) {
// special built-in color // special built-in color
return Color\BuiltIn::lookup($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 // palette color, color index 0x08 maps to pallete index 0
return $palette[$color - 8]; return $palette[$color - 8];
} }

View File

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

View File

@ -93,60 +93,79 @@ class Escher
switch ($fbt) { switch ($fbt) {
case self::DGGCONTAINER: case self::DGGCONTAINER:
$this->readDggContainer(); $this->readDggContainer();
break; break;
case self::DGG: case self::DGG:
$this->readDgg(); $this->readDgg();
break; break;
case self::BSTORECONTAINER: case self::BSTORECONTAINER:
$this->readBstoreContainer(); $this->readBstoreContainer();
break; break;
case self::BSE: case self::BSE:
$this->readBSE(); $this->readBSE();
break; break;
case self::BLIPJPEG: case self::BLIPJPEG:
$this->readBlipJPEG(); $this->readBlipJPEG();
break; break;
case self::BLIPPNG: case self::BLIPPNG:
$this->readBlipPNG(); $this->readBlipPNG();
break; break;
case self::OPT: case self::OPT:
$this->readOPT(); $this->readOPT();
break; break;
case self::TERTIARYOPT: case self::TERTIARYOPT:
$this->readTertiaryOPT(); $this->readTertiaryOPT();
break; break;
case self::SPLITMENUCOLORS: case self::SPLITMENUCOLORS:
$this->readSplitMenuColors(); $this->readSplitMenuColors();
break; break;
case self::DGCONTAINER: case self::DGCONTAINER:
$this->readDgContainer(); $this->readDgContainer();
break; break;
case self::DG: case self::DG:
$this->readDg(); $this->readDg();
break; break;
case self::SPGRCONTAINER: case self::SPGRCONTAINER:
$this->readSpgrContainer(); $this->readSpgrContainer();
break; break;
case self::SPCONTAINER: case self::SPCONTAINER:
$this->readSpContainer(); $this->readSpContainer();
break; break;
case self::SPGR: case self::SPGR:
$this->readSpgr(); $this->readSpgr();
break; break;
case self::SP: case self::SP:
$this->readSp(); $this->readSp();
break; break;
case self::CLIENTTEXTBOX: case self::CLIENTTEXTBOX:
$this->readClientTextbox(); $this->readClientTextbox();
break; break;
case self::CLIENTANCHOR: case self::CLIENTANCHOR:
$this->readClientAnchor(); $this->readClientAnchor();
break; break;
case self::CLIENTDATA: case self::CLIENTDATA:
$this->readClientData(); $this->readClientData();
break; break;
default: default:
$this->readDefault(); $this->readDefault();
break; break;
} }
} }

View File

@ -67,7 +67,7 @@ class MD5
$H = ['self', 'h']; $H = ['self', 'h'];
$I = ['self', 'i']; $I = ['self', 'i'];
/* ROUND 1 */ // ROUND 1
self::step($F, $A, $B, $C, $D, $words[0], 7, 0xd76aa478); 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, $D, $A, $B, $C, $words[1], 12, 0xe8c7b756);
self::step($F, $C, $D, $A, $B, $words[2], 17, 0x242070db); 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, $C, $D, $A, $B, $words[14], 17, 0xa679438e);
self::step($F, $B, $C, $D, $A, $words[15], 22, 0x49b40821); 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, $A, $B, $C, $D, $words[1], 5, 0xf61e2562);
self::step($G, $D, $A, $B, $C, $words[6], 9, 0xc040b340); self::step($G, $D, $A, $B, $C, $words[6], 9, 0xc040b340);
self::step($G, $C, $D, $A, $B, $words[11], 14, 0x265e5a51); 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, $C, $D, $A, $B, $words[7], 14, 0x676f02d9);
self::step($G, $B, $C, $D, $A, $words[12], 20, 0x8d2a4c8a); 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, $A, $B, $C, $D, $words[5], 4, 0xfffa3942);
self::step($H, $D, $A, $B, $C, $words[8], 11, 0x8771f681); self::step($H, $D, $A, $B, $C, $words[8], 11, 0x8771f681);
self::step($H, $C, $D, $A, $B, $words[11], 16, 0x6d9d6122); 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, $C, $D, $A, $B, $words[15], 16, 0x1fa27cf8);
self::step($H, $B, $C, $D, $A, $words[2], 23, 0xc4ac5665); 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, $A, $B, $C, $D, $words[0], 6, 0xf4292244);
self::step($I, $D, $A, $B, $C, $words[7], 10, 0x432aff97); self::step($I, $D, $A, $B, $C, $words[7], 10, 0x432aff97);
self::step($I, $C, $D, $A, $B, $words[14], 15, 0xab9423a7); 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 * @var ReferenceHelper
*/ */
private $referenceHelper = null; private $referenceHelper;
/** /**
* Xlsx\Theme instance. * Xlsx\Theme instance.
@ -79,6 +79,7 @@ class Xlsx extends BaseReader implements IReader
if (basename($rel['Target']) == 'workbook.xml') { if (basename($rel['Target']) == 'workbook.xml') {
$xl = true; $xl = true;
} }
break; break;
} }
} }
@ -381,6 +382,7 @@ class Xlsx extends BaseReader implements IReader
} }
self::$theme = new Xlsx\Theme($themeName, $colourSchemeName, $themeColours); self::$theme = new Xlsx\Theme($themeName, $colourSchemeName, $themeColours);
} }
break; break;
} }
} }
@ -414,6 +416,7 @@ class Xlsx extends BaseReader implements IReader
$docProps->setKeywords((string) self::getArrayItem($xmlCore->xpath('cp:keywords'))); $docProps->setKeywords((string) self::getArrayItem($xmlCore->xpath('cp:keywords')));
$docProps->setCategory((string) self::getArrayItem($xmlCore->xpath('cp:category'))); $docProps->setCategory((string) self::getArrayItem($xmlCore->xpath('cp:category')));
} }
break; break;
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties': case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties':
$xmlCore = simplexml_load_string( $xmlCore = simplexml_load_string(
@ -430,6 +433,7 @@ class Xlsx extends BaseReader implements IReader
$docProps->setManager((string) $xmlCore->Manager); $docProps->setManager((string) $xmlCore->Manager);
} }
} }
break; break;
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties': case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties':
$xmlCore = simplexml_load_string( $xmlCore = simplexml_load_string(
@ -453,13 +457,15 @@ class Xlsx extends BaseReader implements IReader
} }
} }
} }
break; break;
//Ribbon //Ribbon
case 'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility': case 'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility':
$customUI = $rel['Target']; $customUI = $rel['Target'];
if (!is_null($customUI)) { if ($customUI !== null) {
$this->readRibbon($excel, $customUI, $zip); $this->readRibbon($excel, $customUI, $zip);
} }
break; break;
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument': case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument':
$dir = dirname($rel['Target']); $dir = dirname($rel['Target']);
@ -479,7 +485,7 @@ class Xlsx extends BaseReader implements IReader
'SimpleXMLElement', 'SimpleXMLElement',
Settings::getLibXmlLoaderOptions() Settings::getLibXmlLoaderOptions()
); );
if (isset($xmlStrings) && isset($xmlStrings->si)) { if (isset($xmlStrings, $xmlStrings->si)) {
foreach ($xmlStrings->si as $val) { foreach ($xmlStrings->si as $val) {
if (isset($val->t)) { if (isset($val->t)) {
$sharedStrings[] = StringHelper::controlCharacterOOXML2PHP((string) $val->t); $sharedStrings[] = StringHelper::controlCharacterOOXML2PHP((string) $val->t);
@ -495,15 +501,17 @@ class Xlsx extends BaseReader implements IReader
switch ($ele['Type']) { switch ($ele['Type']) {
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet': case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet':
$worksheets[(string) $ele['Id']] = $ele['Target']; $worksheets[(string) $ele['Id']] = $ele['Target'];
break; break;
// a vbaProject ? (: some macros) // a vbaProject ? (: some macros)
case 'http://schemas.microsoft.com/office/2006/relationships/vbaProject': case 'http://schemas.microsoft.com/office/2006/relationships/vbaProject':
$macros = $ele['Target']; $macros = $ele['Target'];
break; 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 $macrosCode = $this->getFromZipArchive($zip, 'xl/vbaProject.bin'); //vbaProject.bin always in 'xl' dir and always named vbaProject.bin
if ($macrosCode !== false) { if ($macrosCode !== false) {
$excel->setMacrosCode($macrosCode); $excel->setMacrosCode($macrosCode);
@ -662,6 +670,7 @@ class Xlsx extends BaseReader implements IReader
if (isset($this->loadSheetsOnly) && !in_array((string) $eleSheet['name'], $this->loadSheetsOnly)) { if (isset($this->loadSheetsOnly) && !in_array((string) $eleSheet['name'], $this->loadSheetsOnly)) {
++$countSkippedSheets; ++$countSkippedSheets;
$mapSheetId[$oldSheetId] = null; $mapSheetId[$oldSheetId] = null;
continue; continue;
} }
@ -690,7 +699,7 @@ class Xlsx extends BaseReader implements IReader
$docSheet->setSheetState((string) $eleSheet['state']); $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'])) { if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) {
$docSheet->getSheetView()->setZoomScale((int) ($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'])) { if (isset($xmlSheet->sheetPr->tabColor['rgb'])) {
$docSheet->getTabColor()->setARGB((string) $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); $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']) && if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) &&
!self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) { !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) {
$docSheet->setShowSummaryRight(false); $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']) && if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) &&
!self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) { !self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) {
$docSheet->getPageSetup()->setFitToPage(false); $docSheet->getPageSetup()->setFitToPage(false);
@ -875,6 +884,7 @@ class Xlsx extends BaseReader implements IReader
} else { } else {
$value = ''; $value = '';
} }
break; break;
case 'b': case 'b':
if (!isset($c->f)) { if (!isset($c->f)) {
@ -887,6 +897,7 @@ class Xlsx extends BaseReader implements IReader
$docSheet->getCell($r)->setFormulaAttributes($att); $docSheet->getCell($r)->setFormulaAttributes($att);
} }
} }
break; break;
case 'inlineStr': case 'inlineStr':
if (isset($c->f)) { if (isset($c->f)) {
@ -894,6 +905,7 @@ class Xlsx extends BaseReader implements IReader
} else { } else {
$value = $this->parseRichText($c->is); $value = $this->parseRichText($c->is);
} }
break; break;
case 'e': case 'e':
if (!isset($c->f)) { if (!isset($c->f)) {
@ -902,6 +914,7 @@ class Xlsx extends BaseReader implements IReader
// Formula // Formula
$this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError'); $this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError');
} }
break; break;
default: default:
if (!isset($c->f)) { if (!isset($c->f)) {
@ -910,6 +923,7 @@ class Xlsx extends BaseReader implements IReader
// Formula // Formula
$this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToString'); $this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToString');
} }
break; break;
} }
@ -1147,7 +1161,7 @@ class Xlsx extends BaseReader implements IReader
if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) { if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) {
$docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false); $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'])) { self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) {
$docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber'])); $docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber']));
} }
@ -1679,6 +1693,7 @@ class Xlsx extends BaseReader implements IReader
} }
} }
} }
break; break;
case '_xlnm.Print_Titles': case '_xlnm.Print_Titles':
// Split $extractedRange // Split $extractedRange
@ -1697,6 +1712,7 @@ class Xlsx extends BaseReader implements IReader
$docSheet->getPageSetup()->setRowsToRepeatAtTop([$matches[1], $matches[2]]); $docSheet->getPageSetup()->setRowsToRepeatAtTop([$matches[1], $matches[2]]);
} }
} }
break; break;
case '_xlnm.Print_Area': case '_xlnm.Print_Area':
$rangeSets = preg_split("/'(.*?)'(?:![A-Z0-9]+:[A-Z0-9]+,?)/", $extractedRange, PREG_SPLIT_NO_EMPTY); $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); $newRangeSets[] = str_replace('$', '', $rangeSet);
} }
$docSheet->getPageSetup()->setPrintArea(implode(',', $newRangeSets)); $docSheet->getPageSetup()->setPrintArea(implode(',', $newRangeSets));
break; break;
default: default:
break; break;
@ -1760,6 +1777,7 @@ class Xlsx extends BaseReader implements IReader
} }
} }
} }
break; break;
} }
} elseif (!isset($definedName['localSheetId'])) { } elseif (!isset($definedName['localSheetId'])) {
@ -1801,6 +1819,7 @@ class Xlsx extends BaseReader implements IReader
$excel->setActiveSheetIndex(0); $excel->setActiveSheetIndex(0);
} }
} }
break; break;
} }
} }
@ -1873,7 +1892,7 @@ class Xlsx extends BaseReader implements IReader
/** /**
* @param Style $docStyle * @param Style $docStyle
* @param \stdClass|\SimpleXMLElement $style * @param \SimpleXMLElement|\stdClass $style
*/ */
private static function readStyle(Style $docStyle, $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'])) { if (isset($style->font->u) && !isset($style->font->u['val'])) {
$docStyle->getFont()->setUnderline(Style\Font::UNDERLINE_SINGLE); $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']); $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']); $vertAlign = strtolower((string) $style->font->vertAlign['val']);
if ($vertAlign == 'superscript') { if ($vertAlign == 'superscript') {
$docStyle->getFont()->setSuperscript(true); $docStyle->getFont()->setSuperscript(true);
@ -2051,7 +2070,7 @@ class Xlsx extends BaseReader implements IReader
(isset($run->rPr->i) && !isset($run->rPr->i['val']))) { (isset($run->rPr->i) && !isset($run->rPr->i['val']))) {
$objText->getFont()->setItalic(true); $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']); $vertAlign = strtolower((string) $run->rPr->vertAlign['val']);
if ($vertAlign == 'superscript') { if ($vertAlign == 'superscript') {
$objText->getFont()->setSuperscript(true); $objText->getFont()->setSuperscript(true);
@ -2062,7 +2081,7 @@ class Xlsx extends BaseReader implements IReader
} }
if (isset($run->rPr->u) && !isset($run->rPr->u['val'])) { if (isset($run->rPr->u) && !isset($run->rPr->u['val'])) {
$objText->getFont()->setUnderline(Style\Font::UNDERLINE_SINGLE); $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']); $objText->getFont()->setUnderline((string) $run->rPr->u['val']);
} }
if ((isset($run->rPr->strike['val']) && self::boolean((string) $run->rPr->strike['val'])) || if ((isset($run->rPr->strike['val']) && self::boolean((string) $run->rPr->strike['val'])) ||

View File

@ -73,21 +73,25 @@ class Chart
switch ($chartDetailKey) { switch ($chartDetailKey) {
case 'layout': case 'layout':
$plotAreaLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta); $plotAreaLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta);
break; break;
case 'catAx': case 'catAx':
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta); $XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta);
} }
break; break;
case 'dateAx': case 'dateAx':
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta); $XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta);
} }
break; break;
case 'valAx': case 'valAx':
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$YaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta); $YaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta);
} }
break; break;
case 'barChart': case 'barChart':
case 'bar3DChart': case 'bar3DChart':
@ -96,16 +100,19 @@ class Chart
$plotSer->setPlotDirection($barDirection); $plotSer->setPlotDirection($barDirection);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail); $plotAttributes = self::readChartAttributes($chartDetail);
break; break;
case 'lineChart': case 'lineChart':
case 'line3DChart': case 'line3DChart':
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::readChartAttributes($chartDetail); $plotAttributes = self::readChartAttributes($chartDetail);
break; break;
case 'areaChart': case 'areaChart':
case 'area3DChart': case 'area3DChart':
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::readChartAttributes($chartDetail); $plotAttributes = self::readChartAttributes($chartDetail);
break; break;
case 'doughnutChart': case 'doughnutChart':
case 'pieChart': case 'pieChart':
@ -115,6 +122,7 @@ class Chart
$plotSer->setPlotStyle($explosion); $plotSer->setPlotStyle($explosion);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail); $plotAttributes = self::readChartAttributes($chartDetail);
break; break;
case 'scatterChart': case 'scatterChart':
$scatterStyle = self::getAttribute($chartDetail->scatterStyle, 'val', 'string'); $scatterStyle = self::getAttribute($chartDetail->scatterStyle, 'val', 'string');
@ -122,6 +130,7 @@ class Chart
$plotSer->setPlotStyle($scatterStyle); $plotSer->setPlotStyle($scatterStyle);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail); $plotAttributes = self::readChartAttributes($chartDetail);
break; break;
case 'bubbleChart': case 'bubbleChart':
$bubbleScale = self::getAttribute($chartDetail->bubbleScale, 'val', 'integer'); $bubbleScale = self::getAttribute($chartDetail->bubbleScale, 'val', 'integer');
@ -129,6 +138,7 @@ class Chart
$plotSer->setPlotStyle($bubbleScale); $plotSer->setPlotStyle($bubbleScale);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail); $plotAttributes = self::readChartAttributes($chartDetail);
break; break;
case 'radarChart': case 'radarChart':
$radarStyle = self::getAttribute($chartDetail->radarStyle, 'val', 'string'); $radarStyle = self::getAttribute($chartDetail->radarStyle, 'val', 'string');
@ -136,6 +146,7 @@ class Chart
$plotSer->setPlotStyle($radarStyle); $plotSer->setPlotStyle($radarStyle);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail); $plotAttributes = self::readChartAttributes($chartDetail);
break; break;
case 'surfaceChart': case 'surfaceChart':
case 'surface3DChart': case 'surface3DChart':
@ -144,10 +155,12 @@ class Chart
$plotSer->setPlotStyle($wireFrame); $plotSer->setPlotStyle($wireFrame);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::readChartAttributes($chartDetail); $plotAttributes = self::readChartAttributes($chartDetail);
break; break;
case 'stockChart': case 'stockChart':
$plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSeries[] = self::chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::readChartAttributes($plotAreaLayout); $plotAttributes = self::readChartAttributes($plotAreaLayout);
break; break;
} }
} }
@ -156,15 +169,19 @@ class Chart
} }
$plotArea = new PlotArea($plotAreaLayout, $plotSeries); $plotArea = new PlotArea($plotAreaLayout, $plotSeries);
self::setChartAttributes($plotAreaLayout, $plotAttributes); self::setChartAttributes($plotAreaLayout, $plotAttributes);
break; break;
case 'plotVisOnly': case 'plotVisOnly':
$plotVisOnly = self::getAttribute($chartDetails, 'val', 'string'); $plotVisOnly = self::getAttribute($chartDetails, 'val', 'string');
break; break;
case 'dispBlanksAs': case 'dispBlanksAs':
$dispBlanksAs = self::getAttribute($chartDetails, 'val', 'string'); $dispBlanksAs = self::getAttribute($chartDetails, 'val', 'string');
break; break;
case 'title': case 'title':
$title = self::chartTitle($chartDetails, $namespacesChartMeta); $title = self::chartTitle($chartDetails, $namespacesChartMeta);
break; break;
case 'legend': case 'legend':
$legendPos = 'r'; $legendPos = 'r';
@ -174,16 +191,20 @@ class Chart
switch ($chartDetailKey) { switch ($chartDetailKey) {
case 'legendPos': case 'legendPos':
$legendPos = self::getAttribute($chartDetail, 'val', 'string'); $legendPos = self::getAttribute($chartDetail, 'val', 'string');
break; break;
case 'overlay': case 'overlay':
$legendOverlay = self::getAttribute($chartDetail, 'val', 'boolean'); $legendOverlay = self::getAttribute($chartDetail, 'val', 'boolean');
break; break;
case 'layout': case 'layout':
$legendLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta); $legendLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta);
break; break;
} }
} }
$legend = new Legend($legendPos, $legendLayout, $legendOverlay); $legend = new Legend($legendPos, $legendLayout, $legendOverlay);
break; break;
} }
} }
@ -209,9 +230,11 @@ class Chart
$caption[] = self::parseRichText($titleDetailPart); $caption[] = self::parseRichText($titleDetailPart);
} }
} }
break; break;
case 'layout': case 'layout':
$titleLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta); $titleLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta);
break; break;
} }
} }
@ -225,7 +248,7 @@ class Chart
return null; return null;
} }
$details = $chartDetail->manualLayout->children($namespacesChartMeta['c']); $details = $chartDetail->manualLayout->children($namespacesChartMeta['c']);
if (is_null($details)) { if ($details === null) {
return null; return null;
} }
$layout = []; $layout = [];
@ -247,6 +270,7 @@ class Chart
switch ($seriesDetailKey) { switch ($seriesDetailKey) {
case 'grouping': case 'grouping':
$multiSeriesType = self::getAttribute($chartDetail->grouping, 'val', 'string'); $multiSeriesType = self::getAttribute($chartDetail->grouping, 'val', 'string');
break; break;
case 'ser': case 'ser':
$marker = null; $marker = null;
@ -254,31 +278,40 @@ class Chart
switch ($seriesKey) { switch ($seriesKey) {
case 'idx': case 'idx':
$seriesIndex = self::getAttribute($seriesDetail, 'val', 'integer'); $seriesIndex = self::getAttribute($seriesDetail, 'val', 'integer');
break; break;
case 'order': case 'order':
$seriesOrder = self::getAttribute($seriesDetail, 'val', 'integer'); $seriesOrder = self::getAttribute($seriesDetail, 'val', 'integer');
$plotOrder[$seriesIndex] = $seriesOrder; $plotOrder[$seriesIndex] = $seriesOrder;
break; break;
case 'tx': case 'tx':
$seriesLabel[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta); $seriesLabel[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
break; break;
case 'marker': case 'marker':
$marker = self::getAttribute($seriesDetail->symbol, 'val', 'string'); $marker = self::getAttribute($seriesDetail->symbol, 'val', 'string');
break; break;
case 'smooth': case 'smooth':
$smoothLine = self::getAttribute($seriesDetail, 'val', 'boolean'); $smoothLine = self::getAttribute($seriesDetail, 'val', 'boolean');
break; break;
case 'cat': case 'cat':
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta); $seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
break; break;
case 'val': case 'val':
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker); $seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break; break;
case 'xVal': case 'xVal':
$seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker); $seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break; break;
case 'yVal': case 'yVal':
$seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker); $seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break; break;
} }
} }
@ -327,9 +360,11 @@ class Chart
switch ($seriesValueIdx) { switch ($seriesValueIdx) {
case 'ptCount': case 'ptCount':
$pointCount = self::getAttribute($seriesValue, 'val', 'integer'); $pointCount = self::getAttribute($seriesValue, 'val', 'integer');
break; break;
case 'formatCode': case 'formatCode':
$formatCode = (string) $seriesValue; $formatCode = (string) $seriesValue;
break; break;
case 'pt': case 'pt':
$pointVal = self::getAttribute($seriesValue, 'idx', 'integer'); $pointVal = self::getAttribute($seriesValue, 'idx', 'integer');
@ -340,6 +375,7 @@ class Chart
} else { } else {
$seriesVal[$pointVal] = (float) $seriesValue->v; $seriesVal[$pointVal] = (float) $seriesValue->v;
} }
break; break;
} }
} }
@ -362,9 +398,11 @@ class Chart
switch ($seriesValueIdx) { switch ($seriesValueIdx) {
case 'ptCount': case 'ptCount':
$pointCount = self::getAttribute($seriesValue, 'val', 'integer'); $pointCount = self::getAttribute($seriesValue, 'val', 'integer');
break; break;
case 'formatCode': case 'formatCode':
$formatCode = (string) $seriesValue; $formatCode = (string) $seriesValue;
break; break;
case 'pt': case 'pt':
$pointVal = self::getAttribute($seriesValue, 'idx', 'integer'); $pointVal = self::getAttribute($seriesValue, 'idx', 'integer');
@ -375,6 +413,7 @@ class Chart
} else { } else {
$seriesVal[$pointVal][] = (float) $seriesValue->v; $seriesVal[$pointVal][] = (float) $seriesValue->v;
} }
break; break;
} }
} }
@ -401,27 +440,27 @@ class Chart
} }
$fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer')); $fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
if (!is_null($fontSize)) { if ($fontSize !== null) {
$objText->getFont()->setSize(floor($fontSize / 100)); $objText->getFont()->setSize(floor($fontSize / 100));
} }
$fontColor = (self::getAttribute($titleDetailElement->rPr, 'color', 'string')); $fontColor = (self::getAttribute($titleDetailElement->rPr, 'color', 'string'));
if (!is_null($fontColor)) { if ($fontColor !== null) {
$objText->getFont()->setColor(new Color(self::readColor($fontColor))); $objText->getFont()->setColor(new Color(self::readColor($fontColor)));
} }
$bold = self::getAttribute($titleDetailElement->rPr, 'b', 'boolean'); $bold = self::getAttribute($titleDetailElement->rPr, 'b', 'boolean');
if (!is_null($bold)) { if ($bold !== null) {
$objText->getFont()->setBold($bold); $objText->getFont()->setBold($bold);
} }
$italic = self::getAttribute($titleDetailElement->rPr, 'i', 'boolean'); $italic = self::getAttribute($titleDetailElement->rPr, 'i', 'boolean');
if (!is_null($italic)) { if ($italic !== null) {
$objText->getFont()->setItalic($italic); $objText->getFont()->setItalic($italic);
} }
$baseline = self::getAttribute($titleDetailElement->rPr, 'baseline', 'integer'); $baseline = self::getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
if (!is_null($baseline)) { if ($baseline !== null) {
if ($baseline > 0) { if ($baseline > 0) {
$objText->getFont()->setSuperscript(true); $objText->getFont()->setSuperscript(true);
} elseif ($baseline < 0) { } elseif ($baseline < 0) {
@ -430,7 +469,7 @@ class Chart
} }
$underscore = (self::getAttribute($titleDetailElement->rPr, 'u', 'string')); $underscore = (self::getAttribute($titleDetailElement->rPr, 'u', 'string'));
if (!is_null($underscore)) { if ($underscore !== null) {
if ($underscore == 'sng') { if ($underscore == 'sng') {
$objText->getFont()->setUnderline(Font::UNDERLINE_SINGLE); $objText->getFont()->setUnderline(Font::UNDERLINE_SINGLE);
} elseif ($underscore == 'dbl') { } elseif ($underscore == 'dbl') {
@ -441,7 +480,7 @@ class Chart
} }
$strikethrough = (self::getAttribute($titleDetailElement->rPr, 's', 'string')); $strikethrough = (self::getAttribute($titleDetailElement->rPr, 's', 'string'));
if (!is_null($strikethrough)) { if ($strikethrough !== null) {
if ($strikethrough == 'noStrike') { if ($strikethrough == 'noStrike') {
$objText->getFont()->setStrikethrough(false); $objText->getFont()->setStrikethrough(false);
} else { } else {
@ -494,24 +533,31 @@ class Chart
switch ($plotAttributeKey) { switch ($plotAttributeKey) {
case 'showLegendKey': case 'showLegendKey':
$plotArea->setShowLegendKey($plotAttributeValue); $plotArea->setShowLegendKey($plotAttributeValue);
break; break;
case 'showVal': case 'showVal':
$plotArea->setShowVal($plotAttributeValue); $plotArea->setShowVal($plotAttributeValue);
break; break;
case 'showCatName': case 'showCatName':
$plotArea->setShowCatName($plotAttributeValue); $plotArea->setShowCatName($plotAttributeValue);
break; break;
case 'showSerName': case 'showSerName':
$plotArea->setShowSerName($plotAttributeValue); $plotArea->setShowSerName($plotAttributeValue);
break; break;
case 'showPercent': case 'showPercent':
$plotArea->setShowPercent($plotAttributeValue); $plotArea->setShowPercent($plotAttributeValue);
break; break;
case 'showBubbleSize': case 'showBubbleSize':
$plotArea->setShowBubbleSize($plotAttributeValue); $plotArea->setShowBubbleSize($plotAttributeValue);
break; break;
case 'showLeaderLines': case 'showLeaderLines':
$plotArea->setShowLeaderLines($plotAttributeValue); $plotArea->setShowLeaderLines($plotAttributeValue);
break; break;
} }
} }

View File

@ -82,6 +82,7 @@ class Xml extends BaseReader implements IReader
// every part of the signature must be present // every part of the signature must be present
if (strpos($data, $match) === false) { if (strpos($data, $match) === false) {
$valid = false; $valid = false;
break; break;
} }
} }
@ -344,38 +345,49 @@ class Xml extends BaseReader implements IReader
switch ($propertyName) { switch ($propertyName) {
case 'Title': case 'Title':
$docProps->setTitle(self::convertStringEncoding($propertyValue, $this->charSet)); $docProps->setTitle(self::convertStringEncoding($propertyValue, $this->charSet));
break; break;
case 'Subject': case 'Subject':
$docProps->setSubject(self::convertStringEncoding($propertyValue, $this->charSet)); $docProps->setSubject(self::convertStringEncoding($propertyValue, $this->charSet));
break; break;
case 'Author': case 'Author':
$docProps->setCreator(self::convertStringEncoding($propertyValue, $this->charSet)); $docProps->setCreator(self::convertStringEncoding($propertyValue, $this->charSet));
break; break;
case 'Created': case 'Created':
$creationDate = strtotime($propertyValue); $creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
break; break;
case 'LastAuthor': case 'LastAuthor':
$docProps->setLastModifiedBy(self::convertStringEncoding($propertyValue, $this->charSet)); $docProps->setLastModifiedBy(self::convertStringEncoding($propertyValue, $this->charSet));
break; break;
case 'LastSaved': case 'LastSaved':
$lastSaveDate = strtotime($propertyValue); $lastSaveDate = strtotime($propertyValue);
$docProps->setModified($lastSaveDate); $docProps->setModified($lastSaveDate);
break; break;
case 'Company': case 'Company':
$docProps->setCompany(self::convertStringEncoding($propertyValue, $this->charSet)); $docProps->setCompany(self::convertStringEncoding($propertyValue, $this->charSet));
break; break;
case 'Category': case 'Category':
$docProps->setCategory(self::convertStringEncoding($propertyValue, $this->charSet)); $docProps->setCategory(self::convertStringEncoding($propertyValue, $this->charSet));
break; break;
case 'Manager': case 'Manager':
$docProps->setManager(self::convertStringEncoding($propertyValue, $this->charSet)); $docProps->setManager(self::convertStringEncoding($propertyValue, $this->charSet));
break; break;
case 'Keywords': case 'Keywords':
$docProps->setKeywords(self::convertStringEncoding($propertyValue, $this->charSet)); $docProps->setKeywords(self::convertStringEncoding($propertyValue, $this->charSet));
break; break;
case 'Description': case 'Description':
$docProps->setDescription(self::convertStringEncoding($propertyValue, $this->charSet)); $docProps->setDescription(self::convertStringEncoding($propertyValue, $this->charSet));
break; break;
} }
} }
@ -389,22 +401,27 @@ class Xml extends BaseReader implements IReader
case 'string': case 'string':
$propertyType = Properties::PROPERTY_TYPE_STRING; $propertyType = Properties::PROPERTY_TYPE_STRING;
$propertyValue = trim($propertyValue); $propertyValue = trim($propertyValue);
break; break;
case 'boolean': case 'boolean':
$propertyType = Properties::PROPERTY_TYPE_BOOLEAN; $propertyType = Properties::PROPERTY_TYPE_BOOLEAN;
$propertyValue = (bool) $propertyValue; $propertyValue = (bool) $propertyValue;
break; break;
case 'integer': case 'integer':
$propertyType = Properties::PROPERTY_TYPE_INTEGER; $propertyType = Properties::PROPERTY_TYPE_INTEGER;
$propertyValue = (int) $propertyValue; $propertyValue = (int) $propertyValue;
break; break;
case 'float': case 'float':
$propertyType = Properties::PROPERTY_TYPE_FLOAT; $propertyType = Properties::PROPERTY_TYPE_FLOAT;
$propertyValue = (float) $propertyValue; $propertyValue = (float) $propertyValue;
break; break;
case 'dateTime.tz': case 'dateTime.tz':
$propertyType = Properties::PROPERTY_TYPE_DATE; $propertyType = Properties::PROPERTY_TYPE_DATE;
$propertyValue = strtotime(trim($propertyValue)); $propertyValue = strtotime(trim($propertyValue));
break; break;
} }
$docProps->setCustomProperty($propertyName, $propertyValue, $propertyType); $docProps->setCustomProperty($propertyName, $propertyValue, $propertyType);
@ -426,17 +443,21 @@ class Xml extends BaseReader implements IReader
if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) { if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) {
$this->styles[$styleID]['alignment']['vertical'] = $styleAttributeValue; $this->styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
} }
break; break;
case 'Horizontal': case 'Horizontal':
if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) { if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) {
$this->styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue; $this->styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
} }
break; break;
case 'WrapText': case 'WrapText':
$this->styles[$styleID]['alignment']['wrapText'] = true; $this->styles[$styleID]['alignment']['wrapText'] = true;
break; break;
} }
} }
break; break;
case 'Borders': case 'Borders':
foreach ($styleData->Border as $borderStyle) { foreach ($styleData->Border as $borderStyle) {
@ -446,15 +467,18 @@ class Xml extends BaseReader implements IReader
switch ($borderStyleKey) { switch ($borderStyleKey) {
case 'LineStyle': case 'LineStyle':
$thisBorder['borderStyle'] = Border::BORDER_MEDIUM; $thisBorder['borderStyle'] = Border::BORDER_MEDIUM;
break; break;
case 'Weight': case 'Weight':
break; break;
case 'Position': case 'Position':
$borderPosition = strtolower($borderStyleValue); $borderPosition = strtolower($borderStyleValue);
break; break;
case 'Color': case 'Color':
$borderColour = substr($borderStyleValue, 1); $borderColour = substr($borderStyleValue, 1);
$thisBorder['color']['rgb'] = $borderColour; $thisBorder['color']['rgb'] = $borderColour;
break; break;
} }
} }
@ -464,6 +488,7 @@ class Xml extends BaseReader implements IReader
} }
} }
} }
break; break;
case 'Font': case 'Font':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
@ -471,38 +496,48 @@ class Xml extends BaseReader implements IReader
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'FontName': case 'FontName':
$this->styles[$styleID]['font']['name'] = $styleAttributeValue; $this->styles[$styleID]['font']['name'] = $styleAttributeValue;
break; break;
case 'Size': case 'Size':
$this->styles[$styleID]['font']['size'] = $styleAttributeValue; $this->styles[$styleID]['font']['size'] = $styleAttributeValue;
break; break;
case 'Color': case 'Color':
$this->styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue, 1); $this->styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue, 1);
break; break;
case 'Bold': case 'Bold':
$this->styles[$styleID]['font']['bold'] = true; $this->styles[$styleID]['font']['bold'] = true;
break; break;
case 'Italic': case 'Italic':
$this->styles[$styleID]['font']['italic'] = true; $this->styles[$styleID]['font']['italic'] = true;
break; break;
case 'Underline': case 'Underline':
if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) { if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) {
$this->styles[$styleID]['font']['underline'] = $styleAttributeValue; $this->styles[$styleID]['font']['underline'] = $styleAttributeValue;
} }
break; break;
} }
} }
break; break;
case 'Interior': case 'Interior':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'Color': case 'Color':
$this->styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue, 1); $this->styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue, 1);
break; break;
case 'Pattern': case 'Pattern':
$this->styles[$styleID]['fill']['fillType'] = strtolower($styleAttributeValue); $this->styles[$styleID]['fill']['fillType'] = strtolower($styleAttributeValue);
break; break;
} }
} }
break; break;
case 'NumberFormat': case 'NumberFormat':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
@ -510,16 +545,19 @@ class Xml extends BaseReader implements IReader
switch ($styleAttributeValue) { switch ($styleAttributeValue) {
case 'Short Date': case 'Short Date':
$styleAttributeValue = 'dd/mm/yyyy'; $styleAttributeValue = 'dd/mm/yyyy';
break; break;
} }
if ($styleAttributeValue > '') { if ($styleAttributeValue > '') {
$this->styles[$styleID]['numberFormat']['formatCode'] = $styleAttributeValue; $this->styles[$styleID]['numberFormat']['formatCode'] = $styleAttributeValue;
} }
} }
break; break;
case 'Protection': case 'Protection':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
} }
break; break;
} }
} }
@ -583,6 +621,7 @@ class Xml extends BaseReader implements IReader
if ($this->getReadFilter() !== null) { if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
++$columnID; ++$columnID;
continue; continue;
} }
} }
@ -634,6 +673,7 @@ class Xml extends BaseReader implements IReader
case 'String': case 'String':
$cellValue = self::convertStringEncoding($cellValue, $this->charSet); $cellValue = self::convertStringEncoding($cellValue, $this->charSet);
$type = Cell\DataType::TYPE_STRING; $type = Cell\DataType::TYPE_STRING;
break; break;
case 'Number': case 'Number':
$type = Cell\DataType::TYPE_NUMERIC; $type = Cell\DataType::TYPE_NUMERIC;
@ -641,17 +681,21 @@ class Xml extends BaseReader implements IReader
if (floor($cellValue) == $cellValue) { if (floor($cellValue) == $cellValue) {
$cellValue = (int) $cellValue; $cellValue = (int) $cellValue;
} }
break; break;
case 'Boolean': case 'Boolean':
$type = Cell\DataType::TYPE_BOOL; $type = Cell\DataType::TYPE_BOOL;
$cellValue = ($cellValue != 0); $cellValue = ($cellValue != 0);
break; break;
case 'DateTime': case 'DateTime':
$type = Cell\DataType::TYPE_NUMERIC; $type = Cell\DataType::TYPE_NUMERIC;
$cellValue = Date::PHPToExcel(strtotime($cellValue)); $cellValue = Date::PHPToExcel(strtotime($cellValue));
break; break;
case 'Error': case 'Error':
$type = Cell\DataType::TYPE_ERROR; $type = Cell\DataType::TYPE_ERROR;
break; break;
} }
} }

View File

@ -122,7 +122,7 @@ class ReferenceHelper
*/ */
private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols) private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)
{ {
list($cellColumn, $cellRow) = Cell::coordinateFromString($cellAddress); [$cellColumn, $cellRow] = Cell::coordinateFromString($cellAddress);
$cellColumnIndex = Cell::columnIndexFromString($cellColumn); $cellColumnIndex = Cell::columnIndexFromString($cellColumn);
// Is cell within the range of rows/columns if we're deleting // Is cell within the range of rows/columns if we're deleting
if ($pNumRows < 0 && if ($pNumRows < 0 &&
@ -309,7 +309,7 @@ class ReferenceHelper
if (!empty($aColumnDimensions)) { if (!empty($aColumnDimensions)) {
foreach ($aColumnDimensions as $objColumnDimension) { foreach ($aColumnDimensions as $objColumnDimension) {
$newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows);
list($newReference) = Cell::coordinateFromString($newReference); [$newReference] = Cell::coordinateFromString($newReference);
if ($objColumnDimension->getColumnIndex() != $newReference) { if ($objColumnDimension->getColumnIndex() != $newReference) {
$objColumnDimension->setColumnIndex($newReference); $objColumnDimension->setColumnIndex($newReference);
} }
@ -334,7 +334,7 @@ class ReferenceHelper
if (!empty($aRowDimensions)) { if (!empty($aRowDimensions)) {
foreach ($aRowDimensions as $objRowDimension) { foreach ($aRowDimensions as $objRowDimension) {
$newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows);
list(, $newReference) = Cell::coordinateFromString($newReference); [, $newReference] = Cell::coordinateFromString($newReference);
if ($objRowDimension->getRowIndex() != $newReference) { if ($objRowDimension->getRowIndex() != $newReference) {
$objRowDimension->setRowIndex($newReference); $objRowDimension->setRowIndex($newReference);
} }
@ -370,7 +370,7 @@ class ReferenceHelper
// Get coordinate of $pBefore // Get coordinate of $pBefore
$beforeColumn = 'A'; $beforeColumn = 'A';
$beforeRow = 1; $beforeRow = 1;
list($beforeColumn, $beforeRow) = Cell::coordinateFromString($pBefore); [$beforeColumn, $beforeRow] = Cell::coordinateFromString($pBefore);
$beforeColumnIndex = Cell::columnIndexFromString($beforeColumn); $beforeColumnIndex = Cell::columnIndexFromString($beforeColumn);
// Clear cells if we are removing columns or rows // Clear cells if we are removing columns or rows
@ -529,7 +529,7 @@ class ReferenceHelper
if (count($autoFilterColumns) > 0) { if (count($autoFilterColumns) > 0) {
sscanf($pBefore, '%[A-Z]%d', $column, $row); sscanf($pBefore, '%[A-Z]%d', $column, $row);
$columnIndex = Cell::columnIndexFromString($column); $columnIndex = Cell::columnIndexFromString($column);
list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($autoFilterRange); [$rangeStart, $rangeEnd] = Cell::rangeBoundaries($autoFilterRange);
if ($columnIndex <= $rangeEnd[0]) { if ($columnIndex <= $rangeEnd[0]) {
if ($pNumCols < 0) { if ($pNumCols < 0) {
// If we're actually deleting any columns that fall within the autofilter range, // 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)) { if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2] . '!' : ''; $toString = ($match[2] > '') ? $match[2] . '!' : '';
$toString .= $modified3 . ':' . $modified4; $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 // 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; $column = Cell::columnIndexFromString(trim($column, '$')) + 100000;
$row = trim($row, '$') + 10000000; $row = trim($row, '$') + 10000000;
@ -722,7 +722,7 @@ class ReferenceHelper
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) { if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2] . '!' : ''; $toString = ($match[2] > '') ? $match[2] . '!' : '';
$toString .= $modified3; $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 // 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; $column = Cell::columnIndexFromString(trim($column, '$')) + 100000;
$row = trim($row, '$') + 10000000; $row = trim($row, '$') + 10000000;
@ -846,6 +846,7 @@ class ReferenceHelper
// Recreate range string // Recreate range string
return Cell::buildRange($range); return Cell::buildRange($range);
} }
throw new Exception('Only cell ranges may be passed to this method.'); 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) { if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {
// Get coordinate of $pBefore // Get coordinate of $pBefore
list($beforeColumn, $beforeRow) = Cell::coordinateFromString($pBefore); [$beforeColumn, $beforeRow] = Cell::coordinateFromString($pBefore);
// Get coordinate of $pCellReference // Get coordinate of $pCellReference
list($newColumn, $newRow) = Cell::coordinateFromString($pCellReference); [$newColumn, $newRow] = Cell::coordinateFromString($pCellReference);
// Verify which parts should be updated // Verify which parts should be updated
$updateColumn = (($newColumn[0] != '$') && ($beforeColumn[0] != '$') && (Cell::columnIndexFromString($newColumn) >= Cell::columnIndexFromString($beforeColumn))); $updateColumn = (($newColumn[0] != '$') && ($beforeColumn[0] != '$') && (Cell::columnIndexFromString($newColumn) >= Cell::columnIndexFromString($beforeColumn)));
@ -887,6 +888,7 @@ class ReferenceHelper
// Return new reference // Return new reference
return $newColumn . $newRow; return $newColumn . $newRow;
} }
throw new Exception('Only single cell references may be passed to this method.'); 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 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 * currently configured to use
* e.g. \PhpOffice\PhpSpreadsheet\Settings::CHART_RENDERER_JPGRAPH * 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 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 * currently configured to use
*/ */
public static function getChartRendererPath() 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 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 * currently configured to use
* e.g. \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF, * e.g. \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF,
* \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF * \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF
@ -188,7 +188,7 @@ class Settings
*/ */
public static function setLibXmlLoaderOptions($options) public static function setLibXmlLoaderOptions($options)
{ {
if (is_null($options) && defined('LIBXML_DTDLOAD')) { if ($options === null && defined('LIBXML_DTDLOAD')) {
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR; $options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
} }
self::$libXmlLoaderOptions = $options; self::$libXmlLoaderOptions = $options;
@ -202,9 +202,9 @@ class Settings
*/ */
public static function getLibXmlLoaderOptions() 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); self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
} elseif (is_null(self::$libXmlLoaderOptions)) { } elseif (self::$libXmlLoaderOptions === null) {
self::$libXmlLoaderOptions = true; self::$libXmlLoaderOptions = true;
} }

View File

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

View File

@ -97,7 +97,7 @@ class Date
/** /**
* Set the Default timezone to use for dates. * 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 * @throws \Exception
* *
@ -132,7 +132,7 @@ class Date
/** /**
* Validate a timezone. * 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 * @throws \Exception
* *
@ -146,14 +146,15 @@ class Date
} elseif (is_string($timeZone)) { } elseif (is_string($timeZone)) {
return new DateTimeZone($timeZone); return new DateTimeZone($timeZone);
} }
throw new \Exception('Invalid timezone'); throw new \Exception('Invalid timezone');
} }
/** /**
* Convert a MS serialized datetime value from Excel to a PHP Date/Time object. * 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 float|int $excelTimestamp MS Excel serialized date/time value
* @param DateTimeZone|string|null $timeZone The timezone to assume for the Excel timestamp, * @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 * if you don't want to treat it as a UTC value
* Use the default (UST) unless you absolutely need a conversion * 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. * Convert a MS serialized datetime value from Excel to a unix timestamp.
* *
* @param int|float $excelTimestamp MS Excel serialized date/time value * @param float|int $excelTimestamp MS Excel serialized date/time value
* @param DateTimeZone|string|null $timeZone The timezone to assume for the Excel timestamp, * @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 * if you don't want to treat it as a UTC value
* Use the default (UST) unless you absolutely need a conversion * 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 * @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 * or boolean FALSE on failure
*/ */
public static function PHPToExcel($dateValue) 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' * @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) public static function stringToExcel($dateValue)
{ {

View File

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

View File

@ -31,7 +31,7 @@ class SpgrContainer
/** /**
* Get the parent Shape Group Container if any. * 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() public function getParent()
{ {

View File

@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\RichText;
class Font class Font
{ {
/* Methods for resolving autosize value */ // Methods for resolving autosize value
const AUTOSIZE_METHOD_APPROX = 'approx'; const AUTOSIZE_METHOD_APPROX = 'approx';
const AUTOSIZE_METHOD_EXACT = 'exact'; const AUTOSIZE_METHOD_EXACT = 'exact';
@ -219,7 +219,7 @@ class Font
* @param \PhpOffice\PhpSpreadsheet\Style\Font $font Font object * @param \PhpOffice\PhpSpreadsheet\Style\Font $font Font object
* @param RichText|string $cellText Text to calculate width * @param RichText|string $cellText Text to calculate width
* @param int $rotation Rotation angle * @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 * @return int Column width
*/ */
@ -245,6 +245,7 @@ class Font
$approximate = self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX; $approximate = self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX;
if (!$approximate) { if (!$approximate) {
$columnWidthAdjust = ceil(self::getTextWidthPixelsExact('n', $font, 0) * 1.07); $columnWidthAdjust = ceil(self::getTextWidthPixelsExact('n', $font, 0) * 1.07);
try { try {
// Width of text in pixels excl. padding // Width of text in pixels excl. padding
// and addition because Excel adds some padding, just use approx width of 'n' glyph // 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) $bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
: ($italic ? self::ARIAL_ITALIC : self::ARIAL) : ($italic ? self::ARIAL_ITALIC : self::ARIAL)
); );
break; break;
case 'Calibri': case 'Calibri':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD) $bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
: ($italic ? self::CALIBRI_ITALIC : self::CALIBRI) : ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
); );
break; break;
case 'Courier New': case 'Courier New':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD) $bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
: ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW) : ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
); );
break; break;
case 'Comic Sans MS': case 'Comic Sans MS':
$fontFile = ( $fontFile = (
$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS $bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
); );
break; break;
case 'Georgia': case 'Georgia':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD) $bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
: ($italic ? self::GEORGIA_ITALIC : self::GEORGIA) : ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
); );
break; break;
case 'Impact': case 'Impact':
$fontFile = self::IMPACT; $fontFile = self::IMPACT;
break; break;
case 'Liberation Sans': case 'Liberation Sans':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD) $bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
: ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS) : ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
); );
break; break;
case 'Lucida Console': case 'Lucida Console':
$fontFile = self::LUCIDA_CONSOLE; $fontFile = self::LUCIDA_CONSOLE;
break; break;
case 'Lucida Sans Unicode': case 'Lucida Sans Unicode':
$fontFile = self::LUCIDA_SANS_UNICODE; $fontFile = self::LUCIDA_SANS_UNICODE;
break; break;
case 'Microsoft Sans Serif': case 'Microsoft Sans Serif':
$fontFile = self::MICROSOFT_SANS_SERIF; $fontFile = self::MICROSOFT_SANS_SERIF;
break; break;
case 'Palatino Linotype': case 'Palatino Linotype':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD) $bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
: ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE) : ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
); );
break; break;
case 'Symbol': case 'Symbol':
$fontFile = self::SYMBOL; $fontFile = self::SYMBOL;
break; break;
case 'Tahoma': case 'Tahoma':
$fontFile = ( $fontFile = (
$bold ? self::TAHOMA_BOLD : self::TAHOMA $bold ? self::TAHOMA_BOLD : self::TAHOMA
); );
break; break;
case 'Times New Roman': case 'Times New Roman':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD) $bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
: ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN) : ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
); );
break; break;
case 'Trebuchet MS': case 'Trebuchet MS':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD) $bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
: ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS) : ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
); );
break; break;
case 'Verdana': case 'Verdana':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD) $bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
: ($italic ? self::VERDANA_ITALIC : self::VERDANA) : ($italic ? self::VERDANA_ITALIC : self::VERDANA)
); );
break; break;
default: default:
throw new PhpSpreadsheetException('Unknown font name "' . $name . '". Cannot map to TrueType font file'); throw new PhpSpreadsheetException('Unknown font name "' . $name . '". Cannot map to TrueType font file');
@ -578,134 +595,166 @@ class Font
case 10: case 10:
// inspection of Arial 10 workbook says 12.75pt ~17px // inspection of Arial 10 workbook says 12.75pt ~17px
$rowHeight = 12.75; $rowHeight = 12.75;
break; break;
case 9: case 9:
// inspection of Arial 9 workbook says 12.00pt ~16px // inspection of Arial 9 workbook says 12.00pt ~16px
$rowHeight = 12; $rowHeight = 12;
break; break;
case 8: case 8:
// inspection of Arial 8 workbook says 11.25pt ~15px // inspection of Arial 8 workbook says 11.25pt ~15px
$rowHeight = 11.25; $rowHeight = 11.25;
break; break;
case 7: case 7:
// inspection of Arial 7 workbook says 9.00pt ~12px // inspection of Arial 7 workbook says 9.00pt ~12px
$rowHeight = 9; $rowHeight = 9;
break; break;
case 6: case 6:
case 5: case 5:
// inspection of Arial 5,6 workbook says 8.25pt ~11px // inspection of Arial 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25; $rowHeight = 8.25;
break; break;
case 4: case 4:
// inspection of Arial 4 workbook says 6.75pt ~9px // inspection of Arial 4 workbook says 6.75pt ~9px
$rowHeight = 6.75; $rowHeight = 6.75;
break; break;
case 3: case 3:
// inspection of Arial 3 workbook says 6.00pt ~8px // inspection of Arial 3 workbook says 6.00pt ~8px
$rowHeight = 6; $rowHeight = 6;
break; break;
case 2: case 2:
case 1: case 1:
// inspection of Arial 1,2 workbook says 5.25pt ~7px // inspection of Arial 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25; $rowHeight = 5.25;
break; break;
default: default:
// use Arial 10 workbook as an approximation, extrapolation // use Arial 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10; $rowHeight = 12.75 * $font->getSize() / 10;
break; break;
} }
break; break;
case 'Calibri': case 'Calibri':
switch ($font->getSize()) { switch ($font->getSize()) {
case 11: case 11:
// inspection of Calibri 11 workbook says 15.00pt ~20px // inspection of Calibri 11 workbook says 15.00pt ~20px
$rowHeight = 15; $rowHeight = 15;
break; break;
case 10: case 10:
// inspection of Calibri 10 workbook says 12.75pt ~17px // inspection of Calibri 10 workbook says 12.75pt ~17px
$rowHeight = 12.75; $rowHeight = 12.75;
break; break;
case 9: case 9:
// inspection of Calibri 9 workbook says 12.00pt ~16px // inspection of Calibri 9 workbook says 12.00pt ~16px
$rowHeight = 12; $rowHeight = 12;
break; break;
case 8: case 8:
// inspection of Calibri 8 workbook says 11.25pt ~15px // inspection of Calibri 8 workbook says 11.25pt ~15px
$rowHeight = 11.25; $rowHeight = 11.25;
break; break;
case 7: case 7:
// inspection of Calibri 7 workbook says 9.00pt ~12px // inspection of Calibri 7 workbook says 9.00pt ~12px
$rowHeight = 9; $rowHeight = 9;
break; break;
case 6: case 6:
case 5: case 5:
// inspection of Calibri 5,6 workbook says 8.25pt ~11px // inspection of Calibri 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25; $rowHeight = 8.25;
break; break;
case 4: case 4:
// inspection of Calibri 4 workbook says 6.75pt ~9px // inspection of Calibri 4 workbook says 6.75pt ~9px
$rowHeight = 6.75; $rowHeight = 6.75;
break; break;
case 3: case 3:
// inspection of Calibri 3 workbook says 6.00pt ~8px // inspection of Calibri 3 workbook says 6.00pt ~8px
$rowHeight = 6.00; $rowHeight = 6.00;
break; break;
case 2: case 2:
case 1: case 1:
// inspection of Calibri 1,2 workbook says 5.25pt ~7px // inspection of Calibri 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25; $rowHeight = 5.25;
break; break;
default: default:
// use Calibri 11 workbook as an approximation, extrapolation // use Calibri 11 workbook as an approximation, extrapolation
$rowHeight = 15 * $font->getSize() / 11; $rowHeight = 15 * $font->getSize() / 11;
break; break;
} }
break; break;
case 'Verdana': case 'Verdana':
switch ($font->getSize()) { switch ($font->getSize()) {
case 10: case 10:
// inspection of Verdana 10 workbook says 12.75pt ~17px // inspection of Verdana 10 workbook says 12.75pt ~17px
$rowHeight = 12.75; $rowHeight = 12.75;
break; break;
case 9: case 9:
// inspection of Verdana 9 workbook says 11.25pt ~15px // inspection of Verdana 9 workbook says 11.25pt ~15px
$rowHeight = 11.25; $rowHeight = 11.25;
break; break;
case 8: case 8:
// inspection of Verdana 8 workbook says 10.50pt ~14px // inspection of Verdana 8 workbook says 10.50pt ~14px
$rowHeight = 10.50; $rowHeight = 10.50;
break; break;
case 7: case 7:
// inspection of Verdana 7 workbook says 9.00pt ~12px // inspection of Verdana 7 workbook says 9.00pt ~12px
$rowHeight = 9.00; $rowHeight = 9.00;
break; break;
case 6: case 6:
case 5: case 5:
// inspection of Verdana 5,6 workbook says 8.25pt ~11px // inspection of Verdana 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25; $rowHeight = 8.25;
break; break;
case 4: case 4:
// inspection of Verdana 4 workbook says 6.75pt ~9px // inspection of Verdana 4 workbook says 6.75pt ~9px
$rowHeight = 6.75; $rowHeight = 6.75;
break; break;
case 3: case 3:
// inspection of Verdana 3 workbook says 6.00pt ~8px // inspection of Verdana 3 workbook says 6.00pt ~8px
$rowHeight = 6; $rowHeight = 6;
break; break;
case 2: case 2:
case 1: case 1:
// inspection of Verdana 1,2 workbook says 5.25pt ~7px // inspection of Verdana 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25; $rowHeight = 5.25;
break; break;
default: default:
// use Verdana 10 workbook as an approximation, extrapolation // use Verdana 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10; $rowHeight = 12.75 * $font->getSize() / 10;
break; break;
} }
break; break;
default: default:
// just use Calibri as an approximation // just use Calibri as an approximation
$rowHeight = 15 * $font->getSize() / 11; $rowHeight = 15 * $font->getSize() / 11;
break; break;
} }

View File

@ -139,8 +139,10 @@ class CholeskyDecomposition
return new Matrix($X, $this->m, $nx); return new Matrix($X, $this->m, $nx);
} }
throw new CalculationException(Matrix::MATRIX_SPD_EXCEPTION); throw new CalculationException(Matrix::MATRIX_SPD_EXCEPTION);
} }
throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION); throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION);
} }
} }

View File

@ -233,6 +233,7 @@ class LUDecomposition
return $d; return $d;
} }
throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION); throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION);
} }
@ -277,8 +278,10 @@ class LUDecomposition
return $X; return $X;
} }
throw new CalculationException(self::MATRIX_SINGULAR_EXCEPTION); throw new CalculationException(self::MATRIX_SINGULAR_EXCEPTION);
} }
throw new CalculationException(self::MATRIX_SQUARE_EXCEPTION); throw new CalculationException(self::MATRIX_SQUARE_EXCEPTION);
} }
} }

View File

@ -62,18 +62,21 @@ class Matrix
$this->m = count($args[0]); $this->m = count($args[0]);
$this->n = count($args[0][0]); $this->n = count($args[0][0]);
$this->A = $args[0]; $this->A = $args[0];
break; break;
//Square matrix - n x n //Square matrix - n x n
case 'integer': case 'integer':
$this->m = $args[0]; $this->m = $args[0];
$this->n = $args[0]; $this->n = $args[0];
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
break; break;
//Rectangular matrix - m x n //Rectangular matrix - m x n
case 'integer,integer': case 'integer,integer':
$this->m = $args[0]; $this->m = $args[0];
$this->n = $args[1]; $this->n = $args[1];
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
break; break;
//Rectangular matrix - m x n initialized from packed array //Rectangular matrix - m x n initialized from packed array
case 'array,integer': case 'array,integer':
@ -92,6 +95,7 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARRAY_LENGTH_EXCEPTION); throw new CalculationException(self::ARRAY_LENGTH_EXCEPTION);
} }
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -167,7 +171,7 @@ class Matrix
switch ($match) { switch ($match) {
//A($i0...; $j0...) //A($i0...; $j0...)
case 'integer,integer': case 'integer,integer':
list($i0, $j0) = $args; [$i0, $j0] = $args;
if ($i0 >= 0) { if ($i0 >= 0) {
$m = $this->m - $i0; $m = $this->m - $i0;
} else { } else {
@ -189,7 +193,7 @@ class Matrix
break; break;
//A($i0...$iF; $j0...$jF) //A($i0...$iF; $j0...$jF)
case 'integer,integer,integer,integer': case 'integer,integer,integer,integer':
list($i0, $iF, $j0, $jF) = $args; [$i0, $iF, $j0, $jF] = $args;
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) {
$m = $iF - $i0; $m = $iF - $i0;
} else { } else {
@ -211,7 +215,7 @@ class Matrix
break; break;
//$R = array of row indices; $C = array of column indices //$R = array of row indices; $C = array of column indices
case 'array,array': case 'array,array':
list($RL, $CL) = $args; [$RL, $CL] = $args;
if (count($RL) > 0) { if (count($RL) > 0) {
$m = count($RL); $m = count($RL);
} else { } else {
@ -233,7 +237,7 @@ class Matrix
break; break;
//A($i0...$iF); $CL = array of column indices //A($i0...$iF); $CL = array of column indices
case 'integer,integer,array': case 'integer,integer,array':
list($i0, $iF, $CL) = $args; [$i0, $iF, $CL] = $args;
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) {
$m = $iF - $i0; $m = $iF - $i0;
} else { } else {
@ -255,7 +259,7 @@ class Matrix
break; break;
//$RL = array of row indices //$RL = array of row indices
case 'array,integer,integer': case 'array,integer,integer':
list($RL, $j0, $jF) = $args; [$RL, $j0, $jF] = $args;
if (count($RL) > 0) { if (count($RL) > 0) {
$m = count($RL); $m = count($RL);
} else { } else {
@ -299,8 +303,10 @@ class Matrix
if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) { if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) {
return true; return true;
} }
throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION); throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION);
} }
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
@ -380,6 +386,7 @@ class Matrix
return $this->getMatrix($i0, 0, $i0 + 1, $this->n); return $this->getMatrix($i0, 0, $i0 + 1, $this->n);
} }
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
@ -402,6 +409,7 @@ class Matrix
return $this->getMatrix(0, $j0, $this->m, $j0 + 1); return $this->getMatrix(0, $j0, $this->m, $j0 + 1);
} }
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
@ -476,9 +484,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -493,6 +503,7 @@ class Matrix
return $M; return $M;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -517,9 +528,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -548,6 +561,7 @@ class Matrix
return $this; return $this;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -572,9 +586,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -589,6 +605,7 @@ class Matrix
return $M; return $M;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -613,9 +630,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -644,6 +663,7 @@ class Matrix
return $this; return $this;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -669,9 +689,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -686,6 +708,7 @@ class Matrix
return $M; return $M;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -711,9 +734,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -742,6 +767,7 @@ class Matrix
return $this; return $this;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -767,9 +793,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -803,6 +831,7 @@ class Matrix
return $M; return $M;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -828,9 +857,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -845,6 +876,7 @@ class Matrix
return $M; return $M;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -870,9 +902,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -887,6 +921,7 @@ class Matrix
return $M; return $M;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -912,9 +947,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -929,6 +966,7 @@ class Matrix
return $M; return $M;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -971,6 +1009,7 @@ class Matrix
return $C; return $C;
} }
throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION); throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION);
case 'array': case 'array':
$B = new self($args[0]); $B = new self($args[0]);
@ -988,6 +1027,7 @@ class Matrix
return $C; return $C;
} }
throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION); throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION);
case 'integer': case 'integer':
$C = new self($this->A); $C = new self($this->A);
@ -1045,9 +1085,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -1076,6 +1118,7 @@ class Matrix
return $this; return $this;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }
@ -1100,9 +1143,11 @@ class Matrix
} else { } else {
throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
} }
break; break;
case 'array': case 'array':
$M = new self($args[0]); $M = new self($args[0]);
break; break;
default: default:
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
@ -1117,6 +1162,7 @@ class Matrix
return $this; return $this;
} }
throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
} }

View File

@ -247,8 +247,10 @@ class QRDecomposition
return $X->getMatrix(0, $this->n - 1, 0, $nx); return $X->getMatrix(0, $this->n - 1, 0, $nx);
} }
throw new CalculationException(self::MATRIX_RANK_EXCEPTION); throw new CalculationException(self::MATRIX_RANK_EXCEPTION);
} }
throw new CalculationException(Matrix::MATRIX_DIMENSION_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]))) { if (abs($e[$k]) <= $eps * (abs($this->s[$k]) + abs($this->s[$k + 1]))) {
$e[$k] = 0.0; $e[$k] = 0.0;
break; break;
} }
} }
@ -276,6 +277,7 @@ class SingularValueDecomposition
$t = ($ks != $p ? abs($e[$ks]) : 0.) + ($ks != $k + 1 ? abs($e[$ks - 1]) : 0.); $t = ($ks != $p ? abs($e[$ks]) : 0.) + ($ks != $k + 1 ? abs($e[$ks - 1]) : 0.);
if (abs($this->s[$ks]) <= $eps * $t) { if (abs($this->s[$ks]) <= $eps * $t) {
$this->s[$ks] = 0.0; $this->s[$ks] = 0.0;
break; break;
} }
} }
@ -313,6 +315,7 @@ class SingularValueDecomposition
} }
} }
} }
break; break;
// Split at negligible s(k). // Split at negligible s(k).
case 2: case 2:
@ -333,6 +336,7 @@ class SingularValueDecomposition
} }
} }
} }
break; break;
// Perform one qr step. // Perform one qr step.
case 3: case 3:
@ -392,6 +396,7 @@ class SingularValueDecomposition
} }
$e[$p - 2] = $f; $e[$p - 2] = $f;
$iter = $iter + 1; $iter = $iter + 1;
break; break;
// Convergence. // Convergence.
case 4: case 4:
@ -430,6 +435,7 @@ class SingularValueDecomposition
} }
$iter = 0; $iter = 0;
--$p; --$p;
break; break;
} // end switch } // end switch
} // end while } // end while

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Shared; namespace PhpOffice\PhpSpreadsheet\Shared;
/* vim: set expandtab tabstop=4 shiftwidth=4: */ // vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | PHP Version 4 | // | PHP Version 4 |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
@ -245,7 +245,7 @@ class OLE
*/ */
private static function _readInt1($fh) private static function _readInt1($fh)
{ {
list(, $tmp) = unpack('c', fread($fh, 1)); [, $tmp] = unpack('c', fread($fh, 1));
return $tmp; return $tmp;
} }
@ -259,7 +259,7 @@ class OLE
*/ */
private static function _readInt2($fh) private static function _readInt2($fh)
{ {
list(, $tmp) = unpack('v', fread($fh, 2)); [, $tmp] = unpack('v', fread($fh, 2));
return $tmp; return $tmp;
} }
@ -273,7 +273,7 @@ class OLE
*/ */
private static function _readInt4($fh) private static function _readInt4($fh)
{ {
list(, $tmp) = unpack('V', fread($fh, 4)); [, $tmp] = unpack('V', fread($fh, 4));
return $tmp; return $tmp;
} }
@ -301,12 +301,15 @@ class OLE
case self::OLE_PPS_TYPE_ROOT: case self::OLE_PPS_TYPE_ROOT:
$pps = new OLE\PPS_Root(null, null, []); $pps = new OLE\PPS_Root(null, null, []);
$this->root = $pps; $this->root = $pps;
break; break;
case self::OLE_PPS_TYPE_DIR: case self::OLE_PPS_TYPE_DIR:
$pps = new OLE\PPS(null, null, null, null, null, null, null, null, null, []); $pps = new OLE\PPS(null, null, null, null, null, null, null, null, null, []);
break; break;
case self::OLE_PPS_TYPE_FILE: case self::OLE_PPS_TYPE_FILE:
$pps = new OLE\PPS\File($name); $pps = new OLE\PPS\File($name);
break; break;
default: default:
continue; continue;
@ -543,8 +546,8 @@ class OLE
// factor used for separating numbers into 4 bytes parts // factor used for separating numbers into 4 bytes parts
$factor = pow(2, 32); $factor = pow(2, 32);
list(, $high_part) = unpack('V', substr($string, 4, 4)); [, $high_part] = unpack('V', substr($string, 4, 4));
list(, $low_part) = unpack('V', substr($string, 0, 4)); [, $low_part] = unpack('V', substr($string, 0, 4));
$big_date = ($high_part * $factor) + $low_part; $big_date = ($high_part * $factor) + $low_part;
// translate to seconds // translate to seconds

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Shared\OLE; namespace PhpOffice\PhpSpreadsheet\Shared\OLE;
/* vim: set expandtab tabstop=4 shiftwidth=4: */ // vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | PHP Version 4 | // | PHP Version 4 |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS;
/* vim: set expandtab tabstop=4 shiftwidth=4: */ // vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | PHP Version 4 | // | PHP Version 4 |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS;
/* vim: set expandtab tabstop=4 shiftwidth=4: */ // vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | PHP Version 4 | // | PHP Version 4 |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
@ -38,7 +38,7 @@ class Root extends PPS
* *
* @var string * @var string
*/ */
protected $tempDirectory = null; protected $tempDirectory;
/** /**
* @param int $time_1st A timestamp * @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 * 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. * 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 * @throws WriterException
* *
@ -98,7 +98,7 @@ class Root extends PPS
$aList = []; $aList = [];
PPS::_savePpsSetPnt($aList, [$this]); PPS::_savePpsSetPnt($aList, [$this]);
// calculate values for header // calculate values for header
list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo); [$iSBDcnt, $iBBcnt, $iPPScnt] = $this->_calcSize($aList); //, $rhInfo);
// Save Header // Save Header
$this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt); $this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt);
@ -129,7 +129,7 @@ class Root extends PPS
public function _calcSize(&$raList) public function _calcSize(&$raList)
{ {
// Calculate Basic Setting // Calculate Basic Setting
list($iSBDcnt, $iBBcnt, $iPPScnt) = [0, 0, 0]; [$iSBDcnt, $iBBcnt, $iPPScnt] = [0, 0, 0];
$iSmallLen = 0; $iSmallLen = 0;
$iSBcnt = 0; $iSBcnt = 0;
$iCount = count($raList); $iCount = count($raList);

View File

@ -34,9 +34,9 @@ class OLERead
const START_BLOCK_POS = 0x74; const START_BLOCK_POS = 0x74;
const SIZE_POS = 0x78; const SIZE_POS = 0x78;
public $wrkbook = null; public $wrkbook;
public $summaryInformation = null; public $summaryInformation;
public $documentSummaryInformation = null; public $documentSummaryInformation;
/** /**
* Read the file. * Read the file.

View File

@ -133,7 +133,7 @@ class StringHelper
"\x1BNz" => 'œ', // 156 in CP1252 "\x1BNz" => 'œ', // 156 in CP1252
"\x1B)>" => 'ž', // 158 in CP1252 "\x1B)>" => 'ž', // 158 in CP1252
"\x1B)?" => 'Ÿ', // 159 in CP1252 "\x1B)?" => 'Ÿ', // 159 in CP1252
"\x1B*0" => ' ', // 160 in CP1252 "\x1B*0" => ' ', // 160 in CP1252
"\x1BN!" => '¡', // 161 in CP1252 "\x1BN!" => '¡', // 161 in CP1252
"\x1BN\"" => '¢', // 162 in CP1252 "\x1BN\"" => '¢', // 162 in CP1252
"\x1BN#" => '£', // 163 in CP1252 "\x1BN#" => '£', // 163 in CP1252

View File

@ -211,7 +211,7 @@ class Xls
*/ */
public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height) 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; $col_start = Cell::columnIndexFromString($column) - 1;
$row_start = $row - 1; $row_start = $row - 1;

View File

@ -137,13 +137,13 @@ class Spreadsheet
public function setMacrosCode($macroCode) public function setMacrosCode($macroCode)
{ {
$this->macrosCode = $macroCode; $this->macrosCode = $macroCode;
$this->setHasMacros(!is_null($macroCode)); $this->setHasMacros($macroCode !== null);
} }
/** /**
* Return the macros code. * Return the macros code.
* *
* @return string|null * @return null|string
*/ */
public function getMacrosCode() public function getMacrosCode()
{ {
@ -153,7 +153,7 @@ class Spreadsheet
/** /**
* Set the macros certificate. * Set the macros certificate.
* *
* @param string|null $certificate * @param null|string $certificate
*/ */
public function setMacrosCertificate($certificate) public function setMacrosCertificate($certificate)
{ {
@ -167,13 +167,13 @@ class Spreadsheet
*/ */
public function hasMacrosCertificate() public function hasMacrosCertificate()
{ {
return !is_null($this->macrosCertificate); return $this->macrosCertificate !== null;
} }
/** /**
* Return the macros certificate. * Return the macros certificate.
* *
* @return string|null * @return null|string
*/ */
public function getMacrosCertificate() public function getMacrosCertificate()
{ {
@ -198,7 +198,7 @@ class Spreadsheet
*/ */
public function setRibbonXMLData($target, $xmlData) public function setRibbonXMLData($target, $xmlData)
{ {
if (!is_null($target) && !is_null($xmlData)) { if ($target !== null && $xmlData !== null) {
$this->ribbonXMLData = ['target' => $target, 'data' => $xmlData]; $this->ribbonXMLData = ['target' => $target, 'data' => $xmlData];
} else { } else {
$this->ribbonXMLData = null; $this->ribbonXMLData = null;
@ -221,12 +221,14 @@ class Spreadsheet
switch ($what) { switch ($what) {
case 'all': case 'all':
$returnData = $this->ribbonXMLData; $returnData = $this->ribbonXMLData;
break; break;
case 'target': case 'target':
case 'data': case 'data':
if (is_array($this->ribbonXMLData) && isset($this->ribbonXMLData[$what])) { if (is_array($this->ribbonXMLData) && isset($this->ribbonXMLData[$what])) {
$returnData = $this->ribbonXMLData[$what]; $returnData = $this->ribbonXMLData[$what];
} }
break; break;
} }
@ -241,7 +243,7 @@ class Spreadsheet
*/ */
public function setRibbonBinObjects($BinObjectsNames, $BinObjectsData) public function setRibbonBinObjects($BinObjectsNames, $BinObjectsData)
{ {
if (!is_null($BinObjectsNames) && !is_null($BinObjectsData)) { if ($BinObjectsNames !== null && $BinObjectsData !== null) {
$this->ribbonBinObjects = ['names' => $BinObjectsNames, 'data' => $BinObjectsData]; $this->ribbonBinObjects = ['names' => $BinObjectsNames, 'data' => $BinObjectsData];
} else { } else {
$this->ribbonBinObjects = null; $this->ribbonBinObjects = null;
@ -276,6 +278,7 @@ class Spreadsheet
if (is_array($this->ribbonBinObjects) && isset($this->ribbonBinObjects[$what])) { if (is_array($this->ribbonBinObjects) && isset($this->ribbonBinObjects[$what])) {
$ReturnData = $this->ribbonBinObjects[$what]; $ReturnData = $this->ribbonBinObjects[$what];
} }
break; break;
case 'types': case 'types':
if (is_array($this->ribbonBinObjects) && if (is_array($this->ribbonBinObjects) &&
@ -285,6 +288,7 @@ class Spreadsheet
} else { } else {
$ReturnData = []; // the caller want an array... not null if empty $ReturnData = []; // the caller want an array... not null if empty
} }
break; break;
} }
@ -298,7 +302,7 @@ class Spreadsheet
*/ */
public function hasRibbon() public function hasRibbon()
{ {
return !is_null($this->ribbonXMLData); return $this->ribbonXMLData !== null;
} }
/** /**
@ -308,7 +312,7 @@ class Spreadsheet
*/ */
public function hasRibbonBinObjects() 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. * 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 * @throws Exception
* *
@ -492,7 +496,7 @@ class Spreadsheet
* Add sheet. * Add sheet.
* *
* @param Worksheet $pSheet * @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 * @throws Exception
* *
@ -570,6 +574,7 @@ class Spreadsheet
{ {
if (!isset($this->workSheetCollection[$pIndex])) { if (!isset($this->workSheetCollection[$pIndex])) {
$numSheets = $this->getSheetCount(); $numSheets = $this->getSheetCount();
throw new Exception( throw new Exception(
"Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}." "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. * Add external sheet.
* *
* @param Worksheet $pSheet External sheet to add * @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 * @throws Exception
* *
@ -804,9 +809,9 @@ class Spreadsheet
* Get named range. * Get named range.
* *
* @param string $namedRange * @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) public function getNamedRange($namedRange, Worksheet $pSheet = null)
{ {
@ -831,7 +836,7 @@ class Spreadsheet
* Remove named range. * Remove named range.
* *
* @param string $namedRange * @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 * @return Spreadsheet
*/ */
@ -917,7 +922,7 @@ class Spreadsheet
* *
* @param string $pValue * @param string $pValue
* *
* @return Style|false * @return false|Style
*/ */
public function getCellXfByHashCode($pValue) public function getCellXfByHashCode($pValue)
{ {
@ -954,6 +959,7 @@ class Spreadsheet
if (isset($this->cellXfCollection[0])) { if (isset($this->cellXfCollection[0])) {
return $this->cellXfCollection[0]; return $this->cellXfCollection[0];
} }
throw new Exception('No default style found for this workbook'); throw new Exception('No default style found for this workbook');
} }
@ -1037,7 +1043,7 @@ class Spreadsheet
* *
* @param string $pValue * @param string $pValue
* *
* @return Style|false * @return false|Style
*/ */
public function getCellStyleXfByHashCode($pValue) public function getCellStyleXfByHashCode($pValue)
{ {

View File

@ -199,7 +199,7 @@ class Style extends Style\Supervisor implements IComparable
$rangeA = $pRange; $rangeA = $pRange;
$rangeB = $pRange; $rangeB = $pRange;
} else { } else {
list($rangeA, $rangeB) = explode(':', $pRange); [$rangeA, $rangeB] = explode(':', $pRange);
} }
// Calculate range outer borders // Calculate range outer borders
@ -313,6 +313,7 @@ class Style extends Style\Supervisor implements IComparable
} else { } else {
unset($regionStyles['borders'][$innerEdge]); unset($regionStyles['borders'][$innerEdge]);
} }
break; break;
case 'left': case 'left':
case 'right': case 'right':
@ -322,6 +323,7 @@ class Style extends Style\Supervisor implements IComparable
} else { } else {
unset($regionStyles['borders'][$innerEdge]); unset($regionStyles['borders'][$innerEdge]);
} }
break; break;
} }
} }
@ -351,6 +353,7 @@ class Style extends Style\Supervisor implements IComparable
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
$oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true; $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true;
} }
break; break;
case 'ROW': case 'ROW':
$oldXfIndexes = []; $oldXfIndexes = [];
@ -361,6 +364,7 @@ class Style extends Style\Supervisor implements IComparable
$oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true; $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true;
} }
} }
break; break;
case 'CELL': case 'CELL':
$oldXfIndexes = []; $oldXfIndexes = [];
@ -369,6 +373,7 @@ class Style extends Style\Supervisor implements IComparable
$oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true; $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true;
} }
} }
break; break;
} }
@ -397,6 +402,7 @@ class Style extends Style\Supervisor implements IComparable
$oldXfIndex = $columnDimension->getXfIndex(); $oldXfIndex = $columnDimension->getXfIndex();
$columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]); $columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
} }
break; break;
case 'ROW': case 'ROW':
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$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 0 : $rowDimension->getXfIndex(); // row without explicit style should be formatted based on default style
$rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]); $rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
} }
break; break;
case 'CELL': case 'CELL':
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
@ -414,6 +421,7 @@ class Style extends Style\Supervisor implements IComparable
$cell->setXfIndex($newXfIndexes[$oldXfIndex]); $cell->setXfIndex($newXfIndexes[$oldXfIndex]);
} }
} }
break; break;
} }
} else { } else {

View File

@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Alignment extends Supervisor implements IComparable class Alignment extends Supervisor implements IComparable
{ {
/* Horizontal alignment styles */ // Horizontal alignment styles
const HORIZONTAL_GENERAL = 'general'; const HORIZONTAL_GENERAL = 'general';
const HORIZONTAL_LEFT = 'left'; const HORIZONTAL_LEFT = 'left';
const HORIZONTAL_RIGHT = 'right'; const HORIZONTAL_RIGHT = 'right';
@ -17,14 +17,14 @@ class Alignment extends Supervisor implements IComparable
const HORIZONTAL_FILL = 'fill'; const HORIZONTAL_FILL = 'fill';
const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only
/* Vertical alignment styles */ // Vertical alignment styles
const VERTICAL_BOTTOM = 'bottom'; const VERTICAL_BOTTOM = 'bottom';
const VERTICAL_TOP = 'top'; const VERTICAL_TOP = 'top';
const VERTICAL_CENTER = 'center'; const VERTICAL_CENTER = 'center';
const VERTICAL_JUSTIFY = 'justify'; const VERTICAL_JUSTIFY = 'justify';
const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only
/* Read order */ // Read order
const READORDER_CONTEXT = 0; const READORDER_CONTEXT = 0;
const READORDER_LTR = 1; const READORDER_LTR = 1;
const READORDER_RTL = 2; const READORDER_RTL = 2;

View File

@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Border extends Supervisor implements IComparable class Border extends Supervisor implements IComparable
{ {
/* Border style */ // Border style
const BORDER_NONE = 'none'; const BORDER_NONE = 'none';
const BORDER_DASHDOT = 'dashDot'; const BORDER_DASHDOT = 'dashDot';
const BORDER_DASHDOTDOT = 'dashDotDot'; const BORDER_DASHDOTDOT = 'dashDotDot';
@ -180,7 +180,7 @@ class Border extends Supervisor implements IComparable
/** /**
* Set Border style. * Set Border style.
* *
* @param string|bool $pValue * @param bool|string $pValue
* When passing a boolean, FALSE equates Border::BORDER_NONE * When passing a boolean, FALSE equates Border::BORDER_NONE
* and TRUE to Border::BORDER_MEDIUM * and TRUE to Border::BORDER_MEDIUM
* *

View File

@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Borders extends Supervisor implements IComparable class Borders extends Supervisor implements IComparable
{ {
/* Diagonal directions */ // Diagonal directions
const DIAGONAL_NONE = 0; const DIAGONAL_NONE = 0;
const DIAGONAL_UP = 1; const DIAGONAL_UP = 1;
const DIAGONAL_DOWN = 2; const DIAGONAL_DOWN = 2;

View File

@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Color extends Supervisor implements IComparable class Color extends Supervisor implements IComparable
{ {
/* Colors */ // Colors
const COLOR_BLACK = 'FF000000'; const COLOR_BLACK = 'FF000000';
const COLOR_WHITE = 'FFFFFFFF'; const COLOR_WHITE = 'FFFFFFFF';
const COLOR_RED = 'FFFF0000'; const COLOR_RED = 'FFFF0000';
@ -31,7 +31,7 @@ class Color extends Supervisor implements IComparable
* *
* @var string * @var string
*/ */
protected $argb = null; protected $argb;
/** /**
* Parent property name. * Parent property name.
@ -337,7 +337,7 @@ class Color extends Supervisor implements IComparable
$pIndex = (int) $pIndex; $pIndex = (int) $pIndex;
// Indexed colors // Indexed colors
if (is_null(self::$indexedColors)) { if (self::$indexedColors === null) {
self::$indexedColors = [ self::$indexedColors = [
1 => 'FF000000', // System Colour #1 - Black 1 => 'FF000000', // System Colour #1 - Black
2 => 'FFFFFFFF', // System Colour #2 - White 2 => 'FFFFFFFF', // System Colour #2 - White

View File

@ -8,14 +8,14 @@ use PhpOffice\PhpSpreadsheet\Style;
class Conditional implements IComparable class Conditional implements IComparable
{ {
/* Condition types */ // Condition types
const CONDITION_NONE = 'none'; const CONDITION_NONE = 'none';
const CONDITION_CELLIS = 'cellIs'; const CONDITION_CELLIS = 'cellIs';
const CONDITION_CONTAINSTEXT = 'containsText'; const CONDITION_CONTAINSTEXT = 'containsText';
const CONDITION_EXPRESSION = 'expression'; const CONDITION_EXPRESSION = 'expression';
const CONDITION_CONTAINSBLANKS = 'containsBlanks'; const CONDITION_CONTAINSBLANKS = 'containsBlanks';
/* Operator types */ // Operator types
const OPERATOR_NONE = ''; const OPERATOR_NONE = '';
const OPERATOR_BEGINSWITH = 'beginsWith'; const OPERATOR_BEGINSWITH = 'beginsWith';
const OPERATOR_ENDSWITH = 'endsWith'; const OPERATOR_ENDSWITH = 'endsWith';

View File

@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Fill extends Supervisor implements IComparable class Fill extends Supervisor implements IComparable
{ {
/* Fill types */ // Fill types
const FILL_NONE = 'none'; const FILL_NONE = 'none';
const FILL_SOLID = 'solid'; const FILL_SOLID = 'solid';
const FILL_GRADIENT_LINEAR = 'linear'; const FILL_GRADIENT_LINEAR = 'linear';

View File

@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\IComparable;
class Font extends Supervisor implements IComparable class Font extends Supervisor implements IComparable
{ {
/* Underline types */ // Underline types
const UNDERLINE_NONE = 'none'; const UNDERLINE_NONE = 'none';
const UNDERLINE_DOUBLE = 'double'; const UNDERLINE_DOUBLE = 'double';
const UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting'; const UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting';
@ -430,7 +430,7 @@ class Font extends Supervisor implements IComparable
/** /**
* Set Underline. * 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, * If a boolean is passed, then TRUE equates to UNDERLINE_SINGLE,
* false equates to UNDERLINE_NONE * false equates to UNDERLINE_NONE
* *

View File

@ -10,7 +10,7 @@ use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
class NumberFormat extends Supervisor implements IComparable class NumberFormat extends Supervisor implements IComparable
{ {
/* Pre-defined formats */ // Pre-defined formats
const FORMAT_GENERAL = 'General'; const FORMAT_GENERAL = 'General';
const FORMAT_TEXT = '@'; const FORMAT_TEXT = '@';
@ -253,7 +253,7 @@ class NumberFormat extends Supervisor implements IComparable
// KOR fmt 55: "yyyy/mm/dd" // KOR fmt 55: "yyyy/mm/dd"
// Built-in format codes // Built-in format codes
if (is_null(self::$builtInFormats)) { if (self::$builtInFormats === null) {
self::$builtInFormats = []; self::$builtInFormats = [];
// General // General
@ -340,7 +340,7 @@ class NumberFormat extends Supervisor implements IComparable
* *
* @param string $formatCode * @param string $formatCode
* *
* @return int|bool * @return bool|int
*/ */
public static function builtInFormatCodeIndex($formatCode) public static function builtInFormatCodeIndex($formatCode)
{ {
@ -601,6 +601,7 @@ class NumberFormat extends Supervisor implements IComparable
switch (count($sections)) { switch (count($sections)) {
case 1: case 1:
$format = $sections[0]; $format = $sections[0];
break; break;
case 2: case 2:
$format = ($value >= 0) ? $sections[0] : $sections[1]; $format = ($value >= 0) ? $sections[0] : $sections[1];
@ -621,6 +622,7 @@ class NumberFormat extends Supervisor implements IComparable
default: default:
// something is wrong, just use first section // something is wrong, just use first section
$format = $sections[0]; $format = $sections[0];
break; break;
} }
@ -722,7 +724,7 @@ class NumberFormat extends Supervisor implements IComparable
// Currency or Accounting // Currency or Accounting
$currencyFormat = $m[0]; $currencyFormat = $m[0];
$currencyCode = $m[1]; $currencyCode = $m[1];
list($currencyCode) = explode('-', $currencyCode); [$currencyCode] = explode('-', $currencyCode);
if ($currencyCode == '') { if ($currencyCode == '') {
$currencyCode = StringHelper::getCurrencyCode(); $currencyCode = StringHelper::getCurrencyCode();
} }
@ -736,7 +738,7 @@ class NumberFormat extends Supervisor implements IComparable
// Additional formatting provided by callback function // Additional formatting provided by callback function
if ($callBack !== null) { if ($callBack !== null) {
list($writerInstance, $function) = $callBack; [$writerInstance, $function] = $callBack;
$value = $writerInstance->$function($value, $formatColor); $value = $writerInstance->$function($value, $formatColor);
} }

View File

@ -8,12 +8,12 @@ use PhpOffice\PhpSpreadsheet\Collection\CellsFactory;
class Worksheet implements IComparable class Worksheet implements IComparable
{ {
/* Break types */ // Break types
const BREAK_NONE = 0; const BREAK_NONE = 0;
const BREAK_ROW = 1; const BREAK_ROW = 1;
const BREAK_COLUMN = 2; const BREAK_COLUMN = 2;
/* Sheet state */ // Sheet state
const SHEETSTATE_VISIBLE = 'visible'; const SHEETSTATE_VISIBLE = 'visible';
const SHEETSTATE_HIDDEN = 'hidden'; const SHEETSTATE_HIDDEN = 'hidden';
const SHEETSTATE_VERYHIDDEN = 'veryHidden'; const SHEETSTATE_VERYHIDDEN = 'veryHidden';
@ -65,14 +65,14 @@ class Worksheet implements IComparable
* *
* @var Worksheet\ColumnDimension * @var Worksheet\ColumnDimension
*/ */
private $defaultColumnDimension = null; private $defaultColumnDimension;
/** /**
* Collection of drawings. * Collection of drawings.
* *
* @var Worksheet\BaseDrawing[] * @var Worksheet\BaseDrawing[]
*/ */
private $drawingCollection = null; private $drawingCollection;
/** /**
* Collection of Chart objects. * Collection of Chart objects.
@ -303,7 +303,7 @@ class Worksheet implements IComparable
* *
* @var string * @var string
*/ */
private $codeName = null; private $codeName;
/** /**
* Create a new worksheet. * Create a new worksheet.
@ -524,14 +524,14 @@ class Worksheet implements IComparable
* Add chart. * Add chart.
* *
* @param Chart $pChart * @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 * @return Chart
*/ */
public function addChart(Chart $pChart, $iChartIndex = null) public function addChart(Chart $pChart, $iChartIndex = null)
{ {
$pChart->setWorksheet($this); $pChart->setWorksheet($this);
if (is_null($iChartIndex)) { if ($iChartIndex === null) {
$this->chartCollection[] = $pChart; $this->chartCollection[] = $pChart;
} else { } else {
// Insert the chart at the requested index // Insert the chart at the requested index
@ -558,7 +558,7 @@ class Worksheet implements IComparable
* *
* @throws Exception * @throws Exception
* *
* @return false|Chart * @return Chart|false
*/ */
public function getChartByIndex($index) public function getChartByIndex($index)
{ {
@ -566,7 +566,7 @@ class Worksheet implements IComparable
if ($chartCount == 0) { if ($chartCount == 0) {
return false; return false;
} }
if (is_null($index)) { if ($index === null) {
$index = --$chartCount; $index = --$chartCount;
} }
if (!isset($this->chartCollection[$index])) { if (!isset($this->chartCollection[$index])) {
@ -600,7 +600,7 @@ class Worksheet implements IComparable
* *
* @throws Exception * @throws Exception
* *
* @return false|Chart * @return Chart|false
*/ */
public function getChartByName($chartName) public function getChartByName($chartName)
{ {
@ -1287,6 +1287,7 @@ class Worksheet implements IComparable
if (!$namedRange->getLocalOnly()) { if (!$namedRange->getLocalOnly()) {
return $namedRange->getWorksheet()->cellExists($pCoordinate); return $namedRange->getWorksheet()->cellExists($pCoordinate);
} }
throw new Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle()); throw new Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
} }
} else { } else {
@ -1504,7 +1505,7 @@ class Worksheet implements IComparable
*/ */
public function getStyleByColumnAndRow($pColumn, $pRow, $pColumn2 = null, $pRow2 = null) 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; $cellRange = Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->getStyle($cellRange); return $this->getStyle($cellRange);
@ -1542,7 +1543,7 @@ class Worksheet implements IComparable
} }
// Calculate range outer borders // 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 // Make sure we can loop upwards on rows and columns
if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
@ -1582,7 +1583,7 @@ class Worksheet implements IComparable
} }
// Calculate range outer borders // 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 // Make sure we can loop upwards on rows and columns
if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
@ -1898,7 +1899,7 @@ class Worksheet implements IComparable
/** /**
* Set AutoFilter. * 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 * A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility
* *
* @throws Exception * @throws Exception
@ -2071,6 +2072,7 @@ class Worksheet implements IComparable
if ($pBefore >= 0) { if ($pBefore >= 0) {
return $this->insertNewColumnBefore(Cell::stringFromColumnIndex($pBefore), $pNumCols); return $this->insertNewColumnBefore(Cell::stringFromColumnIndex($pBefore), $pNumCols);
} }
throw new Exception('Columns can only be inserted before at least column A (0).'); 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) { if ($pColumn >= 0) {
return $this->removeColumn(Cell::stringFromColumnIndex($pColumn), $pNumCols); return $this->removeColumn(Cell::stringFromColumnIndex($pColumn), $pNumCols);
} }
throw new Exception('Columns to be deleted should at least start from column 0'); 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); $pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate);
if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) { if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) {
list($first) = Cell::splitRange($pCoordinate); [$first] = Cell::splitRange($pCoordinate);
$this->activeCell = $first[0]; $this->activeCell = $first[0];
} else { } else {
$this->activeCell = $pCoordinate; $this->activeCell = $pCoordinate;
@ -2467,7 +2470,7 @@ class Worksheet implements IComparable
} }
// start coordinate // start coordinate
list($startColumn, $startRow) = Cell::coordinateFromString($startCell); [$startColumn, $startRow] = Cell::coordinateFromString($startCell);
// Loop through $source // Loop through $source
foreach ($source as $rowData) { foreach ($source as $rowData) {
@ -2509,7 +2512,7 @@ class Worksheet implements IComparable
// Returnvalue // Returnvalue
$returnValue = []; $returnValue = [];
// Identify the range that we need to extract from the worksheet // 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); $minCol = Cell::stringFromColumnIndex($rangeStart[0] - 1);
$minRow = $rangeStart[1]; $minRow = $rangeStart[1];
$maxCol = Cell::stringFromColumnIndex($rangeEnd[0] - 1); $maxCol = Cell::stringFromColumnIndex($rangeEnd[0] - 1);
@ -2737,7 +2740,7 @@ class Worksheet implements IComparable
* Set hyperlink. * Set hyperlink.
* *
* @param string $pCellCoordinate Cell coordinate to insert hyperlink, eg: 'A1' * @param string $pCellCoordinate Cell coordinate to insert hyperlink, eg: 'A1'
* @param Cell\Hyperlink|null $pHyperlink * @param null|Cell\Hyperlink $pHyperlink
* *
* @return Worksheet * @return Worksheet
*/ */
@ -2796,7 +2799,7 @@ class Worksheet implements IComparable
* Set data validation. * Set data validation.
* *
* @param string $pCellCoordinate Cell coordinate to insert data validation, eg: 'A1' * @param string $pCellCoordinate Cell coordinate to insert data validation, eg: 'A1'
* @param Cell\DataValidation|null $pDataValidation * @param null|Cell\DataValidation $pDataValidation
* *
* @return Worksheet * @return Worksheet
*/ */
@ -3029,6 +3032,6 @@ class Worksheet implements IComparable
*/ */
public function hasCodeName() 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