Update PHP-CS-Fixer rules

This commit is contained in:
Adrien Crivelli 2020-05-18 13:49:57 +09:00
parent 38b360f912
commit fcd9f10663
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
496 changed files with 2634 additions and 2866 deletions

View File

@ -1,11 +1,8 @@
<?php <?php
$finder = PhpCsFixer\Finder::create() $finder = PhpCsFixer\Finder::create()
->exclude(['vendor', 'tests/data/Calculation']) ->exclude('vendor')
->in('samples') ->in(__DIR__);
->in('src')
->in('tests/PhpSpreadsheetTests')
;
return PhpCsFixer\Config::create() return PhpCsFixer\Config::create()
->setRiskyAllowed(true) ->setRiskyAllowed(true)
@ -13,21 +10,27 @@ return PhpCsFixer\Config::create()
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__)) ->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__))
->setRules([ ->setRules([
'align_multiline_comment' => true, 'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'], 'array_syntax' => ['syntax' => 'short'],
'backtick_to_shell_exec' => true, 'backtick_to_shell_exec' => true,
'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' => false, // Deprecated
'blank_line_before_statement' => true, 'blank_line_before_statement' => true,
'braces' => true, 'braces' => true,
'cast_spaces' => true, 'cast_spaces' => true,
'class_attributes_separation' => ['elements' => ['method', 'property']], // const are often grouped with other related const 'class_attributes_separation' => ['elements' => ['method', 'property']], // const are often grouped with other related const
'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 better support in IDE
'combine_consecutive_issets' => true, 'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true, 'combine_consecutive_unsets' => true,
'combine_nested_dirname' => true,
'comment_to_phpdoc' => true,
'compact_nullable_typehint' => true, 'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'], 'concat_space' => ['spacing' => 'one'],
'constant_case' => true,
'date_time_immutable' => false, // Break our unit tests
'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,
@ -38,39 +41,57 @@ return PhpCsFixer\Config::create()
'elseif' => true, 'elseif' => true,
'encoding' => true, 'encoding' => true,
'ereg_to_preg' => true, 'ereg_to_preg' => true,
'error_suppression' => true,
'escape_implicit_backslashes' => true, 'escape_implicit_backslashes' => true,
'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read 'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
'explicit_string_variable' => false, // I feel it makes the code actually harder to read 'explicit_string_variable' => false, // I feel it makes the code actually harder to read
'final_class' => false, // We need non-final classes
'final_internal_class' => true, 'final_internal_class' => true,
'final_public_method_for_abstract_class' => false, // We need non-final methods
'final_static_access' => true,
'fopen_flag_order' => true,
'fopen_flags' => true,
'full_opening_tag' => true, 'full_opening_tag' => true,
'fully_qualified_strict_types' => true,
'function_declaration' => true, 'function_declaration' => true,
'function_to_constant' => 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, 'global_namespace_import' => true,
'hash_to_slash_comment' => false, // Deprecated
'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_indentation' => false, // Requires PHP >= 7.3
'heredoc_to_nowdoc' => false, // Not sure about this one 'heredoc_to_nowdoc' => false, // Not sure about this one
'implode_call' => true,
'include' => true, 'include' => true,
'increment_style' => true, 'increment_style' => true,
'indentation_type' => true, 'indentation_type' => true,
'is_null' => ['use_yoda_style' => false], 'is_null' => true,
'linebreak_after_opening_tag' => true,
'line_ending' => true, 'line_ending' => true,
'linebreak_after_opening_tag' => true,
'list_syntax' => ['syntax' => 'short'], 'list_syntax' => ['syntax' => 'short'],
'logical_operators' => true,
'lowercase_cast' => true, 'lowercase_cast' => true,
'lowercase_constants' => true, 'lowercase_constants' => false, // Deprecated
'lowercase_keywords' => true, 'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true, 'magic_constant_casing' => true,
'magic_method_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_chaining_indentation' => true, 'method_chaining_indentation' => true,
'method_separation' => true, 'method_separation' => false, // Deprecated
'modernize_types_casting' => true, 'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true, 'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => false, // Micro optimization that look messy
'native_function_casing' => true, 'native_function_casing' => true,
'native_function_invocation' => false, // This is risky and seems to be micro-optimization that make code uglier so not worth it, at least for now 'native_function_invocation' => false, // I suppose this would be best, but I am still unconvinced about the visual aspect of it
'native_function_type_declaration_casing' => true,
'new_with_braces' => true, 'new_with_braces' => true,
'no_alias_functions' => true, 'no_alias_functions' => true,
'no_alternative_syntax' => true,
'no_binary_string' => true,
'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
@ -80,16 +101,15 @@ return PhpCsFixer\Config::create()
'no_empty_phpdoc' => true, 'no_empty_phpdoc' => true,
'no_empty_statement' => true, 'no_empty_statement' => true,
'no_extra_blank_lines' => true, 'no_extra_blank_lines' => true,
'no_extra_consecutive_blank_lines' => false, // Deprecated
'no_homoglyph_names' => true, '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' => false, // Deprecated
'non_printable_character' => true,
'no_null_property_initialization' => 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,
@ -97,29 +117,55 @@ return PhpCsFixer\Config::create()
'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 'no_superfluous_elseif' => false, // Might be risky on a huge code base
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'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_in_comment' => true,
'no_trailing_whitespace' => true, 'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true, 'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true, 'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true, 'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true, 'no_unreachable_default_argument_value' => true,
'no_unset_cast' => true,
'no_unset_on_property' => 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,
'non_printable_character' => true,
'normalize_index_brace' => true,
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
'not_operator_with_successor_space' => false, // idem
'nullable_type_declaration_for_default_null_value' => true,
'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,
'ordered_interfaces' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'php_unit_dedicate_assert_internal_type' => true,
'php_unit_expectation' => true,
'php_unit_fqcn_annotation' => true,
'php_unit_internal_class' => false, // Because tests are excluded from package
'php_unit_method_casing' => true,
'php_unit_mock' => true,
'php_unit_mock_short_will_return' => true,
'php_unit_namespaced' => true,
'php_unit_no_expectation_annotation' => true,
'php_unit_ordered_covers' => true,
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_size_class' => false, // That seems extra work to maintain for little benefits
'php_unit_strict' => false, // We sometime actually need assertEquals
'php_unit_test_annotation' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage
'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,
'phpdoc_indent' => true, 'phpdoc_indent' => true,
'phpdoc_inline_tag' => true, 'phpdoc_inline_tag' => true,
'phpdoc_line_span' => false, // Unfortunately our old comments turn even uglier with this
'phpdoc_no_access' => true, 'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true, 'phpdoc_no_alias_tag' => true,
'phpdoc_no_empty_return' => true, 'phpdoc_no_empty_return' => true,
@ -132,43 +178,46 @@ return PhpCsFixer\Config::create()
'phpdoc_single_line_var_spacing' => true, 'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true, 'phpdoc_summary' => true,
'phpdoc_to_comment' => true, 'phpdoc_to_comment' => true,
'phpdoc_to_param_type' => false, // Because experimental, but interesting for one shot use
'phpdoc_to_return_type' => false, // idem
'phpdoc_trim' => true, 'phpdoc_trim' => true,
'phpdoc_types_order' => true, 'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => true, 'phpdoc_types' => true,
'phpdoc_types_order' => true,
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true, 'phpdoc_var_without_name' => true,
'php_unit_construct' => true, 'pow_to_exponentiation' => true,
'php_unit_dedicate_assert' => true, 'pre_increment' => false, // Deprecated
'php_unit_expectation' => true,
'php_unit_fqcn_annotation' => true,
'php_unit_mock' => true,
'php_unit_namespaced' => true,
'php_unit_no_expectation_annotation' => true,
'php_unit_strict' => false, // We sometime actually need assertEquals
'php_unit_test_annotation' => true,
'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage
'pow_to_exponentiation' => false,
'protected_to_private' => true, 'protected_to_private' => true,
'psr0' => true, 'psr0' => true,
'psr4' => true, 'psr4' => true,
'random_api_migration' => false, // This breaks our unit tests 'random_api_migration' => true,
'return_assignment' => false, // Sometimes useful for clarity or debug
'return_type_declaration' => true, 'return_type_declaration' => true,
'self_accessor' => true, 'self_accessor' => true,
'self_static_accessor' => true,
'semicolon_after_instruction' => false, // Buggy in `samples/index.php` 'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
'set_type_to_cast' => true,
'short_scalar_cast' => true, 'short_scalar_cast' => true,
'silenced_deprecation_error' => true, 'silenced_deprecation_error' => false, // Deprecated
'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null 'simple_to_complex_string_variable' => false, // Would differ from TypeScript without obvious advantages
'simplified_null_return' => false, // Even if technically correct we prefer to be explicit
'single_blank_line_at_eof' => true, 'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true, 'single_blank_line_before_namespace' => true,
'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_line_comment_style' => true,
'single_line_throw' => false, // I don't see any reason for having a special case for Exception
'single_quote' => true, 'single_quote' => true,
'single_trait_insert_per_statement' => true,
'space_after_semicolon' => true, 'space_after_semicolon' => true,
'standardize_increment' => true,
'standardize_not_equals' => true, 'standardize_not_equals' => true,
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()` 'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
'strict_comparison' => false, // No, too dangerous to change that 'strict_comparison' => false, // No, too dangerous to change that
'strict_param' => false, // No, too dangerous to change that 'strict_param' => false, // No, too dangerous to change that
'string_line_ending' => true,
'switch_case_semicolon_to_colon' => true, 'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true, 'switch_case_space' => true,
'ternary_operator_spaces' => true, 'ternary_operator_spaces' => true,
@ -177,7 +226,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 'void_return' => true,
'whitespace_after_comma_in_array' => true, 'whitespace_after_comma_in_array' => true,
'yoda_style' => false, 'yoda_style' => false,
]); ]);

View File

@ -59,18 +59,18 @@ foreach ($years as $year) {
$period, $period,
$i $i
); );
$value = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); $value = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4));
$salesValue = $invoiceValue = null; $salesValue = $invoiceValue = null;
$incomeOrExpenditure = rand(-1, 1); $incomeOrExpenditure = mt_rand(-1, 1);
if ($incomeOrExpenditure == -1) { if ($incomeOrExpenditure == -1) {
$expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4));
$income = null; $income = null;
} elseif ($incomeOrExpenditure == 1) { } elseif ($incomeOrExpenditure == 1) {
$expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4));
$income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4));
} else { } else {
$expenditure = null; $expenditure = null;
$income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4));
} }
$dataArray = [$year, $dataArray = [$year,
$period, $period,

View File

@ -59,18 +59,18 @@ foreach ($years as $year) {
$period, $period,
$i $i
); );
$value = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); $value = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4));
$salesValue = $invoiceValue = null; $salesValue = $invoiceValue = null;
$incomeOrExpenditure = rand(-1, 1); $incomeOrExpenditure = mt_rand(-1, 1);
if ($incomeOrExpenditure == -1) { if ($incomeOrExpenditure == -1) {
$expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4));
$income = null; $income = null;
} elseif ($incomeOrExpenditure == 1) { } elseif ($incomeOrExpenditure == 1) {
$expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4));
$income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4));
} else { } else {
$expenditure = null; $expenditure = null;
$income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4));
} }
$dataArray = [$year, $dataArray = [$year,
$period, $period,

View File

@ -59,18 +59,18 @@ foreach ($years as $year) {
$period, $period,
$i $i
); );
$value = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); $value = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4));
$salesValue = $invoiceValue = null; $salesValue = $invoiceValue = null;
$incomeOrExpenditure = rand(-1, 1); $incomeOrExpenditure = mt_rand(-1, 1);
if ($incomeOrExpenditure == -1) { if ($incomeOrExpenditure == -1) {
$expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4));
$income = null; $income = null;
} elseif ($incomeOrExpenditure == 1) { } elseif ($incomeOrExpenditure == 1) {
$expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4));
$income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4));
} else { } else {
$expenditure = null; $expenditure = null;
$income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4));
} }
$dataArray = [$year, $dataArray = [$year,
$period, $period,

View File

@ -21,7 +21,11 @@ $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
// Generate an image // Generate an image
$helper->log('Generate an image'); $helper->log('Generate an image');
$gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream'); $gdImage = @imagecreatetruecolor(120, 20);
if (!$gdImage) {
die('Cannot Initialize new GD image stream');
}
$textColor = imagecolorallocate($gdImage, 255, 255, 255); $textColor = imagecolorallocate($gdImage, 255, 255, 255);
imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor); imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor);

View File

@ -23,7 +23,7 @@ class ChunkReadFilter implements IReadFilter
* @param mixed $startRow * @param mixed $startRow
* @param mixed $chunkSize * @param mixed $chunkSize
*/ */
public function setRows($startRow, $chunkSize) public function setRows($startRow, $chunkSize): void
{ {
$this->startRow = $startRow; $this->startRow = $startRow;
$this->endRow = $startRow + $chunkSize; $this->endRow = $startRow + $chunkSize;

View File

@ -24,7 +24,7 @@ class ChunkReadFilter implements IReadFilter
* @param mixed $startRow * @param mixed $startRow
* @param mixed $chunkSize * @param mixed $chunkSize
*/ */
public function setRows($startRow, $chunkSize) public function setRows($startRow, $chunkSize): void
{ {
$this->startRow = $startRow; $this->startRow = $startRow;
$this->endRow = $startRow + $chunkSize; $this->endRow = $startRow + $chunkSize;

View File

@ -11,6 +11,7 @@ use PhpOffice\PhpSpreadsheet\NamedRange;
use PhpOffice\PhpSpreadsheet\Shared; use PhpOffice\PhpSpreadsheet\Shared;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use ReflectionMethod;
class Calculation class Calculation
{ {
@ -2263,16 +2264,16 @@ class Calculation
], ],
]; ];
public function __construct(Spreadsheet $spreadsheet = null) public function __construct(?Spreadsheet $spreadsheet = null)
{ {
$this->delta = 1 * pow(10, 0 - ini_get('precision')); $this->delta = 1 * 10 ** (0 - ini_get('precision'));
$this->spreadsheet = $spreadsheet; $this->spreadsheet = $spreadsheet;
$this->cyclicReferenceStack = new CyclicReferenceStack(); $this->cyclicReferenceStack = new CyclicReferenceStack();
$this->debugLog = new Logger($this->cyclicReferenceStack); $this->debugLog = new Logger($this->cyclicReferenceStack);
} }
private static function loadLocales() private static function loadLocales(): void
{ {
$localeFileDirectory = __DIR__ . '/locale/'; $localeFileDirectory = __DIR__ . '/locale/';
foreach (glob($localeFileDirectory . '*', GLOB_ONLYDIR) as $filename) { foreach (glob($localeFileDirectory . '*', GLOB_ONLYDIR) as $filename) {
@ -2291,7 +2292,7 @@ class Calculation
* *
* @return Calculation * @return Calculation
*/ */
public static function getInstance(Spreadsheet $spreadsheet = null) public static function getInstance(?Spreadsheet $spreadsheet = null)
{ {
if ($spreadsheet !== null) { if ($spreadsheet !== null) {
$instance = $spreadsheet->getCalculationEngine(); $instance = $spreadsheet->getCalculationEngine();
@ -2311,7 +2312,7 @@ class Calculation
* Flush the calculation cache for any existing instance of this class * Flush the calculation cache for any existing instance of this class
* but only if a Calculation instance exists. * but only if a Calculation instance exists.
*/ */
public function flushInstance() public function flushInstance(): void
{ {
$this->clearCalculationCache(); $this->clearCalculationCache();
$this->clearBranchStore(); $this->clearBranchStore();
@ -2400,7 +2401,7 @@ class Calculation
* *
* @param bool $pValue * @param bool $pValue
*/ */
public function setCalculationCacheEnabled($pValue) public function setCalculationCacheEnabled($pValue): void
{ {
$this->calculationCacheEnabled = $pValue; $this->calculationCacheEnabled = $pValue;
$this->clearCalculationCache(); $this->clearCalculationCache();
@ -2409,7 +2410,7 @@ class Calculation
/** /**
* Enable calculation cache. * Enable calculation cache.
*/ */
public function enableCalculationCache() public function enableCalculationCache(): void
{ {
$this->setCalculationCacheEnabled(true); $this->setCalculationCacheEnabled(true);
} }
@ -2417,7 +2418,7 @@ class Calculation
/** /**
* Disable calculation cache. * Disable calculation cache.
*/ */
public function disableCalculationCache() public function disableCalculationCache(): void
{ {
$this->setCalculationCacheEnabled(false); $this->setCalculationCacheEnabled(false);
} }
@ -2425,7 +2426,7 @@ class Calculation
/** /**
* Clear calculation cache. * Clear calculation cache.
*/ */
public function clearCalculationCache() public function clearCalculationCache(): void
{ {
$this->calculationCache = []; $this->calculationCache = [];
} }
@ -2435,7 +2436,7 @@ class Calculation
* *
* @param string $worksheetName * @param string $worksheetName
*/ */
public function clearCalculationCacheForWorksheet($worksheetName) public function clearCalculationCacheForWorksheet($worksheetName): void
{ {
if (isset($this->calculationCache[$worksheetName])) { if (isset($this->calculationCache[$worksheetName])) {
unset($this->calculationCache[$worksheetName]); unset($this->calculationCache[$worksheetName]);
@ -2448,7 +2449,7 @@ class Calculation
* @param string $fromWorksheetName * @param string $fromWorksheetName
* @param string $toWorksheetName * @param string $toWorksheetName
*/ */
public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName) public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName): void
{ {
if (isset($this->calculationCache[$fromWorksheetName])) { if (isset($this->calculationCache[$fromWorksheetName])) {
$this->calculationCache[$toWorksheetName] = &$this->calculationCache[$fromWorksheetName]; $this->calculationCache[$toWorksheetName] = &$this->calculationCache[$fromWorksheetName];
@ -2459,25 +2460,24 @@ class Calculation
/** /**
* Enable/disable calculation cache. * Enable/disable calculation cache.
* *
* @param bool $pValue
* @param mixed $enabled * @param mixed $enabled
*/ */
public function setBranchPruningEnabled($enabled) public function setBranchPruningEnabled($enabled): void
{ {
$this->branchPruningEnabled = $enabled; $this->branchPruningEnabled = $enabled;
} }
public function enableBranchPruning() public function enableBranchPruning(): void
{ {
$this->setBranchPruningEnabled(true); $this->setBranchPruningEnabled(true);
} }
public function disableBranchPruning() public function disableBranchPruning(): void
{ {
$this->setBranchPruningEnabled(false); $this->setBranchPruningEnabled(false);
} }
public function clearBranchStore() public function clearBranchStore(): void
{ {
$this->branchStoreKeyCounter = 0; $this->branchStoreKeyCounter = 0;
} }
@ -2779,7 +2779,7 @@ class Calculation
* *
* @return mixed * @return mixed
*/ */
public function calculate(Cell $pCell = null) public function calculate(?Cell $pCell = null)
{ {
try { try {
return $this->calculateCellValue($pCell); return $this->calculateCellValue($pCell);
@ -2796,7 +2796,7 @@ class Calculation
* *
* @return mixed * @return mixed
*/ */
public function calculateCellValue(Cell $pCell = null, $resetLog = true) public function calculateCellValue(?Cell $pCell = null, $resetLog = true)
{ {
if ($pCell === null) { if ($pCell === null) {
return null; return null;
@ -2898,7 +2898,7 @@ class Calculation
* *
* @return mixed * @return mixed
*/ */
public function calculateFormula($formula, $cellID = null, Cell $pCell = null) public function calculateFormula($formula, $cellID = null, ?Cell $pCell = null)
{ {
// Initialise the logging settings // Initialise the logging settings
$this->formulaError = null; $this->formulaError = null;
@ -2957,7 +2957,7 @@ class Calculation
* @param string $cellReference * @param string $cellReference
* @param mixed $cellValue * @param mixed $cellValue
*/ */
public function saveValueToCache($cellReference, $cellValue) public function saveValueToCache($cellReference, $cellValue): void
{ {
if ($this->calculationCacheEnabled) { if ($this->calculationCacheEnabled) {
$this->calculationCache[$cellReference] = $cellValue; $this->calculationCache[$cellReference] = $cellValue;
@ -2973,7 +2973,7 @@ class Calculation
* *
* @return mixed * @return mixed
*/ */
public function _calculateFormulaValue($formula, $cellID = null, Cell $pCell = null) public function _calculateFormulaValue($formula, $cellID = null, ?Cell $pCell = null)
{ {
$cellValue = null; $cellValue = null;
@ -3119,7 +3119,7 @@ class Calculation
* @param int $matrix2Rows Row size of second matrix operand * @param int $matrix2Rows Row size of second matrix operand
* @param int $matrix2Columns Column size of second matrix operand * @param int $matrix2Columns Column size of second matrix operand
*/ */
private static function resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) private static function resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void
{ {
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
if ($matrix2Rows < $matrix1Rows) { if ($matrix2Rows < $matrix1Rows) {
@ -3162,7 +3162,7 @@ class Calculation
* @param int $matrix2Rows Row size of second matrix operand * @param int $matrix2Rows Row size of second matrix operand
* @param int $matrix2Columns Column size of second matrix operand * @param int $matrix2Columns Column size of second matrix operand
*/ */
private static function resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) private static function resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void
{ {
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
if ($matrix2Columns < $matrix1Columns) { if ($matrix2Columns < $matrix1Columns) {
@ -3371,11 +3371,10 @@ class Calculation
/** /**
* @param string $formula * @param string $formula
* @param null|\PhpOffice\PhpSpreadsheet\Cell\Cell $pCell
* *
* @return bool * @return bool
*/ */
private function _parseFormula($formula, Cell $pCell = null) private function _parseFormula($formula, ?Cell $pCell = null)
{ {
if (($formula = $this->convertMatrixReferences(trim($formula))) === false) { if (($formula = $this->convertMatrixReferences(trim($formula))) === false) {
return false; return false;
@ -3469,7 +3468,7 @@ class Calculation
++$index; // Drop the redundant plus symbol ++$index; // Drop the redundant plus symbol
} elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal } elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal
return $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression return $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression
} elseif ((isset(self::$operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? } elseif ((isset(self::$operators[$opCharacter]) || $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
while ($stack->count() > 0 && while ($stack->count() > 0 &&
($o2 = $stack->last()) && ($o2 = $stack->last()) &&
isset(self::$operators[$o2['value']]) && isset(self::$operators[$o2['value']]) &&
@ -3495,7 +3494,7 @@ class Calculation
// Branch pruning we decrease the depth whether is it a function // Branch pruning we decrease the depth whether is it a function
// call or a parenthesis // call or a parenthesis
if (!empty($pendingStoreKey)) { if (!empty($pendingStoreKey)) {
$parenthesisDepthMap[$pendingStoreKey] -= 1; --$parenthesisDepthMap[$pendingStoreKey];
} }
if (is_array($d) && preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? if (is_array($d) && preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function?
@ -3509,7 +3508,7 @@ class Calculation
} }
$expectingThenMap[$pendingStoreKey] = false; $expectingThenMap[$pendingStoreKey] = false;
$expectingElseMap[$pendingStoreKey] = false; $expectingElseMap[$pendingStoreKey] = false;
$parenthesisDepthMap[$pendingStoreKey] -= 1; --$parenthesisDepthMap[$pendingStoreKey];
array_pop($pendingStoreKeysStack); array_pop($pendingStoreKeysStack);
unset($pendingStoreKey); unset($pendingStoreKey);
} }
@ -3615,7 +3614,7 @@ class Calculation
++$index; ++$index;
} elseif ($opCharacter == '(' && !$expectingOperator) { } elseif ($opCharacter == '(' && !$expectingOperator) {
if (!empty($pendingStoreKey)) { // Branch pruning: we go deeper if (!empty($pendingStoreKey)) { // Branch pruning: we go deeper
$parenthesisDepthMap[$pendingStoreKey] += 1; ++$parenthesisDepthMap[$pendingStoreKey];
} }
$stack->push('Brace', '(', null, $currentCondition, $currentOnlyIf, $currentOnlyIf); $stack->push('Brace', '(', null, $currentCondition, $currentOnlyIf, $currentOnlyIf);
++$index; ++$index;
@ -3641,7 +3640,7 @@ class Calculation
$parenthesisDepthMap[$pendingStoreKey] = 0; $parenthesisDepthMap[$pendingStoreKey] = 0;
} else { // this is not an if but we go deeper } else { // this is not an if but we go deeper
if (!empty($pendingStoreKey) && array_key_exists($pendingStoreKey, $parenthesisDepthMap)) { if (!empty($pendingStoreKey) && array_key_exists($pendingStoreKey, $parenthesisDepthMap)) {
$parenthesisDepthMap[$pendingStoreKey] += 1; ++$parenthesisDepthMap[$pendingStoreKey];
} }
} }
@ -3818,11 +3817,10 @@ class Calculation
/** /**
* @param mixed $tokens * @param mixed $tokens
* @param null|string $cellID * @param null|string $cellID
* @param null|Cell $pCell
* *
* @return bool * @return bool
*/ */
private function processTokenStack($tokens, $cellID = null, Cell $pCell = null) private function processTokenStack($tokens, $cellID = null, ?Cell $pCell = null)
{ {
if ($tokens == false) { if ($tokens == false) {
return false; return false;
@ -4361,7 +4359,6 @@ class Calculation
* @param mixed $operand1 * @param mixed $operand1
* @param mixed $operand2 * @param mixed $operand2
* @param string $operation * @param string $operation
* @param Stack $stack
* @param bool $recursingArrays * @param bool $recursingArrays
* *
* @return mixed * @return mixed
@ -4583,7 +4580,7 @@ class Calculation
break; break;
// Power // Power
case '^': case '^':
$result = pow($operand1, $operand2); $result = $operand1 ** $operand2;
break; break;
} }
@ -4620,7 +4617,7 @@ class Calculation
* *
* @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned.
*/ */
public function extractCellRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true) public function extractCellRange(&$pRange = 'A1', ?Worksheet $pSheet = null, $resetLog = true)
{ {
// Return value // Return value
$returnValue = []; $returnValue = [];
@ -4673,7 +4670,7 @@ class Calculation
* *
* @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned.
*/ */
public function extractNamedRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true) public function extractNamedRange(&$pRange = 'A1', ?Worksheet $pSheet = null, $resetLog = true)
{ {
// Return value // Return value
$returnValue = []; $returnValue = [];
@ -4773,21 +4770,19 @@ class Calculation
/** /**
* Add cell reference if needed while making sure that it is the last argument. * Add cell reference if needed while making sure that it is the last argument.
* *
* @param array $args
* @param bool $passCellReference * @param bool $passCellReference
* @param array|string $functionCall * @param array|string $functionCall
* @param null|Cell $pCell
* *
* @return array * @return array
*/ */
private function addCellReference(array $args, $passCellReference, $functionCall, Cell $pCell = null) private function addCellReference(array $args, $passCellReference, $functionCall, ?Cell $pCell = null)
{ {
if ($passCellReference) { if ($passCellReference) {
if (is_array($functionCall)) { if (is_array($functionCall)) {
$className = $functionCall[0]; $className = $functionCall[0];
$methodName = $functionCall[1]; $methodName = $functionCall[1];
$reflectionMethod = new \ReflectionMethod($className, $methodName); $reflectionMethod = new ReflectionMethod($className, $methodName);
$argumentCount = count($reflectionMethod->getParameters()); $argumentCount = count($reflectionMethod->getParameters());
while (count($args) < $argumentCount - 1) { while (count($args) < $argumentCount - 1) {
$args[] = null; $args[] = null;

View File

@ -2,6 +2,8 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
use DateTimeImmutable;
use DateTimeInterface;
use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
@ -66,7 +68,7 @@ class DateTime
public static function getDateValue($dateValue) public static function getDateValue($dateValue)
{ {
if (!is_numeric($dateValue)) { if (!is_numeric($dateValue)) {
if ((is_object($dateValue)) && ($dateValue instanceof \DateTimeInterface)) { if ((is_object($dateValue)) && ($dateValue instanceof DateTimeInterface)) {
$dateValue = Date::PHPToExcel($dateValue); $dateValue = Date::PHPToExcel($dateValue);
} else { } else {
$saveReturnDateType = Functions::getReturnDateType(); $saveReturnDateType = Functions::getReturnDateType();
@ -768,9 +770,9 @@ class DateTime
* *
* @category Date/Time Functions * @category Date/Time Functions
* *
* @param \DateTimeImmutable|float|int|string $endDate Excel date serial value (float), * @param DateTimeImmutable|float|int|string $endDate Excel date serial value (float),
* PHP date timestamp (integer), PHP DateTime object, or a standard date string * PHP date timestamp (integer), PHP DateTime object, or a standard date string
* @param \DateTimeImmutable|float|int|string $startDate Excel date serial value (float), * @param DateTimeImmutable|float|int|string $startDate Excel date serial value (float),
* PHP date timestamp (integer), PHP DateTime object, or a standard date string * PHP date timestamp (integer), PHP DateTime object, or a standard date string
* *
* @return int|string Number of days between start date and end date or an error * @return int|string Number of days between start date and end date or an error

View File

@ -26,7 +26,7 @@ class CyclicReferenceStack
* *
* @param mixed $value * @param mixed $value
*/ */
public function push($value) public function push($value): void
{ {
$this->stack[$value] = $value; $this->stack[$value] = $value;
} }
@ -56,7 +56,7 @@ class CyclicReferenceStack
/** /**
* Clear the stack. * Clear the stack.
*/ */
public function clear() public function clear(): void
{ {
$this->stack = []; $this->stack = [];
} }

View File

@ -39,8 +39,6 @@ class Logger
/** /**
* Instantiate a Calculation engine logger. * Instantiate a Calculation engine logger.
*
* @param CyclicReferenceStack $stack
*/ */
public function __construct(CyclicReferenceStack $stack) public function __construct(CyclicReferenceStack $stack)
{ {
@ -52,7 +50,7 @@ class Logger
* *
* @param bool $pValue * @param bool $pValue
*/ */
public function setWriteDebugLog($pValue) public function setWriteDebugLog($pValue): void
{ {
$this->writeDebugLog = $pValue; $this->writeDebugLog = $pValue;
} }
@ -72,7 +70,7 @@ class Logger
* *
* @param bool $pValue * @param bool $pValue
*/ */
public function setEchoDebugLog($pValue) public function setEchoDebugLog($pValue): void
{ {
$this->echoDebugLog = $pValue; $this->echoDebugLog = $pValue;
} }
@ -90,11 +88,11 @@ class Logger
/** /**
* Write an entry to the calculation engine debug log. * Write an entry to the calculation engine debug log.
*/ */
public function writeDebugLog(...$args) public function writeDebugLog(...$args): void
{ {
// Only write the debug log if logging is enabled // Only write the debug log if logging is enabled
if ($this->writeDebugLog) { if ($this->writeDebugLog) {
$message = implode($args); $message = implode('', $args);
$cellReference = implode(' -> ', $this->cellStack->showStack()); $cellReference = implode(' -> ', $this->cellStack->showStack());
if ($this->echoDebugLog) { if ($this->echoDebugLog) {
echo $cellReference, echo $cellReference,
@ -111,7 +109,7 @@ class Logger
/** /**
* Clear the calculation engine debug log. * Clear the calculation engine debug log.
*/ */
public function clearLog() public function clearLog(): void
{ {
$this->debugLog = []; $this->debugLog = [];
} }

View File

@ -799,7 +799,7 @@ class Engineering
} }
if (abs($x) <= 30) { if (abs($x) <= 30) {
$fResult = $fTerm = pow($x / 2, $ord) / MathTrig::FACT($ord); $fResult = $fTerm = ($x / 2) ** $ord / MathTrig::FACT($ord);
$ordK = 1; $ordK = 1;
$fSqrX = ($x * $x) / 4; $fSqrX = ($x * $x) / 4;
do { do {
@ -854,7 +854,7 @@ class Engineering
$fResult = 0; $fResult = 0;
if (abs($x) <= 30) { if (abs($x) <= 30) {
$fResult = $fTerm = pow($x / 2, $ord) / MathTrig::FACT($ord); $fResult = $fTerm = ($x / 2) ** $ord / MathTrig::FACT($ord);
$ordK = 1; $ordK = 1;
$fSqrX = ($x * $x) / -4; $fSqrX = ($x * $x) / -4;
do { do {
@ -2357,7 +2357,7 @@ class Engineering
} elseif (is_numeric($value)) { } elseif (is_numeric($value)) {
if ($value == (int) ($value)) { if ($value == (int) ($value)) {
$value = (int) ($value); $value = (int) ($value);
if (($value > pow(2, 48) - 1) || ($value < 0)) { if (($value > 2 ** 48 - 1) || ($value < 0)) {
throw new Exception(Functions::NAN()); throw new Exception(Functions::NAN());
} }
@ -2477,7 +2477,7 @@ class Engineering
$shiftAmount = Functions::flattenSingleValue($shiftAmount); $shiftAmount = Functions::flattenSingleValue($shiftAmount);
$result = $number << $shiftAmount; $result = $number << $shiftAmount;
if ($result > pow(2, 48) - 1) { if ($result > 2 ** 48 - 1) {
return Functions::NAN(); return Functions::NAN();
} }

View File

@ -15,7 +15,7 @@ class Exception extends PhpSpreadsheetException
* @param mixed $line * @param mixed $line
* @param mixed $context * @param mixed $context
*/ */
public static function errorHandlerCallback($code, $string, $file, $line, $context) public static function errorHandlerCallback($code, $string, $file, $line, $context): void
{ {
$e = new self($string, $code); $e = new self($string, $code);
$e->line = $line; $e->line = $line;

View File

@ -851,7 +851,7 @@ class Financial
return Functions::NAN(); return Functions::NAN();
} }
// Set Fixed Depreciation Rate // Set Fixed Depreciation Rate
$fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life)); $fixedDepreciationRate = 1 - ($salvage / $cost) ** (1 / $life);
$fixedDepreciationRate = round($fixedDepreciationRate, 3); $fixedDepreciationRate = round($fixedDepreciationRate, 3);
// Loop through each period calculating the depreciation // Loop through each period calculating the depreciation
@ -917,7 +917,7 @@ class Financial
return Functions::NAN(); return Functions::NAN();
} }
// Set Fixed Depreciation Rate // Set Fixed Depreciation Rate
$fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life)); $fixedDepreciationRate = 1 - ($salvage / $cost) ** (1 / $life);
$fixedDepreciationRate = round($fixedDepreciationRate, 3); $fixedDepreciationRate = round($fixedDepreciationRate, 3);
// Loop through each period calculating the depreciation // Loop through each period calculating the depreciation
@ -1021,7 +1021,7 @@ class Financial
$dollars = floor($fractional_dollar); $dollars = floor($fractional_dollar);
$cents = fmod($fractional_dollar, 1); $cents = fmod($fractional_dollar, 1);
$cents /= $fraction; $cents /= $fraction;
$cents *= pow(10, ceil(log10($fraction))); $cents *= 10 ** ceil(log10($fraction));
return $dollars + $cents; return $dollars + $cents;
} }
@ -1059,7 +1059,7 @@ class Financial
$dollars = floor($decimal_dollar); $dollars = floor($decimal_dollar);
$cents = fmod($decimal_dollar, 1); $cents = fmod($decimal_dollar, 1);
$cents *= $fraction; $cents *= $fraction;
$cents *= pow(10, -ceil(log10($fraction))); $cents *= 10 ** (-ceil(log10($fraction)));
return $dollars + $cents; return $dollars + $cents;
} }
@ -1090,7 +1090,7 @@ class Financial
return Functions::NAN(); return Functions::NAN();
} }
return pow((1 + $nominal_rate / $npery), $npery) - 1; return (1 + $nominal_rate / $npery) ** $npery - 1;
} }
/** /**
@ -1131,7 +1131,7 @@ class Financial
// Calculate // Calculate
if ($rate !== null && $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 * (1 + $rate) ** $nper - $pmt * (1 + $rate * $type) * ((1 + $rate) ** $nper - 1) / $rate;
} }
return -$pv - $pmt * $nper; return -$pv - $pmt * $nper;
@ -1400,9 +1400,9 @@ class Financial
$npv_pos = $npv_neg = 0.0; $npv_pos = $npv_neg = 0.0;
foreach ($values as $i => $v) { foreach ($values as $i => $v) {
if ($v >= 0) { if ($v >= 0) {
$npv_pos += $v / pow($rr, $i); $npv_pos += $v / $rr ** $i;
} else { } else {
$npv_neg += $v / pow($fr, $i); $npv_neg += $v / $fr ** $i;
} }
} }
@ -1410,8 +1410,8 @@ class Financial
return Functions::VALUE(); return Functions::VALUE();
} }
$mirr = pow((-$npv_pos * pow($rr, $n)) $mirr = ((-$npv_pos * $rr ** $n)
/ ($npv_neg * ($rr)), (1.0 / ($n - 1))) - 1.0; / ($npv_neg * ($rr))) ** (1.0 / ($n - 1)) - 1.0;
return is_finite($mirr) ? $mirr : Functions::VALUE(); return is_finite($mirr) ? $mirr : Functions::VALUE();
} }
@ -1437,7 +1437,7 @@ class Financial
} }
// Calculate // Calculate
return $npery * (pow($effect_rate + 1, 1 / $npery) - 1); return $npery * (($effect_rate + 1) ** (1 / $npery) - 1);
} }
/** /**
@ -1502,7 +1502,7 @@ class Financial
for ($i = 1; $i <= $countArgs; ++$i) { for ($i = 1; $i <= $countArgs; ++$i) {
// Is it a numeric value? // Is it a numeric value?
if (is_numeric($aArgs[$i - 1])) { if (is_numeric($aArgs[$i - 1])) {
$returnValue += $aArgs[$i - 1] / pow(1 + $rate, $i); $returnValue += $aArgs[$i - 1] / (1 + $rate) ** $i;
} }
} }
@ -1565,7 +1565,7 @@ class Financial
// Calculate // Calculate
if ($rate !== null && $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 * (1 + $rate) ** $nper) / (1 + $rate * $type) / (((1 + $rate) ** $nper - 1) / $rate);
} }
return (-$pv - $fv) / $nper; return (-$pv - $fv) / $nper;
@ -1672,9 +1672,9 @@ class Financial
$rfp = 100 * ($rate / $frequency); $rfp = 100 * ($rate / $frequency);
$de = $dsc / $e; $de = $dsc / $e;
$result = $redemption / pow($baseYF, (--$n + $de)); $result = $redemption / $baseYF ** (--$n + $de);
for ($k = 0; $k <= $n; ++$k) { for ($k = 0; $k <= $n; ++$k) {
$result += $rfp / (pow($baseYF, ($k + $de))); $result += $rfp / ($baseYF ** ($k + $de));
} }
$result -= $rfp * ($a / $e); $result -= $rfp * ($a / $e);
@ -1820,7 +1820,7 @@ class Financial
// Calculate // Calculate
if ($rate !== null && $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) * (((1 + $rate) ** $nper - 1) / $rate) - $fv) / (1 + $rate) ** $nper;
} }
return -$fv - $pmt * $nper; return -$fv - $pmt * $nper;
@ -1889,8 +1889,8 @@ class Financial
if ($rate == 0) { if ($rate == 0) {
return Functions::NAN(); return Functions::NAN();
} }
$tt1 = pow($rate + 1, $nper); $tt1 = ($rate + 1) ** $nper;
$tt2 = pow($rate + 1, $nper - 1); $tt2 = ($rate + 1) ** ($nper - 1);
$numerator = $fv + $tt1 * $pv + $pmt * ($tt1 - 1) * ($rate * $type + 1) / $rate; $numerator = $fv + $tt1 * $pv + $pmt * ($tt1 - 1) * ($rate * $type + 1) / $rate;
$denominator = $nper * $tt2 * $pv - $pmt * ($tt1 - 1) * ($rate * $type + 1) / ($rate * $rate) $denominator = $nper * $tt2 * $pv - $pmt * ($tt1 - 1) * ($rate * $type + 1) / ($rate * $rate)
+ $nper * $pmt * $tt2 * ($rate * $type + 1) / $rate + $nper * $pmt * $tt2 * ($rate * $type + 1) / $rate
@ -1971,7 +1971,7 @@ class Financial
return Functions::NAN(); return Functions::NAN();
} }
return pow($fv / $pv, 1 / $nper) - 1; return ($fv / $pv) ** (1 / $nper) - 1;
} }
/** /**
@ -2377,7 +2377,7 @@ class Financial
if (!is_numeric($dif)) { if (!is_numeric($dif)) {
return $dif; return $dif;
} }
$xnpv += $values[$i] / pow(1 + $rate, $dif / 365); $xnpv += $values[$i] / (1 + $rate) ** ($dif / 365);
} }
return is_finite($xnpv) ? $xnpv : Functions::VALUE(); return is_finite($xnpv) ? $xnpv : Functions::VALUE();

View File

@ -125,7 +125,7 @@ class FormulaParser
/** /**
* Parse to tokens. * Parse to tokens.
*/ */
private function parseToTokens() private function parseToTokens(): void
{ {
// No attempt is made to verify formulas; assumes formulas are derived from Excel, where // No attempt is made to verify formulas; assumes formulas are derived from Excel, where
// they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions. // they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions.

View File

@ -103,7 +103,7 @@ class FormulaToken
* *
* @param string $value * @param string $value
*/ */
public function setValue($value) public function setValue($value): void
{ {
$this->value = $value; $this->value = $value;
} }
@ -123,7 +123,7 @@ class FormulaToken
* *
* @param string $value * @param string $value
*/ */
public function setTokenType($value) public function setTokenType($value): void
{ {
$this->tokenType = $value; $this->tokenType = $value;
} }
@ -143,7 +143,7 @@ class FormulaToken
* *
* @param string $value * @param string $value
*/ */
public function setTokenSubType($value) public function setTokenSubType($value): void
{ {
$this->tokenSubType = $value; $this->tokenSubType = $value;
} }

View File

@ -660,7 +660,7 @@ class Functions
* *
* @return bool|string * @return bool|string
*/ */
public static function isFormula($cellReference = '', Cell $pCell = null) public static function isFormula($cellReference = '', ?Cell $pCell = null)
{ {
if ($pCell === null) { if ($pCell === null) {
return self::REF(); return self::REF();

View File

@ -238,7 +238,7 @@ class LookupRef
* *
* @return mixed The value of $displayName (or $linkURL if $displayName was blank) * @return mixed The value of $displayName (or $linkURL if $displayName was blank)
*/ */
public static function HYPERLINK($linkURL = '', $displayName = null, Cell $pCell = null) public static function HYPERLINK($linkURL = '', $displayName = null, ?Cell $pCell = null)
{ {
$linkURL = ($linkURL === null) ? '' : Functions::flattenSingleValue($linkURL); $linkURL = ($linkURL === null) ? '' : Functions::flattenSingleValue($linkURL);
$displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName); $displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName);
@ -275,7 +275,7 @@ class LookupRef
* *
* @todo Support for the optional a1 parameter introduced in Excel 2010 * @todo Support for the optional a1 parameter introduced in Excel 2010
*/ */
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 ($cellAddress === null || $cellAddress === '') { if ($cellAddress === null || $cellAddress === '') {
@ -339,11 +339,10 @@ class LookupRef
* starting reference). * starting reference).
* @param mixed $height The height, in number of rows, that you want the returned reference to be. Height must be a positive number. * @param mixed $height The height, in number of rows, that you want the returned reference to be. Height must be a positive number.
* @param mixed $width The width, in number of columns, that you want the returned reference to be. Width must be a positive number. * @param mixed $width The width, in number of columns, that you want the returned reference to be. Width must be a positive number.
* @param null|Cell $pCell
* *
* @return string A reference to a cell or range of cells * @return string A reference to a cell or range of cells
*/ */
public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, Cell $pCell = null) public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, ?Cell $pCell = null)
{ {
$rows = Functions::flattenSingleValue($rows); $rows = Functions::flattenSingleValue($rows);
$columns = Functions::flattenSingleValue($columns); $columns = Functions::flattenSingleValue($columns);
@ -419,14 +418,6 @@ class LookupRef
* Excel Function: * Excel Function:
* =CHOOSE(index_num, value1, [value2], ...) * =CHOOSE(index_num, value1, [value2], ...)
* *
* @param mixed $index_num Specifies which value argument is selected.
* Index_num must be a number between 1 and 254, or a formula or reference to a cell containing a number
* between 1 and 254.
* @param mixed $value1 ... Value1 is required, subsequent values are optional.
* Between 1 to 254 value arguments from which CHOOSE selects a value or an action to perform based on
* index_num. The arguments can be numbers, cell references, defined names, formulas, functions, or
* text.
*
* @return mixed The selected value * @return mixed The selected value
*/ */
public static function CHOOSE(...$chooseArgs) public static function CHOOSE(...$chooseArgs)
@ -945,7 +936,7 @@ class LookupRef
* *
* @return string * @return string
*/ */
public static function FORMULATEXT($cellReference = '', Cell $pCell = null) public static function FORMULATEXT($cellReference = '', ?Cell $pCell = null)
{ {
if ($pCell === null) { if ($pCell === null) {
return Functions::REF(); return Functions::REF();

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation; namespace PhpOffice\PhpSpreadsheet\Calculation;
use Exception;
use Matrix\Exception as MatrixException; use Matrix\Exception as MatrixException;
use Matrix\Matrix; use Matrix\Matrix;
@ -68,7 +69,7 @@ class MathTrig
try { try {
$arabic = self::calculateArabic(str_split($roman)); $arabic = self::calculateArabic(str_split($roman));
} catch (\Exception $e) { } catch (Exception $e) {
return Functions::VALUE(); // Invalid character detected return Functions::VALUE(); // Invalid character detected
} }
@ -82,7 +83,6 @@ class MathTrig
/** /**
* Recursively calculate the arabic value of a roman numeral. * Recursively calculate the arabic value of a roman numeral.
* *
* @param array $roman
* @param int $sum * @param int $sum
* @param int $subtract * @param int $subtract
* *
@ -102,7 +102,7 @@ class MathTrig
$numeral = array_shift($roman); $numeral = array_shift($roman);
if (!isset($lookup[$numeral])) { if (!isset($lookup[$numeral])) {
throw new \Exception('Invalid character detected'); throw new Exception('Invalid character detected');
} }
$arabic = $lookup[$numeral]; $arabic = $lookup[$numeral];
@ -618,7 +618,7 @@ class MathTrig
$myCountedFactors = array_count_values($myFactors); $myCountedFactors = array_count_values($myFactors);
$myPoweredFactors = []; $myPoweredFactors = [];
foreach ($myCountedFactors as $myCountedFactor => $myCountedPower) { foreach ($myCountedFactors as $myCountedFactor => $myCountedPower) {
$myPoweredFactors[$myCountedFactor] = pow($myCountedFactor, $myCountedPower); $myPoweredFactors[$myCountedFactor] = $myCountedFactor ** $myCountedPower;
} }
foreach ($myPoweredFactors as $myPoweredValue => $myPoweredFactor) { foreach ($myPoweredFactors as $myPoweredValue => $myPoweredFactor) {
if (isset($allPoweredFactors[$myPoweredValue])) { if (isset($allPoweredFactors[$myPoweredValue])) {
@ -986,7 +986,7 @@ class MathTrig
} }
// Return // Return
$result = pow($x, $y); $result = $x ** $y;
return (!is_nan($result) && !is_infinite($result)) ? $result : Functions::NAN(); return (!is_nan($result) && !is_infinite($result)) ? $result : Functions::NAN();
} }
@ -1139,10 +1139,10 @@ class MathTrig
if ((is_numeric($number)) && (is_numeric($digits))) { if ((is_numeric($number)) && (is_numeric($digits))) {
if ($number < 0.0) { if ($number < 0.0) {
return round($number - 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_DOWN); return round($number - 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_DOWN);
} }
return round($number + 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_DOWN); return round($number + 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_DOWN);
} }
return Functions::VALUE(); return Functions::VALUE();
@ -1165,10 +1165,10 @@ class MathTrig
if ((is_numeric($number)) && (is_numeric($digits))) { if ((is_numeric($number)) && (is_numeric($digits))) {
if ($number < 0.0) { if ($number < 0.0) {
return round($number + 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_UP); return round($number + 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_UP);
} }
return round($number - 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_UP); return round($number - 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_UP);
} }
return Functions::VALUE(); return Functions::VALUE();
@ -1179,9 +1179,6 @@ class MathTrig
* *
* Returns the sum of a power series * Returns the sum of a power series
* *
* @param float $x Input value to the power series
* @param float $n Initial power to which you want to raise $x
* @param float $m Step by which to increase $n for each term in the series
* @param array of mixed Data Series * @param array of mixed Data Series
* *
* @return float|string The result, or a string containing an error * @return float|string The result, or a string containing an error
@ -1203,7 +1200,7 @@ class MathTrig
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))) {
$returnValue += $arg * pow($x, $n + ($m * $i++)); $returnValue += $arg * $x ** ($n + ($m * $i++));
} else { } else {
return Functions::VALUE(); return Functions::VALUE();
} }
@ -1445,7 +1442,6 @@ class MathTrig
* @category Mathematical and Trigonometric Functions * @category Mathematical and Trigonometric Functions
* *
* @param mixed $args Data values * @param mixed $args Data values
* @param string $condition the criteria that defines which cells will be summed
* *
* @return float * @return float
*/ */
@ -1663,7 +1659,7 @@ class MathTrig
$digits = floor($digits); $digits = floor($digits);
// Truncate // Truncate
$adjust = pow(10, $digits); $adjust = 10 ** $digits;
if (($digits > 0) && (rtrim((int) ((abs($value) - abs((int) $value)) * $adjust), '0') < $adjust / 10)) { if (($digits > 0) && (rtrim((int) ((abs($value) - abs((int) $value)) * $adjust), '0') < $adjust / 10)) {
return $value; return $value;

View File

@ -397,10 +397,10 @@ class Statistical
for ($i = 1; $i <= $n; ++$i) { for ($i = 1; $i <= $n; ++$i) {
$divisor *= ($a + $i); $divisor *= ($a + $i);
} }
$summer += (pow($x, $n) / $divisor); $summer += ($x ** $n / $divisor);
} }
return pow($x, $a) * exp(0 - $x) * $summer; return $x ** $a * exp(0 - $x) * $summer;
} }
// //
@ -874,13 +874,13 @@ class Statistical
if ($cumulative) { if ($cumulative) {
$summer = 0; $summer = 0;
for ($i = 0; $i <= $value; ++$i) { for ($i = 0; $i <= $value; ++$i) {
$summer += MathTrig::COMBIN($trials, $i) * pow($probability, $i) * pow(1 - $probability, $trials - $i); $summer += MathTrig::COMBIN($trials, $i) * $probability ** $i * (1 - $probability) ** ($trials - $i);
} }
return $summer; return $summer;
} }
return MathTrig::COMBIN($trials, $value) * pow($probability, $value) * pow(1 - $probability, $trials - $value); return MathTrig::COMBIN($trials, $value) * $probability ** $value * (1 - $probability) ** ($trials - $value);
} }
} }
@ -1320,7 +1320,7 @@ class Statistical
$t = sqrt(log(1 / ($alpha * $alpha))); $t = sqrt(log(1 / ($alpha * $alpha)));
$trialsApprox = 0 - ($t + (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t)); $trialsApprox = 0 - ($t + (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t));
} else { } else {
$t = sqrt(log(1 / pow(1 - $alpha, 2))); $t = sqrt(log(1 / (1 - $alpha) ** 2));
$trialsApprox = $t - (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t); $trialsApprox = $t - (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t);
} }
@ -1441,9 +1441,9 @@ class Statistical
} }
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
if ($returnValue === null) { if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2); $returnValue = ($arg - $aMean) ** 2;
} else { } else {
$returnValue += pow(($arg - $aMean), 2); $returnValue += ($arg - $aMean) ** 2;
} }
++$aCount; ++$aCount;
} }
@ -1603,7 +1603,7 @@ class Statistical
return self::incompleteGamma($a, $value / $b) / self::gamma($a); return self::incompleteGamma($a, $value / $b) / self::gamma($a);
} }
return (1 / (pow($b, $a) * self::gamma($a))) * pow($value, $a - 1) * exp(0 - ($value / $b)); return (1 / ($b ** $a * self::gamma($a))) * $value ** ($a - 1) * exp(0 - ($value / $b));
} }
} }
@ -1721,7 +1721,7 @@ class Statistical
if (is_numeric($aMean) && ($aMean > 0)) { if (is_numeric($aMean) && ($aMean > 0)) {
$aCount = self::COUNT($aArgs); $aCount = self::COUNT($aArgs);
if (self::MIN($aArgs) > 0) { if (self::MIN($aArgs) > 0) {
return pow($aMean, (1 / $aCount)); return $aMean ** (1 / $aCount);
} }
} }
@ -1900,7 +1900,7 @@ class Statistical
} else { } else {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
$summer += pow((($arg - $mean) / $stdDev), 4); $summer += (($arg - $mean) / $stdDev) ** 4;
++$count; ++$count;
} }
} }
@ -1908,7 +1908,7 @@ class Statistical
// Return // Return
if ($count > 3) { if ($count > 3) {
return $summer * ($count * ($count + 1) / (($count - 1) * ($count - 2) * ($count - 3))) - (3 * pow($count - 1, 2) / (($count - 2) * ($count - 3))); return $summer * ($count * ($count + 1) / (($count - 1) * ($count - 2) * ($count - 3))) - (3 * ($count - 1) ** 2 / (($count - 2) * ($count - 3)));
} }
} }
@ -1927,7 +1927,6 @@ class Statistical
* @category Statistical Functions * @category Statistical Functions
* *
* @param mixed $args Data values * @param mixed $args Data values
* @param int $entry Position (ordered from the largest) in the array or range of data to return
* *
* @return float|string The result, or a string containing an error * @return float|string The result, or a string containing an error
*/ */
@ -2579,7 +2578,7 @@ class Statistical
} }
} }
return (MathTrig::COMBIN($failures + $successes - 1, $successes - 1)) * (pow($probability, $successes)) * (pow(1 - $probability, $failures)); return (MathTrig::COMBIN($failures + $successes - 1, $successes - 1)) * ($probability ** $successes) * ((1 - $probability) ** $failures);
} }
return Functions::VALUE(); return Functions::VALUE();
@ -2614,7 +2613,7 @@ class Statistical
return 0.5 * (1 + Engineering::erfVal(($value - $mean) / ($stdDev * sqrt(2)))); return 0.5 * (1 + Engineering::erfVal(($value - $mean) / ($stdDev * sqrt(2))));
} }
return (1 / (self::SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean, 2) / (2 * ($stdDev * $stdDev)))); return (1 / (self::SQRT2PI * $stdDev)) * exp(0 - (($value - $mean) ** 2 / (2 * ($stdDev * $stdDev))));
} }
} }
@ -2695,7 +2694,6 @@ class Statistical
* @category Statistical Functions * @category Statistical Functions
* *
* @param mixed $args Data values * @param mixed $args Data values
* @param float $entry Percentile value in the range 0..1, inclusive.
* *
* @return float|string The result, or a string containing an error * @return float|string The result, or a string containing an error
*/ */
@ -2841,13 +2839,13 @@ class Statistical
$summer = 0; $summer = 0;
$floor = floor($value); $floor = floor($value);
for ($i = 0; $i <= $floor; ++$i) { for ($i = 0; $i <= $floor; ++$i) {
$summer += pow($mean, $i) / MathTrig::FACT($i); $summer += $mean ** $i / MathTrig::FACT($i);
} }
return exp(0 - $mean) * $summer; return exp(0 - $mean) * $summer;
} }
return (exp(0 - $mean) * pow($mean, $value)) / MathTrig::FACT($value); return (exp(0 - $mean) * $mean ** $value) / MathTrig::FACT($value);
} }
} }
@ -2865,7 +2863,6 @@ class Statistical
* @category Statistical Functions * @category Statistical Functions
* *
* @param mixed $args Data values * @param mixed $args Data values
* @param int $entry Quartile value in the range 1..3, inclusive.
* *
* @return float|string The result, or a string containing an error * @return float|string The result, or a string containing an error
*/ */
@ -2979,7 +2976,7 @@ class Statistical
} else { } else {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
$summer += pow((($arg - $mean) / $stdDev), 3); $summer += (($arg - $mean) / $stdDev) ** 3;
++$count; ++$count;
} }
} }
@ -3033,7 +3030,6 @@ class Statistical
* @category Statistical Functions * @category Statistical Functions
* *
* @param mixed $args Data values * @param mixed $args Data values
* @param int $entry Position (ordered from the smallest) in the array or range of data to return
* *
* @return float|string The result, or a string containing an error * @return float|string The result, or a string containing an error
*/ */
@ -3126,9 +3122,9 @@ 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 ($returnValue === null) { if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2); $returnValue = ($arg - $aMean) ** 2;
} else { } else {
$returnValue += pow(($arg - $aMean), 2); $returnValue += ($arg - $aMean) ** 2;
} }
++$aCount; ++$aCount;
} }
@ -3178,9 +3174,9 @@ class Statistical
$arg = 0; $arg = 0;
} }
if ($returnValue === null) { if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2); $returnValue = ($arg - $aMean) ** 2;
} else { } else {
$returnValue += pow(($arg - $aMean), 2); $returnValue += ($arg - $aMean) ** 2;
} }
++$aCount; ++$aCount;
} }
@ -3226,9 +3222,9 @@ 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 ($returnValue === null) { if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2); $returnValue = ($arg - $aMean) ** 2;
} else { } else {
$returnValue += pow(($arg - $aMean), 2); $returnValue += ($arg - $aMean) ** 2;
} }
++$aCount; ++$aCount;
} }
@ -3277,9 +3273,9 @@ class Statistical
$arg = 0; $arg = 0;
} }
if ($returnValue === null) { if ($returnValue === null) {
$returnValue = pow(($arg - $aMean), 2); $returnValue = ($arg - $aMean) ** 2;
} else { } else {
$returnValue += pow(($arg - $aMean), 2); $returnValue += ($arg - $aMean) ** 2;
} }
++$aCount; ++$aCount;
} }
@ -3491,7 +3487,6 @@ class Statistical
* @category Statistical Functions * @category Statistical Functions
* *
* @param mixed $args Data values * @param mixed $args Data values
* @param float $discard Percentage to discard
* *
* @return float|string * @return float|string
*/ */
@ -3746,10 +3741,10 @@ class Statistical
} }
if ((is_numeric($cumulative)) || (is_bool($cumulative))) { if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) { if ($cumulative) {
return 1 - exp(0 - pow($value / $beta, $alpha)); return 1 - exp(0 - ($value / $beta) ** $alpha);
} }
return ($alpha / pow($beta, $alpha)) * pow($value, $alpha - 1) * exp(0 - pow($value / $beta, $alpha)); return ($alpha / $beta ** $alpha) * $value ** ($alpha - 1) * exp(0 - ($value / $beta) ** $alpha);
} }
} }

View File

@ -167,7 +167,7 @@ class TextData
if ($decimals > 0) { if ($decimals > 0) {
$mask .= '.' . str_repeat('0', $decimals); $mask .= '.' . str_repeat('0', $decimals);
} else { } else {
$round = pow(10, abs($decimals)); $round = 10 ** abs($decimals);
if ($value < 0) { if ($value < 0) {
$round = 0 - $round; $round = 0 - $round;
} }
@ -623,7 +623,7 @@ class TextData
$percentageAdjustment = strlen($value) - strlen($percentageString); $percentageAdjustment = strlen($value) - strlen($percentageString);
if ($percentageAdjustment) { if ($percentageAdjustment) {
$value = (float) $percentageString; $value = (float) $percentageString;
$value /= pow(10, $percentageAdjustment * 2); $value /= 10 ** ($percentageAdjustment * 2);
} }
} }

View File

@ -49,7 +49,7 @@ class Stack
$storeKey = null, $storeKey = null,
$onlyIf = null, $onlyIf = null,
$onlyIfNot = null $onlyIfNot = null
) { ): void {
$stackItem = $this->getStackItem($type, $value, $reference, $storeKey, $onlyIf, $onlyIfNot); $stackItem = $this->getStackItem($type, $value, $reference, $storeKey, $onlyIf, $onlyIfNot);
$this->stack[$this->count++] = $stackItem; $this->stack[$this->count++] = $stackItem;
@ -124,7 +124,7 @@ class Stack
/** /**
* Clear the stack. * Clear the stack.
*/ */
public function clear() public function clear(): void
{ {
$this->stack = []; $this->stack = [];
$this->count = 0; $this->count = 0;

View File

@ -76,12 +76,12 @@ class Cell
return $this; return $this;
} }
public function detach() public function detach(): void
{ {
$this->parent = null; $this->parent = null;
} }
public function attach(Cells $parent) public function attach(Cells $parent): void
{ {
$this->parent = $parent; $this->parent = $parent;
} }
@ -91,7 +91,6 @@ class Cell
* *
* @param mixed $pValue * @param mixed $pValue
* @param string $pDataType * @param string $pDataType
* @param Worksheet $pSheet
*/ */
public function __construct($pValue, $pDataType, Worksheet $pSheet) public function __construct($pValue, $pDataType, Worksheet $pSheet)
{ {
@ -386,7 +385,7 @@ class Cell
* *
* @return Cell * @return Cell
*/ */
public function setDataValidation(DataValidation $pDataValidation = null) public function setDataValidation(?DataValidation $pDataValidation = null)
{ {
if (!isset($this->parent)) { if (!isset($this->parent)) {
throw new Exception('Cannot set data validation for cell that is not bound to a worksheet'); throw new Exception('Cannot set data validation for cell that is not bound to a worksheet');
@ -444,7 +443,7 @@ class Cell
* *
* @return Cell * @return Cell
*/ */
public function setHyperlink(Hyperlink $pHyperlink = null) public function setHyperlink(?Hyperlink $pHyperlink = null)
{ {
if (!isset($this->parent)) { if (!isset($this->parent)) {
throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet'); throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
@ -532,8 +531,6 @@ class Cell
/** /**
* Re-bind parent. * Re-bind parent.
* *
* @param Worksheet $parent
*
* @return Cell * @return Cell
*/ */
public function rebindParent(Worksheet $parent) public function rebindParent(Worksheet $parent)
@ -600,10 +597,8 @@ class Cell
/** /**
* Set value binder to use. * Set value binder to use.
*
* @param IValueBinder $binder
*/ */
public static function setValueBinder(IValueBinder $binder) public static function setValueBinder(IValueBinder $binder): void
{ {
self::$valueBinder = $binder; self::$valueBinder = $binder;
} }

View File

@ -503,7 +503,7 @@ abstract class Coordinate
* @param int $currentRow * @param int $currentRow
* @param int $endRow * @param int $endRow
*/ */
private static function validateRange($cellBlock, $startColumnIndex, $endColumnIndex, $currentRow, $endRow) private static function validateRange($cellBlock, $startColumnIndex, $endColumnIndex, $currentRow, $endRow): void
{ {
if ($startColumnIndex >= $endColumnIndex || $currentRow > $endRow) { if ($startColumnIndex >= $endColumnIndex || $currentRow > $endRow) {
throw new Exception('Invalid range: "' . $cellBlock . '"'); throw new Exception('Invalid range: "' . $cellBlock . '"');

View File

@ -178,7 +178,7 @@ class Axis extends Properties
* @param string $major_unit * @param string $major_unit
* @param string $minor_unit * @param string $minor_unit
*/ */
public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null) public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null): void
{ {
$this->axisOptions['axis_labels'] = (string) $axis_labels; $this->axisOptions['axis_labels'] = (string) $axis_labels;
($horizontal_crosses_value !== null) ? $this->axisOptions['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null; ($horizontal_crosses_value !== null) ? $this->axisOptions['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null;
@ -210,7 +210,7 @@ class Axis extends Properties
* *
* @param string $orientation * @param string $orientation
*/ */
public function setAxisOrientation($orientation) public function setAxisOrientation($orientation): void
{ {
$this->axisOptions['orientation'] = (string) $orientation; $this->axisOptions['orientation'] = (string) $orientation;
} }
@ -222,7 +222,7 @@ class Axis extends Properties
* @param int $alpha * @param int $alpha
* @param string $type * @param string $type
*/ */
public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB): void
{ {
$this->fillProperties = $this->setColorProperties($color, $alpha, $type); $this->fillProperties = $this->setColorProperties($color, $alpha, $type);
} }
@ -234,7 +234,7 @@ class Axis extends Properties
* @param int $alpha * @param int $alpha
* @param string $type * @param string $type
*/ */
public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB): void
{ {
$this->lineProperties = $this->setColorProperties($color, $alpha, $type); $this->lineProperties = $this->setColorProperties($color, $alpha, $type);
} }
@ -276,7 +276,7 @@ class Axis extends Properties
* @param string $end_arrow_type * @param string $end_arrow_type
* @param string $end_arrow_size * @param string $end_arrow_size
*/ */
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): void
{ {
($line_width !== null) ? $this->lineStyleProperties['width'] = $this->getExcelPointsWidth((float) $line_width) : null; ($line_width !== null) ? $this->lineStyleProperties['width'] = $this->getExcelPointsWidth((float) $line_width) : null;
($compound_type !== null) ? $this->lineStyleProperties['compound'] = (string) $compound_type : null; ($compound_type !== null) ? $this->lineStyleProperties['compound'] = (string) $compound_type : null;
@ -336,7 +336,7 @@ class Axis extends Properties
* @param int $sh_angle * @param int $sh_angle
* @param float $sh_distance * @param float $sh_distance
*/ */
public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null) public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null): void
{ {
$this->setShadowPresetsProperties((int) $sh_presets) $this->setShadowPresetsProperties((int) $sh_presets)
->setShadowColor( ->setShadowColor(
@ -367,7 +367,6 @@ class Axis extends Properties
/** /**
* Set Shadow Properties from Mapped Values. * Set Shadow Properties from Mapped Values.
* *
* @param array $properties_map
* @param mixed &$reference * @param mixed &$reference
* *
* @return $this * @return $this
@ -479,7 +478,7 @@ class Axis extends Properties
* @param int $color_alpha * @param int $color_alpha
* @param string $color_type * @param string $color_type
*/ */
public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null): void
{ {
$this->setGlowSize($size) $this->setGlowSize($size)
->setGlowColor( ->setGlowColor(
@ -538,7 +537,7 @@ class Axis extends Properties
* *
* @param float $size * @param float $size
*/ */
public function setSoftEdges($size) public function setSoftEdges($size): void
{ {
if ($size !== null) { if ($size !== null) {
$softEdges['size'] = (string) $this->getExcelPointsWidth($size); $softEdges['size'] = (string) $this->getExcelPointsWidth($size);

View File

@ -144,19 +144,10 @@ class Chart
* Create a new Chart. * Create a new Chart.
* *
* @param mixed $name * @param mixed $name
* @param null|Title $title
* @param null|Legend $legend
* @param null|PlotArea $plotArea
* @param mixed $plotVisibleOnly * @param mixed $plotVisibleOnly
* @param string $displayBlanksAs * @param string $displayBlanksAs
* @param null|Title $xAxisLabel
* @param null|Title $yAxisLabel
* @param null|Axis $xAxis
* @param null|Axis $yAxis
* @param null|GridLines $majorGridlines
* @param null|GridLines $minorGridlines
*/ */
public function __construct($name, Title $title = null, Legend $legend = null, PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = DataSeries::EMPTY_AS_GAP, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null) public function __construct($name, ?Title $title = null, ?Legend $legend = null, ?PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = DataSeries::EMPTY_AS_GAP, ?Title $xAxisLabel = null, ?Title $yAxisLabel = null, ?Axis $xAxis = null, ?Axis $yAxis = null, ?GridLines $majorGridlines = null, ?GridLines $minorGridlines = null)
{ {
$this->name = $name; $this->name = $name;
$this->title = $title; $this->title = $title;
@ -199,7 +190,7 @@ class Chart
* *
* @return $this * @return $this
*/ */
public function setWorksheet(Worksheet $pValue = null) public function setWorksheet(?Worksheet $pValue = null)
{ {
$this->worksheet = $pValue; $this->worksheet = $pValue;
@ -219,8 +210,6 @@ class Chart
/** /**
* Set Title. * Set Title.
* *
* @param Title $title
*
* @return $this * @return $this
*/ */
public function setTitle(Title $title) public function setTitle(Title $title)
@ -243,8 +232,6 @@ class Chart
/** /**
* Set Legend. * Set Legend.
* *
* @param Legend $legend
*
* @return $this * @return $this
*/ */
public function setLegend(Legend $legend) public function setLegend(Legend $legend)
@ -267,8 +254,6 @@ class Chart
/** /**
* Set X-Axis Label. * Set X-Axis Label.
* *
* @param Title $label
*
* @return $this * @return $this
*/ */
public function setXAxisLabel(Title $label) public function setXAxisLabel(Title $label)
@ -291,8 +276,6 @@ class Chart
/** /**
* Set Y-Axis Label. * Set Y-Axis Label.
* *
* @param Title $label
*
* @return $this * @return $this
*/ */
public function setYAxisLabel(Title $label) public function setYAxisLabel(Title $label)
@ -645,7 +628,7 @@ class Chart
return $this->bottomRightYOffset; return $this->bottomRightYOffset;
} }
public function refresh() public function refresh(): void
{ {
if ($this->worksheet !== null) { if ($this->worksheet !== null) {
$this->plotArea->refresh($this->worksheet); $this->plotArea->refresh($this->worksheet);

View File

@ -373,7 +373,7 @@ class DataSeries
return $this; return $this;
} }
public function refresh(Worksheet $worksheet) public function refresh(Worksheet $worksheet): void
{ {
foreach ($this->plotValues as $plotValues) { foreach ($this->plotValues as $plotValues) {
if ($plotValues !== null) { if ($plotValues !== null) {

View File

@ -352,7 +352,7 @@ class DataSeriesValues
return $this; return $this;
} }
public function refresh(Worksheet $worksheet, $flatten = true) public function refresh(Worksheet $worksheet, $flatten = true): void
{ {
if ($this->dataSource !== null) { if ($this->dataSource !== null) {
$calcEngine = Calculation::getInstance($worksheet->getParent()); $calcEngine = Calculation::getInstance($worksheet->getParent());

View File

@ -107,7 +107,7 @@ class GridLines extends Properties
* @param int $alpha * @param int $alpha
* @param string $type * @param string $type
*/ */
public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD) public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD): void
{ {
$this->activateObject() $this->activateObject()
->lineProperties['color'] = $this->setColorProperties( ->lineProperties['color'] = $this->setColorProperties(
@ -130,7 +130,7 @@ class GridLines extends Properties
* @param string $end_arrow_type * @param string $end_arrow_type
* @param string $end_arrow_size * @param string $end_arrow_size
*/ */
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): void
{ {
$this->activateObject(); $this->activateObject();
($line_width !== null) ($line_width !== null)
@ -194,7 +194,7 @@ class GridLines extends Properties
* @param int $color_alpha * @param int $color_alpha
* @param string $color_type * @param string $color_type
*/ */
public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null): void
{ {
$this $this
->activateObject() ->activateObject()
@ -286,7 +286,7 @@ class GridLines extends Properties
* @param int $sh_angle * @param int $sh_angle
* @param float $sh_distance * @param float $sh_distance
*/ */
public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null) public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null): void
{ {
$this->activateObject() $this->activateObject()
->setShadowPresetsProperties((int) $sh_presets) ->setShadowPresetsProperties((int) $sh_presets)
@ -318,7 +318,6 @@ class GridLines extends Properties
/** /**
* Set Shadow Properties Values. * Set Shadow Properties Values.
* *
* @param array $properties_map
* @param mixed &$reference * @param mixed &$reference
* *
* @return $this * @return $this
@ -435,7 +434,7 @@ class GridLines extends Properties
* *
* @param float $size * @param float $size
*/ */
public function setSoftEdgesSize($size) public function setSoftEdgesSize($size): void
{ {
if ($size !== null) { if ($size !== null) {
$this->activateObject(); $this->activateObject();

View File

@ -110,8 +110,6 @@ class Layout
/** /**
* Create a new Layout. * Create a new Layout.
*
* @param array $layout
*/ */
public function __construct(array $layout = []) public function __construct(array $layout = [])
{ {

View File

@ -52,10 +52,9 @@ class Legend
* Create a new Legend. * Create a new Legend.
* *
* @param string $position * @param string $position
* @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)
{ {
$this->setPosition($position); $this->setPosition($position);
$this->layout = $layout; $this->layout = $layout;

View File

@ -23,10 +23,9 @@ class PlotArea
/** /**
* Create a new PlotArea. * Create a new PlotArea.
* *
* @param null|Layout $layout
* @param DataSeries[] $plotSeries * @param DataSeries[] $plotSeries
*/ */
public function __construct(Layout $layout = null, array $plotSeries = []) public function __construct(?Layout $layout = null, array $plotSeries = [])
{ {
$this->layout = $layout; $this->layout = $layout;
$this->plotSeries = $plotSeries; $this->plotSeries = $plotSeries;
@ -103,7 +102,7 @@ class PlotArea
return $this; return $this;
} }
public function refresh(Worksheet $worksheet) public function refresh(Worksheet $worksheet): void
{ {
foreach ($this->plotSeries as $plotSeries) { foreach ($this->plotSeries as $plotSeries) {
$plotSeries->refresh($worksheet); $plotSeries->refresh($worksheet);

View File

@ -8,8 +8,6 @@ interface IRenderer
{ {
/** /**
* IRenderer constructor. * IRenderer constructor.
*
* @param \PhpOffice\PhpSpreadsheet\Chart\Chart $chart
*/ */
public function __construct(Chart $chart); public function __construct(Chart $chart);

View File

@ -2,8 +2,24 @@
namespace PhpOffice\PhpSpreadsheet\Chart\Renderer; namespace PhpOffice\PhpSpreadsheet\Chart\Renderer;
use AccBarPlot;
use AccLinePlot;
use BarPlot;
use ContourPlot;
use Graph;
use GroupBarPlot;
use LinePlot;
use PhpOffice\PhpSpreadsheet\Chart\Chart; use PhpOffice\PhpSpreadsheet\Chart\Chart;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PieGraph;
use PiePlot;
use PiePlot3D;
use PiePlotC;
use RadarGraph;
use RadarPlot;
use ScatterPlot;
use Spline;
use StockPlot;
require_once __DIR__ . '/Polyfill.php'; require_once __DIR__ . '/Polyfill.php';
@ -33,8 +49,6 @@ class JpGraph implements IRenderer
/** /**
* Create a new jpgraph. * Create a new jpgraph.
*
* @param Chart $chart
*/ */
public function __construct(Chart $chart) public function __construct(Chart $chart)
{ {
@ -43,7 +57,7 @@ class JpGraph implements IRenderer
$this->chart = $chart; $this->chart = $chart;
} }
private static function init() private static function init(): void
{ {
static $loaded = false; static $loaded = false;
if ($loaded) { if ($loaded) {
@ -179,7 +193,7 @@ class JpGraph implements IRenderer
return $caption; return $caption;
} }
private function renderTitle() private function renderTitle(): void
{ {
$title = $this->getCaption($this->chart->getTitle()); $title = $this->getCaption($this->chart->getTitle());
if ($title !== null) { if ($title !== null) {
@ -187,7 +201,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderLegend() private function renderLegend(): void
{ {
$legend = $this->chart->getLegend(); $legend = $this->chart->getLegend();
if ($legend !== null) { if ($legend !== null) {
@ -220,9 +234,9 @@ class JpGraph implements IRenderer
} }
} }
private function renderCartesianPlotArea($type = 'textlin') private function renderCartesianPlotArea($type = 'textlin'): void
{ {
$this->graph = new \Graph(self::$width, self::$height); $this->graph = new Graph(self::$width, self::$height);
$this->graph->SetScale($type); $this->graph->SetScale($type);
$this->renderTitle(); $this->renderTitle();
@ -257,22 +271,22 @@ class JpGraph implements IRenderer
} }
} }
private function renderPiePlotArea() private function renderPiePlotArea(): void
{ {
$this->graph = new \PieGraph(self::$width, self::$height); $this->graph = new PieGraph(self::$width, self::$height);
$this->renderTitle(); $this->renderTitle();
} }
private function renderRadarPlotArea() private function renderRadarPlotArea(): void
{ {
$this->graph = new \RadarGraph(self::$width, self::$height); $this->graph = new RadarGraph(self::$width, self::$height);
$this->graph->SetScale('lin'); $this->graph->SetScale('lin');
$this->renderTitle(); $this->renderTitle();
} }
private function renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d') private function renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d'): void
{ {
$grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); $grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
@ -308,7 +322,7 @@ class JpGraph implements IRenderer
++$testCurrentIndex; ++$testCurrentIndex;
} }
$seriesPlot = new \LinePlot($dataValues); $seriesPlot = new LinePlot($dataValues);
if ($combination) { if ($combination) {
$seriesPlot->SetBarCenter(); $seriesPlot->SetBarCenter();
} }
@ -330,12 +344,12 @@ class JpGraph implements IRenderer
if ($grouping == 'standard') { if ($grouping == 'standard') {
$groupPlot = $seriesPlots; $groupPlot = $seriesPlots;
} else { } else {
$groupPlot = new \AccLinePlot($seriesPlots); $groupPlot = new AccLinePlot($seriesPlots);
} }
$this->graph->Add($groupPlot); $this->graph->Add($groupPlot);
} }
private function renderPlotBar($groupID, $dimensions = '2d') private function renderPlotBar($groupID, $dimensions = '2d'): void
{ {
$rotation = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection(); $rotation = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
// Rotate for bar rather than column chart // Rotate for bar rather than column chart
@ -385,7 +399,7 @@ class JpGraph implements IRenderer
if ($rotation == 'bar') { if ($rotation == 'bar') {
$dataValues = array_reverse($dataValues); $dataValues = array_reverse($dataValues);
} }
$seriesPlot = new \BarPlot($dataValues); $seriesPlot = new BarPlot($dataValues);
$seriesPlot->SetColor('black'); $seriesPlot->SetColor('black');
$seriesPlot->SetFillColor(self::$colourSet[self::$plotColour++]); $seriesPlot->SetFillColor(self::$colourSet[self::$plotColour++]);
if ($dimensions == '3d') { if ($dimensions == '3d') {
@ -406,11 +420,11 @@ class JpGraph implements IRenderer
} }
if ($grouping == 'clustered') { if ($grouping == 'clustered') {
$groupPlot = new \GroupBarPlot($seriesPlots); $groupPlot = new GroupBarPlot($seriesPlots);
} elseif ($grouping == 'standard') { } elseif ($grouping == 'standard') {
$groupPlot = new \GroupBarPlot($seriesPlots); $groupPlot = new GroupBarPlot($seriesPlots);
} else { } else {
$groupPlot = new \AccBarPlot($seriesPlots); $groupPlot = new AccBarPlot($seriesPlots);
if ($dimensions == '3d') { if ($dimensions == '3d') {
$groupPlot->SetShadow(); $groupPlot->SetShadow();
} }
@ -419,7 +433,7 @@ class JpGraph implements IRenderer
$this->graph->Add($groupPlot); $this->graph->Add($groupPlot);
} }
private function renderPlotScatter($groupID, $bubble) private function renderPlotScatter($groupID, $bubble): void
{ {
$grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); $grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
$scatterStyle = $bubbleSize = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); $scatterStyle = $bubbleSize = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
@ -436,14 +450,14 @@ class JpGraph implements IRenderer
$dataValuesY[$k] = $k; $dataValuesY[$k] = $k;
} }
$seriesPlot = new \ScatterPlot($dataValuesX, $dataValuesY); $seriesPlot = new ScatterPlot($dataValuesX, $dataValuesY);
if ($scatterStyle == 'lineMarker') { if ($scatterStyle == 'lineMarker') {
$seriesPlot->SetLinkPoints(); $seriesPlot->SetLinkPoints();
$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);
[$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]);
$this->graph->Add($lplot); $this->graph->Add($lplot);
@ -464,7 +478,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderPlotRadar($groupID) private function renderPlotRadar($groupID): void
{ {
$radarStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); $radarStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
@ -488,7 +502,7 @@ class JpGraph implements IRenderer
$this->graph->SetTitles(array_reverse($dataValues)); $this->graph->SetTitles(array_reverse($dataValues));
$seriesPlot = new \RadarPlot(array_reverse($dataValuesX)); $seriesPlot = new RadarPlot(array_reverse($dataValuesX));
$dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); $dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
$seriesPlot->SetColor(self::$colourSet[self::$plotColour++]); $seriesPlot->SetColor(self::$colourSet[self::$plotColour++]);
@ -502,7 +516,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderPlotContour($groupID) private function renderPlotContour($groupID): void
{ {
$contourStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); $contourStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
@ -517,12 +531,12 @@ class JpGraph implements IRenderer
$dataValues[$i] = $dataValuesX; $dataValues[$i] = $dataValuesX;
} }
$seriesPlot = new \ContourPlot($dataValues); $seriesPlot = new ContourPlot($dataValues);
$this->graph->Add($seriesPlot); $this->graph->Add($seriesPlot);
} }
private function renderPlotStock($groupID) private function renderPlotStock($groupID): void
{ {
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
$plotOrder = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder(); $plotOrder = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder();
@ -556,13 +570,13 @@ class JpGraph implements IRenderer
$this->graph->xaxis->SetTickLabels($datasetLabels); $this->graph->xaxis->SetTickLabels($datasetLabels);
} }
$seriesPlot = new \StockPlot($dataValuesPlot); $seriesPlot = new StockPlot($dataValuesPlot);
$seriesPlot->SetWidth(20); $seriesPlot->SetWidth(20);
$this->graph->Add($seriesPlot); $this->graph->Add($seriesPlot);
} }
private function renderAreaChart($groupCount, $dimensions = '2d') private function renderAreaChart($groupCount, $dimensions = '2d'): void
{ {
$this->renderCartesianPlotArea(); $this->renderCartesianPlotArea();
@ -571,7 +585,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderLineChart($groupCount, $dimensions = '2d') private function renderLineChart($groupCount, $dimensions = '2d'): void
{ {
$this->renderCartesianPlotArea(); $this->renderCartesianPlotArea();
@ -580,7 +594,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderBarChart($groupCount, $dimensions = '2d') private function renderBarChart($groupCount, $dimensions = '2d'): void
{ {
$this->renderCartesianPlotArea(); $this->renderCartesianPlotArea();
@ -589,7 +603,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderScatterChart($groupCount) private function renderScatterChart($groupCount): void
{ {
$this->renderCartesianPlotArea('linlin'); $this->renderCartesianPlotArea('linlin');
@ -598,7 +612,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderBubbleChart($groupCount) private function renderBubbleChart($groupCount): void
{ {
$this->renderCartesianPlotArea('linlin'); $this->renderCartesianPlotArea('linlin');
@ -607,7 +621,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = false, $multiplePlots = false) private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = false, $multiplePlots = false): void
{ {
$this->renderPiePlotArea(); $this->renderPiePlotArea();
@ -643,12 +657,12 @@ class JpGraph implements IRenderer
} }
if ($dimensions == '3d') { if ($dimensions == '3d') {
$seriesPlot = new \PiePlot3D($dataValues); $seriesPlot = new PiePlot3D($dataValues);
} else { } else {
if ($doughnut) { if ($doughnut) {
$seriesPlot = new \PiePlotC($dataValues); $seriesPlot = new PiePlotC($dataValues);
} else { } else {
$seriesPlot = new \PiePlot($dataValues); $seriesPlot = new PiePlot($dataValues);
} }
} }
@ -679,7 +693,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderRadarChart($groupCount) private function renderRadarChart($groupCount): void
{ {
$this->renderRadarPlotArea(); $this->renderRadarPlotArea();
@ -688,7 +702,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderStockChart($groupCount) private function renderStockChart($groupCount): void
{ {
$this->renderCartesianPlotArea('intint'); $this->renderCartesianPlotArea('intint');
@ -697,7 +711,7 @@ class JpGraph implements IRenderer
} }
} }
private function renderContourChart($groupCount, $dimensions) private function renderContourChart($groupCount, $dimensions): void
{ {
$this->renderCartesianPlotArea('intint'); $this->renderCartesianPlotArea('intint');

View File

@ -2,7 +2,7 @@
// This is a dirty workaround to output JpGraph charts even when antialiasing is not available // This is a dirty workaround to output JpGraph charts even when antialiasing is not available
if (!function_exists('imageantialias')) { if (!function_exists('imageantialias')) {
function imageantialias(...$args) function imageantialias(...$args): void
{ {
// Do nothing // Do nothing
} }

View File

@ -22,9 +22,8 @@ class Title
* Create a new Title. * Create a new Title.
* *
* @param null|mixed $caption * @param null|mixed $caption
* @param null|Layout $layout
*/ */
public function __construct($caption = null, Layout $layout = null) public function __construct($caption = null, ?Layout $layout = null)
{ {
$this->caption = $caption; $this->caption = $caption;
$this->layout = $layout; $this->layout = $layout;

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Collection; namespace PhpOffice\PhpSpreadsheet\Collection;
use Generator;
use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
@ -61,7 +62,6 @@ class Cells
* Initialise this new cell collection. * Initialise this new cell collection.
* *
* @param Worksheet $parent The worksheet for this cell collection * @param Worksheet $parent The worksheet for this cell collection
* @param CacheInterface $cache
*/ */
public function __construct(Worksheet $parent, CacheInterface $cache) public function __construct(Worksheet $parent, CacheInterface $cache)
{ {
@ -117,7 +117,7 @@ class Cells
* *
* @param string $pCoord Coordinate of the cell to delete * @param string $pCoord Coordinate of the cell to delete
*/ */
public function delete($pCoord) public function delete($pCoord): void
{ {
if ($pCoord === $this->currentCoordinate && $this->currentCell !== null) { if ($pCoord === $this->currentCoordinate && $this->currentCell !== null) {
$this->currentCell->detach(); $this->currentCell->detach();
@ -346,7 +346,7 @@ class Cells
* *
* @param string $row Row number to remove * @param string $row Row number to remove
*/ */
public function removeRow($row) public function removeRow($row): void
{ {
foreach ($this->getCoordinates() as $coord) { foreach ($this->getCoordinates() as $coord) {
$c = ''; $c = '';
@ -364,7 +364,7 @@ class Cells
* *
* @param string $column Column ID to remove * @param string $column Column ID to remove
*/ */
public function removeColumn($column) public function removeColumn($column): void
{ {
foreach ($this->getCoordinates() as $coord) { foreach ($this->getCoordinates() as $coord) {
$c = ''; $c = '';
@ -381,7 +381,7 @@ class Cells
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object. * and the 'nullify' the current cell object.
*/ */
private function storeCurrentCell() private function storeCurrentCell(): void
{ {
if ($this->currentCellIsDirty && !empty($this->currentCoordinate)) { if ($this->currentCellIsDirty && !empty($this->currentCoordinate)) {
$this->currentCell->detach(); $this->currentCell->detach();
@ -459,7 +459,7 @@ class Cells
/** /**
* Clear the cell collection and disconnect from our parent. * Clear the cell collection and disconnect from our parent.
*/ */
public function unsetWorksheetCells() public function unsetWorksheetCells(): void
{ {
if ($this->currentCell !== null) { if ($this->currentCell !== null) {
$this->currentCell->detach(); $this->currentCell->detach();
@ -487,7 +487,7 @@ class Cells
/** /**
* Returns all known cache keys. * Returns all known cache keys.
* *
* @return \Generator|string[] * @return Generator|string[]
*/ */
private function getAllCacheKeys() private function getAllCacheKeys()
{ {

View File

@ -118,8 +118,6 @@ class Comment implements IComparable
/** /**
* Set Rich text comment. * Set Rich text comment.
* *
* @param RichText $pValue
*
* @return $this * @return $this
*/ */
public function setText(RichText $pValue) public function setText(RichText $pValue)

View File

@ -11,8 +11,6 @@ class DocumentGenerator
{ {
/** /**
* @param array[] $phpSpreadsheetFunctions * @param array[] $phpSpreadsheetFunctions
*
* @return string
*/ */
public static function generateFunctionListByCategory(array $phpSpreadsheetFunctions): string public static function generateFunctionListByCategory(array $phpSpreadsheetFunctions): string
{ {
@ -40,7 +38,7 @@ class DocumentGenerator
return (new ReflectionClass(Category::class))->getConstants(); return (new ReflectionClass(Category::class))->getConstants();
} }
private static function tableRow(array $lengths, array $values = null): string private static function tableRow(array $lengths, ?array $values = null): string
{ {
$result = ''; $result = '';
foreach (array_map(null, $lengths, $values ?? []) as $i => [$length, $value]) { foreach (array_map(null, $lengths, $values ?? []) as $i => [$length, $value]) {
@ -73,8 +71,6 @@ class DocumentGenerator
/** /**
* @param array[] $phpSpreadsheetFunctions * @param array[] $phpSpreadsheetFunctions
*
* @return string
*/ */
public static function generateFunctionListByName(array $phpSpreadsheetFunctions): string public static function generateFunctionListByName(array $phpSpreadsheetFunctions): string
{ {

View File

@ -36,7 +36,7 @@ class HashTable
* *
* @param IComparable[] $pSource Source array to create HashTable from * @param IComparable[] $pSource Source array to create HashTable from
*/ */
public function addFromSource(array $pSource = null) public function addFromSource(?array $pSource = null): void
{ {
// Check if an array was passed // Check if an array was passed
if ($pSource == null) { if ($pSource == null) {
@ -53,7 +53,7 @@ class HashTable
* *
* @param IComparable $pSource Item to add * @param IComparable $pSource Item to add
*/ */
public function add(IComparable $pSource) public function add(IComparable $pSource): void
{ {
$hash = $pSource->getHashCode(); $hash = $pSource->getHashCode();
if (!isset($this->items[$hash])) { if (!isset($this->items[$hash])) {
@ -67,7 +67,7 @@ class HashTable
* *
* @param IComparable $pSource Item to remove * @param IComparable $pSource Item to remove
*/ */
public function remove(IComparable $pSource) public function remove(IComparable $pSource): void
{ {
$hash = $pSource->getHashCode(); $hash = $pSource->getHashCode();
if (isset($this->items[$hash])) { if (isset($this->items[$hash])) {
@ -90,7 +90,7 @@ class HashTable
/** /**
* Clear HashTable. * Clear HashTable.
*/ */
public function clear() public function clear(): void
{ {
$this->items = []; $this->items = [];
$this->keyMap = []; $this->keyMap = [];

View File

@ -593,7 +593,7 @@ class Html
*/ */
protected $richTextObject; protected $richTextObject;
protected function initialise() protected function initialise(): void
{ {
$this->face = $this->size = $this->color = null; $this->face = $this->size = $this->color = null;
$this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false; $this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
@ -632,7 +632,7 @@ class Html
return $this->richTextObject; return $this->richTextObject;
} }
protected function cleanWhitespace() protected function cleanWhitespace(): void
{ {
foreach ($this->richTextObject->getRichTextElements() as $key => $element) { foreach ($this->richTextObject->getRichTextElements() as $key => $element) {
$text = $element->getText(); $text = $element->getText();
@ -646,7 +646,7 @@ class Html
} }
} }
protected function buildTextRun() protected function buildTextRun(): void
{ {
$text = $this->stringData; $text = $this->stringData;
if (trim($text) === '') { if (trim($text) === '') {
@ -691,7 +691,7 @@ class Html
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT); $value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
} }
return implode($values[0]); return implode('', $values[0]);
} }
protected function colourNameLookup($rgb) protected function colourNameLookup($rgb)
@ -699,7 +699,7 @@ class Html
return self::$colourMap[$rgb]; return self::$colourMap[$rgb];
} }
protected function startFontTag($tag) protected function startFontTag($tag): void
{ {
foreach ($tag->attributes as $attribute) { foreach ($tag->attributes as $attribute) {
$attributeName = strtolower($attribute->name); $attributeName = strtolower($attribute->name);
@ -719,77 +719,77 @@ class Html
} }
} }
protected function endFontTag() protected function endFontTag(): void
{ {
$this->face = $this->size = $this->color = null; $this->face = $this->size = $this->color = null;
} }
protected function startBoldTag() protected function startBoldTag(): void
{ {
$this->bold = true; $this->bold = true;
} }
protected function endBoldTag() protected function endBoldTag(): void
{ {
$this->bold = false; $this->bold = false;
} }
protected function startItalicTag() protected function startItalicTag(): void
{ {
$this->italic = true; $this->italic = true;
} }
protected function endItalicTag() protected function endItalicTag(): void
{ {
$this->italic = false; $this->italic = false;
} }
protected function startUnderlineTag() protected function startUnderlineTag(): void
{ {
$this->underline = true; $this->underline = true;
} }
protected function endUnderlineTag() protected function endUnderlineTag(): void
{ {
$this->underline = false; $this->underline = false;
} }
protected function startSubscriptTag() protected function startSubscriptTag(): void
{ {
$this->subscript = true; $this->subscript = true;
} }
protected function endSubscriptTag() protected function endSubscriptTag(): void
{ {
$this->subscript = false; $this->subscript = false;
} }
protected function startSuperscriptTag() protected function startSuperscriptTag(): void
{ {
$this->superscript = true; $this->superscript = true;
} }
protected function endSuperscriptTag() protected function endSuperscriptTag(): void
{ {
$this->superscript = false; $this->superscript = false;
} }
protected function startStrikethruTag() protected function startStrikethruTag(): void
{ {
$this->strikethrough = true; $this->strikethrough = true;
} }
protected function endStrikethruTag() protected function endStrikethruTag(): void
{ {
$this->strikethrough = false; $this->strikethrough = false;
} }
protected function breakTag() protected function breakTag(): void
{ {
$this->stringData .= "\n"; $this->stringData .= "\n";
} }
protected function parseTextNode(DOMText $textNode) protected function parseTextNode(DOMText $textNode): void
{ {
$domText = preg_replace( $domText = preg_replace(
'/\s+/u', '/\s+/u',
@ -801,11 +801,9 @@ class Html
} }
/** /**
* @param DOMElement $element
* @param string $callbackTag * @param string $callbackTag
* @param array $callbacks
*/ */
protected function handleCallback(DOMElement $element, $callbackTag, array $callbacks) protected function handleCallback(DOMElement $element, $callbackTag, array $callbacks): void
{ {
if (isset($callbacks[$callbackTag])) { if (isset($callbacks[$callbackTag])) {
$elementHandler = $callbacks[$callbackTag]; $elementHandler = $callbacks[$callbackTag];
@ -815,7 +813,7 @@ class Html
} }
} }
protected function parseElementNode(DOMElement $element) protected function parseElementNode(DOMElement $element): void
{ {
$callbackTag = strtolower($element->nodeName); $callbackTag = strtolower($element->nodeName);
$this->stack[] = $callbackTag; $this->stack[] = $callbackTag;
@ -828,7 +826,7 @@ class Html
$this->handleCallback($element, $callbackTag, $this->endTagCallbacks); $this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
} }
protected function parseElements(DOMNode $element) protected function parseElements(DOMNode $element): void
{ {
foreach ($element->childNodes as $child) { foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) { if ($child instanceof DOMText) {

View File

@ -11,6 +11,7 @@ use RecursiveIteratorIterator;
use RecursiveRegexIterator; use RecursiveRegexIterator;
use ReflectionClass; use ReflectionClass;
use RegexIterator; use RegexIterator;
use RuntimeException;
/** /**
* Helper class to be used in sample code. * Helper class to be used in sample code.
@ -106,11 +107,10 @@ class Sample
/** /**
* Write documents. * Write documents.
* *
* @param Spreadsheet $spreadsheet
* @param string $filename * @param string $filename
* @param string[] $writers * @param string[] $writers
*/ */
public function write(Spreadsheet $spreadsheet, $filename, array $writers = ['Xlsx', 'Xls']) public function write(Spreadsheet $spreadsheet, $filename, array $writers = ['Xlsx', 'Xls']): void
{ {
// Set active sheet index to the first sheet, so Excel opens this as the first sheet // Set active sheet index to the first sheet, so Excel opens this as the first sheet
$spreadsheet->setActiveSheetIndex(0); $spreadsheet->setActiveSheetIndex(0);
@ -142,7 +142,7 @@ class Sample
$tempFolder = sys_get_temp_dir() . '/phpspreadsheet'; $tempFolder = sys_get_temp_dir() . '/phpspreadsheet';
if (!is_dir($tempFolder)) { if (!is_dir($tempFolder)) {
if (!mkdir($tempFolder) && !is_dir($tempFolder)) { if (!mkdir($tempFolder) && !is_dir($tempFolder)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $tempFolder)); throw new RuntimeException(sprintf('Directory "%s" was not created', $tempFolder));
} }
} }
@ -179,7 +179,7 @@ class Sample
return $temporaryFilename . '.' . $extension; return $temporaryFilename . '.' . $extension;
} }
public function log($message) public function log($message): void
{ {
$eol = $this->isCli() ? PHP_EOL : '<br />'; $eol = $this->isCli() ? PHP_EOL : '<br />';
echo date('H:i:s ') . $message . $eol; echo date('H:i:s ') . $message . $eol;
@ -188,7 +188,7 @@ class Sample
/** /**
* Log ending notes. * Log ending notes.
*/ */
public function logEndingNotes() public function logEndingNotes(): void
{ {
// Do not show execution time for index // Do not show execution time for index
$this->log('Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . 'MB'); $this->log('Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . 'MB');
@ -197,11 +197,10 @@ class Sample
/** /**
* Log a line about the write operation. * Log a line about the write operation.
* *
* @param IWriter $writer
* @param string $path * @param string $path
* @param float $callStartTime * @param float $callStartTime
*/ */
public function logWrite(IWriter $writer, $path, $callStartTime) public function logWrite(IWriter $writer, $path, $callStartTime): void
{ {
$callEndTime = microtime(true); $callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime; $callTime = $callEndTime - $callStartTime;
@ -219,7 +218,7 @@ class Sample
* @param string $path * @param string $path
* @param float $callStartTime * @param float $callStartTime
*/ */
public function logRead($format, $path, $callStartTime) public function logRead($format, $path, $callStartTime): void
{ {
$callEndTime = microtime(true); $callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime; $callTime = $callEndTime - $callStartTime;

View File

@ -37,7 +37,6 @@ abstract class IOFactory
/** /**
* Create Writer\IWriter. * Create Writer\IWriter.
* *
* @param Spreadsheet $spreadsheet
* @param string $writerType Example: Xlsx * @param string $writerType Example: Xlsx
* *
* @return Writer\IWriter * @return Writer\IWriter
@ -192,7 +191,7 @@ abstract class IOFactory
* @param string $writerType * @param string $writerType
* @param string $writerClass * @param string $writerClass
*/ */
public static function registerWriter($writerType, $writerClass) public static function registerWriter($writerType, $writerClass): void
{ {
if (!is_a($writerClass, Writer\IWriter::class, true)) { if (!is_a($writerClass, Writer\IWriter::class, true)) {
throw new Writer\Exception('Registered writers must implement ' . Writer\IWriter::class); throw new Writer\Exception('Registered writers must implement ' . Writer\IWriter::class);
@ -207,7 +206,7 @@ abstract class IOFactory
* @param string $readerType * @param string $readerType
* @param string $readerClass * @param string $readerClass
*/ */
public static function registerReader($readerType, $readerClass) public static function registerReader($readerType, $readerClass): void
{ {
if (!is_a($readerClass, Reader\IReader::class, true)) { if (!is_a($readerClass, Reader\IReader::class, true)) {
throw new Reader\Exception('Registered readers must implement ' . Reader\IReader::class); throw new Reader\Exception('Registered readers must implement ' . Reader\IReader::class);

View File

@ -45,7 +45,6 @@ class NamedRange
* Create a new NamedRange. * Create a new NamedRange.
* *
* @param string $pName * @param string $pName
* @param Worksheet $pWorksheet
* @param string $pRange * @param string $pRange
* @param bool $pLocalOnly * @param bool $pLocalOnly
* @param null|Worksheet $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.
@ -123,7 +122,7 @@ class NamedRange
* *
* @return $this * @return $this
*/ */
public function setWorksheet(Worksheet $value = null) public function setWorksheet(?Worksheet $value = null)
{ {
if ($value !== null) { if ($value !== null) {
$this->worksheet = $value; $this->worksheet = $value;
@ -196,11 +195,9 @@ class NamedRange
/** /**
* Set scope. * Set scope.
* *
* @param null|Worksheet $value
*
* @return $this * @return $this
*/ */
public function setScope(Worksheet $value = null) public function setScope(?Worksheet $value = null)
{ {
$this->scope = $value; $this->scope = $value;
$this->localOnly = $value != null; $this->localOnly = $value != null;

View File

@ -145,12 +145,12 @@ abstract class BaseReader implements IReader
* *
* @param string $pFilename * @param string $pFilename
*/ */
protected function openFile($pFilename) protected function openFile($pFilename): void
{ {
File::assertFile($pFilename); File::assertFile($pFilename);
// Open file // Open file
$this->fileHandle = fopen($pFilename, 'r'); $this->fileHandle = fopen($pFilename, 'rb');
if ($this->fileHandle === false) { if ($this->fileHandle === false) {
throw new Exception('Could not open file ' . $pFilename . ' for reading.'); throw new Exception('Could not open file ' . $pFilename . ' for reading.');
} }

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader; namespace PhpOffice\PhpSpreadsheet\Reader;
use InvalidArgumentException;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
@ -85,7 +86,7 @@ class Csv extends BaseReader
/** /**
* Move filepointer past any BOM marker. * Move filepointer past any BOM marker.
*/ */
protected function skipBOM() protected function skipBOM(): void
{ {
rewind($this->fileHandle); rewind($this->fileHandle);
@ -101,7 +102,7 @@ class Csv extends BaseReader
/** /**
* Identify any separator that is explicitly set in the file. * Identify any separator that is explicitly set in the file.
*/ */
protected function checkSeparator() protected function checkSeparator(): void
{ {
$line = fgets($this->fileHandle); $line = fgets($this->fileHandle);
if ($line === false) { if ($line === false) {
@ -120,7 +121,7 @@ class Csv extends BaseReader
/** /**
* Infer the separator if it isn't explicitly set in the file or specified by the user. * Infer the separator if it isn't explicitly set in the file or specified by the user.
*/ */
protected function inferSeparator() protected function inferSeparator(): void
{ {
if ($this->delimiter !== null) { if ($this->delimiter !== null) {
return; return;
@ -178,7 +179,7 @@ class Csv extends BaseReader
$meanSquareDeviations[$delimiter] = array_reduce( $meanSquareDeviations[$delimiter] = array_reduce(
$series, $series,
function ($sum, $value) use ($median) { function ($sum, $value) use ($median) {
return $sum + pow($value - $median, 2); return $sum + ($value - $median) ** 2;
} }
) / count($series); ) / count($series);
} }
@ -292,7 +293,7 @@ class Csv extends BaseReader
return $this->loadIntoExisting($pFilename, $spreadsheet); return $this->loadIntoExisting($pFilename, $spreadsheet);
} }
private function openFileOrMemory($pFilename) private function openFileOrMemory($pFilename): void
{ {
// Open file // Open file
$fhandle = $this->canRead($pFilename); $fhandle = $this->canRead($pFilename);
@ -303,7 +304,7 @@ class Csv extends BaseReader
if ($this->inputEncoding !== 'UTF-8') { if ($this->inputEncoding !== 'UTF-8') {
fclose($this->fileHandle); fclose($this->fileHandle);
$entireFile = file_get_contents($pFilename); $entireFile = file_get_contents($pFilename);
$this->fileHandle = fopen('php://memory', 'r+'); $this->fileHandle = fopen('php://memory', 'r+b');
$data = StringHelper::convertEncoding($entireFile, 'UTF-8', $this->inputEncoding); $data = StringHelper::convertEncoding($entireFile, 'UTF-8', $this->inputEncoding);
fwrite($this->fileHandle, $data); fwrite($this->fileHandle, $data);
rewind($this->fileHandle); rewind($this->fileHandle);
@ -314,7 +315,6 @@ class Csv extends BaseReader
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param Spreadsheet $spreadsheet
* *
* @return Spreadsheet * @return Spreadsheet
*/ */
@ -508,7 +508,7 @@ class Csv extends BaseReader
// Check if file exists // Check if file exists
try { try {
$this->openFile($pFilename); $this->openFile($pFilename);
} catch (\InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
return false; return false;
} }

View File

@ -58,7 +58,7 @@ class Gnumeric extends BaseReader
} }
// Read signature data (first 3 bytes) // Read signature data (first 3 bytes)
$fh = fopen($pFilename, 'r'); $fh = fopen($pFilename, 'rb');
$data = fread($fh, 2); $data = fread($fh, 2);
fclose($fh); fclose($fh);
@ -182,7 +182,6 @@ class Gnumeric extends BaseReader
* Loads from file into Spreadsheet instance. * Loads from file into Spreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param Spreadsheet $spreadsheet
* *
* @return Spreadsheet * @return Spreadsheet
*/ */
@ -473,7 +472,7 @@ class Gnumeric extends BaseReader
$endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol']; $endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol'];
$endColumn = Coordinate::stringFromColumnIndex($endColumn + 1); $endColumn = Coordinate::stringFromColumnIndex($endColumn + 1);
$endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow']; $endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow'];
$endRow += 1; ++$endRow;
$cellRange = $startColumn . $startRow . ':' . $endColumn . $endRow; $cellRange = $startColumn . $startRow . ':' . $endColumn . $endRow;
$styleAttributes = $styleRegion->Style->attributes(); $styleAttributes = $styleRegion->Style->attributes();

View File

@ -270,7 +270,7 @@ class Html extends BaseReader
return array_pop($this->nestedColumn); return array_pop($this->nestedColumn);
} }
protected function flushCell(Worksheet $sheet, $column, $row, &$cellContent) protected function flushCell(Worksheet $sheet, $column, $row, &$cellContent): void
{ {
if (is_string($cellContent)) { if (is_string($cellContent)) {
// Simple String content // Simple String content
@ -290,13 +290,11 @@ class Html extends BaseReader
} }
/** /**
* @param DOMNode $element
* @param Worksheet $sheet
* @param int $row * @param int $row
* @param string $column * @param string $column
* @param string $cellContent * @param string $cellContent
*/ */
protected function processDomElement(DOMNode $element, Worksheet $sheet, &$row, &$column, &$cellContent) protected function processDomElement(DOMNode $element, Worksheet $sheet, &$row, &$column, &$cellContent): void
{ {
foreach ($element->childNodes as $child) { foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) { if ($child instanceof DOMText) {
@ -577,7 +575,6 @@ class Html extends BaseReader
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param Spreadsheet $spreadsheet
* *
* @return Spreadsheet * @return Spreadsheet
*/ */
@ -603,9 +600,6 @@ class Html extends BaseReader
* Spreadsheet from content. * Spreadsheet from content.
* *
* @param string $content * @param string $content
* @param null|Spreadsheet $spreadsheet
*
* @return Spreadsheet
*/ */
public function loadFromString($content, ?Spreadsheet $spreadsheet = null): Spreadsheet public function loadFromString($content, ?Spreadsheet $spreadsheet = null): Spreadsheet
{ {
@ -622,11 +616,6 @@ class Html extends BaseReader
/** /**
* Loads PhpSpreadsheet from DOMDocument into PhpSpreadsheet instance. * Loads PhpSpreadsheet from DOMDocument into PhpSpreadsheet instance.
*
* @param DOMDocument $document
* @param Spreadsheet $spreadsheet
*
* @return Spreadsheet
*/ */
private function loadDocument(DOMDocument $document, Spreadsheet $spreadsheet): Spreadsheet private function loadDocument(DOMDocument $document, Spreadsheet $spreadsheet): Spreadsheet
{ {
@ -687,7 +676,7 @@ class Html extends BaseReader
* @param string $column * @param string $column
* @param array $attributeArray * @param array $attributeArray
*/ */
private function applyInlineStyle(&$sheet, $row, $column, $attributeArray) private function applyInlineStyle(&$sheet, $row, $column, $attributeArray): void
{ {
if (!isset($attributeArray['style'])) { if (!isset($attributeArray['style'])) {
return; return;
@ -852,12 +841,10 @@ class Html extends BaseReader
} }
/** /**
* @param Worksheet $sheet
* @param string $column * @param string $column
* @param int $row * @param int $row
* @param array $attributes
*/ */
private function insertImage(Worksheet $sheet, $column, $row, array $attributes) private function insertImage(Worksheet $sheet, $column, $row, array $attributes): void
{ {
if (!isset($attributes['src'])) { if (!isset($attributes['src'])) {
return; return;
@ -941,11 +928,10 @@ class Html extends BaseReader
} }
/** /**
* @param Style $cellStyle
* @param string $styleValue * @param string $styleValue
* @param string $type * @param string $type
*/ */
private function setBorderStyle(Style $cellStyle, $styleValue, $type) private function setBorderStyle(Style $cellStyle, $styleValue, $type): void
{ {
[, $borderStyle, $color] = explode(' ', $styleValue); [, $borderStyle, $color] = explode(' ', $styleValue);

View File

@ -118,8 +118,6 @@ interface IReader
/** /**
* Set read filter. * Set read filter.
* *
* @param IReadFilter $pValue
*
* @return IReader * @return IReader
*/ */
public function setReadFilter(IReadFilter $pValue); public function setReadFilter(IReadFilter $pValue);

View File

@ -4,6 +4,10 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
use DateTime; use DateTime;
use DateTimeZone; use DateTimeZone;
use DOMAttr;
use DOMDocument;
use DOMElement;
use DOMNode;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Cell\DataType; use PhpOffice\PhpSpreadsheet\Cell\DataType;
@ -242,7 +246,6 @@ class Ods extends BaseReader
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param Spreadsheet $spreadsheet
* *
* @return Spreadsheet * @return Spreadsheet
*/ */
@ -251,7 +254,7 @@ class Ods extends BaseReader
File::assertFile($pFilename); File::assertFile($pFilename);
$timezoneObj = new DateTimeZone('Europe/London'); $timezoneObj = new DateTimeZone('Europe/London');
$GMT = new \DateTimeZone('UTC'); $GMT = new DateTimeZone('UTC');
$zip = new ZipArchive(); $zip = new ZipArchive();
if (!$zip->open($pFilename)) { if (!$zip->open($pFilename)) {
@ -275,7 +278,7 @@ class Ods extends BaseReader
// Content // Content
$dom = new \DOMDocument('1.01', 'UTF-8'); $dom = new DOMDocument('1.01', 'UTF-8');
$dom->loadXML( $dom->loadXML(
$this->securityScanner->scan($zip->getFromName('content.xml')), $this->securityScanner->scan($zip->getFromName('content.xml')),
Settings::getLibXmlLoaderOptions() Settings::getLibXmlLoaderOptions()
@ -291,12 +294,12 @@ class Ods extends BaseReader
->getElementsByTagNameNS($officeNs, 'spreadsheet'); ->getElementsByTagNameNS($officeNs, 'spreadsheet');
foreach ($spreadsheets as $workbookData) { foreach ($spreadsheets as $workbookData) {
/** @var \DOMElement $workbookData */ /** @var DOMElement $workbookData */
$tables = $workbookData->getElementsByTagNameNS($tableNs, 'table'); $tables = $workbookData->getElementsByTagNameNS($tableNs, 'table');
$worksheetID = 0; $worksheetID = 0;
foreach ($tables as $worksheetDataSet) { foreach ($tables as $worksheetDataSet) {
/** @var \DOMElement $worksheetDataSet */ /** @var DOMElement $worksheetDataSet */
$worksheetName = $worksheetDataSet->getAttributeNS($tableNs, 'name'); $worksheetName = $worksheetDataSet->getAttributeNS($tableNs, 'name');
// Check loadSheetsOnly // Check loadSheetsOnly
@ -322,7 +325,7 @@ class Ods extends BaseReader
// Go through every child of table element // Go through every child of table element
$rowID = 1; $rowID = 1;
foreach ($worksheetDataSet->childNodes as $childNode) { foreach ($worksheetDataSet->childNodes as $childNode) {
/** @var \DOMElement $childNode */ /** @var DOMElement $childNode */
// Filter elements which are not under the "table" ns // Filter elements which are not under the "table" ns
if ($childNode->namespaceURI != $tableNs) { if ($childNode->namespaceURI != $tableNs) {
@ -395,11 +398,11 @@ class Ods extends BaseReader
// Content // Content
/** @var \DOMElement[] $paragraphs */ /** @var DOMElement[] $paragraphs */
$paragraphs = []; $paragraphs = [];
foreach ($cellData->childNodes as $item) { foreach ($cellData->childNodes as $item) {
/** @var \DOMElement $item */ /** @var DOMElement $item */
// Filter text:p elements // Filter text:p elements
if ($item->nodeName == 'text:p') { if ($item->nodeName == 'text:p') {
@ -649,22 +652,20 @@ class Ods extends BaseReader
/** /**
* Recursively scan element. * Recursively scan element.
* *
* @param \DOMNode $element
*
* @return string * @return string
*/ */
protected function scanElementForText(\DOMNode $element) protected function scanElementForText(DOMNode $element)
{ {
$str = ''; $str = '';
foreach ($element->childNodes as $child) { foreach ($element->childNodes as $child) {
/** @var \DOMNode $child */ /** @var DOMNode $child */
if ($child->nodeType == XML_TEXT_NODE) { if ($child->nodeType == XML_TEXT_NODE) {
$str .= $child->nodeValue; $str .= $child->nodeValue;
} elseif ($child->nodeType == XML_ELEMENT_NODE && $child->nodeName == 'text:s') { } elseif ($child->nodeType == XML_ELEMENT_NODE && $child->nodeName == 'text:s') {
// It's a space // It's a space
// Multiple spaces? // Multiple spaces?
/** @var \DOMAttr $cAttr */ /** @var DOMAttr $cAttr */
$cAttr = $child->attributes->getNamedItem('c'); $cAttr = $child->attributes->getNamedItem('c');
if ($cAttr) { if ($cAttr) {
$multiplier = (int) $cAttr->nodeValue; $multiplier = (int) $cAttr->nodeValue;

View File

@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Ods;
use PhpOffice\PhpSpreadsheet\Document\Properties as DocumentProperties; use PhpOffice\PhpSpreadsheet\Document\Properties as DocumentProperties;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
use SimpleXMLElement;
class Properties class Properties
{ {
@ -14,7 +15,7 @@ class Properties
$this->spreadsheet = $spreadsheet; $this->spreadsheet = $spreadsheet;
} }
public function load(\SimpleXMLElement $xml, $namespacesMeta) public function load(SimpleXMLElement $xml, $namespacesMeta): void
{ {
$docProps = $this->spreadsheet->getProperties(); $docProps = $this->spreadsheet->getProperties();
$officeProperty = $xml->children($namespacesMeta['office']); $officeProperty = $xml->children($namespacesMeta['office']);
@ -35,7 +36,7 @@ class Properties
} }
} }
private function setCoreProperties(DocumentProperties $docProps, \SimpleXMLElement $officePropertyDC) private function setCoreProperties(DocumentProperties $docProps, SimpleXMLElement $officePropertyDC): void
{ {
foreach ($officePropertyDC as $propertyName => $propertyValue) { foreach ($officePropertyDC as $propertyName => $propertyValue) {
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
@ -73,10 +74,10 @@ class Properties
private function setMetaProperties( private function setMetaProperties(
$namespacesMeta, $namespacesMeta,
\SimpleXMLElement $propertyValue, SimpleXMLElement $propertyValue,
$propertyName, $propertyName,
DocumentProperties $docProps DocumentProperties $docProps
) { ): void {
$propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']);
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
@ -100,7 +101,7 @@ class Properties
} }
} }
private function setUserDefinedProperty($propertyValueAttributes, $propertyValue, DocumentProperties $docProps) private function setUserDefinedProperty($propertyValueAttributes, $propertyValue, DocumentProperties $docProps): void
{ {
$propertyValueName = ''; $propertyValueName = '';
$propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING; $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING;

View File

@ -61,7 +61,7 @@ class XmlScanner
return false; return false;
} }
private function disableEntityLoaderCheck() private function disableEntityLoaderCheck(): void
{ {
if (Settings::getLibXmlDisableEntityLoader()) { if (Settings::getLibXmlDisableEntityLoader()) {
$libxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true); $libxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true);
@ -72,7 +72,7 @@ class XmlScanner
} }
} }
public static function shutdown() public static function shutdown(): void
{ {
if (self::$libxmlDisableEntityLoaderValue !== null) { if (self::$libxmlDisableEntityLoaderValue !== null) {
libxml_disable_entity_loader(self::$libxmlDisableEntityLoaderValue); libxml_disable_entity_loader(self::$libxmlDisableEntityLoaderValue);
@ -85,7 +85,7 @@ class XmlScanner
self::shutdown(); self::shutdown();
} }
public function setAdditionalCallback(callable $callback) public function setAdditionalCallback(callable $callback): void
{ {
$this->callback = $callback; $this->callback = $callback;
} }

View File

@ -190,7 +190,6 @@ class Slk extends BaseReader
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param Spreadsheet $spreadsheet
* *
* @return Spreadsheet * @return Spreadsheet
*/ */

View File

@ -1248,10 +1248,10 @@ class Xls extends BaseReader
[$firstColumn, $firstRow] = Coordinate::coordinateFromString($coordinateStrings[0]); [$firstColumn, $firstRow] = Coordinate::coordinateFromString($coordinateStrings[0]);
[$lastColumn, $lastRow] = Coordinate::coordinateFromString($coordinateStrings[1]); [$lastColumn, $lastRow] = Coordinate::coordinateFromString($coordinateStrings[1]);
if ($firstColumn == 'A' and $lastColumn == 'IV') { if ($firstColumn == 'A' && $lastColumn == 'IV') {
// then we have repeating rows // then we have repeating rows
$docSheet->getPageSetup()->setRowsToRepeatAtTop([$firstRow, $lastRow]); $docSheet->getPageSetup()->setRowsToRepeatAtTop([$firstRow, $lastRow]);
} elseif ($firstRow == 1 and $lastRow == 65536) { } elseif ($firstRow == 1 && $lastRow == 65536) {
// then we have repeating columns // then we have repeating columns
$docSheet->getPageSetup()->setColumnsToRepeatAtLeft([$firstColumn, $lastColumn]); $docSheet->getPageSetup()->setColumnsToRepeatAtLeft([$firstColumn, $lastColumn]);
} }
@ -1348,7 +1348,7 @@ class Xls extends BaseReader
* *
* @param string $pFilename * @param string $pFilename
*/ */
private function loadOLE($pFilename) private function loadOLE($pFilename): void
{ {
// OLE reader // OLE reader
$ole = new OLERead(); $ole = new OLERead();
@ -1365,7 +1365,7 @@ class Xls extends BaseReader
/** /**
* Read summary information. * Read summary information.
*/ */
private function readSummaryInformation() private function readSummaryInformation(): void
{ {
if (!isset($this->summaryInformation)) { if (!isset($this->summaryInformation)) {
return; return;
@ -1512,7 +1512,7 @@ class Xls extends BaseReader
/** /**
* Read additional document summary information. * Read additional document summary information.
*/ */
private function readDocumentSummaryInformation() private function readDocumentSummaryInformation(): void
{ {
if (!isset($this->documentSummaryInformation)) { if (!isset($this->documentSummaryInformation)) {
return; return;
@ -1650,7 +1650,7 @@ class Xls extends BaseReader
/** /**
* Reads a general type of BIFF record. Does nothing except for moving stream pointer forward to next record. * Reads a general type of BIFF record. Does nothing except for moving stream pointer forward to next record.
*/ */
private function readDefault() private function readDefault(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
@ -1662,7 +1662,7 @@ class Xls extends BaseReader
* The NOTE record specifies a comment associated with a particular cell. In Excel 95 (BIFF7) and earlier versions, * The NOTE record specifies a comment associated with a particular cell. In Excel 95 (BIFF7) and earlier versions,
* this record stores a note (cell note). This feature was significantly enhanced in Excel 97. * this record stores a note (cell note). This feature was significantly enhanced in Excel 97.
*/ */
private function readNote() private function readNote(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -1715,7 +1715,7 @@ class Xls extends BaseReader
/** /**
* The TEXT Object record contains the text associated with a cell annotation. * The TEXT Object record contains the text associated with a cell annotation.
*/ */
private function readTextObject() private function readTextObject(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -1762,7 +1762,7 @@ class Xls extends BaseReader
/** /**
* Read BOF. * Read BOF.
*/ */
private function readBof() private function readBof(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = substr($this->data, $this->pos + 4, $length); $recordData = substr($this->data, $this->pos + 4, $length);
@ -1813,7 +1813,7 @@ class Xls extends BaseReader
* are based on the source of Spreadsheet-ParseExcel: * are based on the source of Spreadsheet-ParseExcel:
* https://metacpan.org/release/Spreadsheet-ParseExcel * https://metacpan.org/release/Spreadsheet-ParseExcel
*/ */
private function readFilepass() private function readFilepass(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
@ -1963,7 +1963,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readCodepage() private function readCodepage(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -1989,7 +1989,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readDateMode() private function readDateMode(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2007,7 +2007,7 @@ class Xls extends BaseReader
/** /**
* Read a FONT record. * Read a FONT record.
*/ */
private function readFont() private function readFont(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2115,7 +2115,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readFormat() private function readFormat(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2152,7 +2152,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readXf() private function readXf(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2449,7 +2449,7 @@ class Xls extends BaseReader
} }
} }
private function readXfExt() private function readXfExt(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2498,7 +2498,7 @@ class Xls extends BaseReader
if (isset($this->mapCellXfIndex[$ixfe])) { if (isset($this->mapCellXfIndex[$ixfe])) {
$fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill(); $fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill();
$fill->getStartColor()->setRGB($rgb); $fill->getStartColor()->setRGB($rgb);
unset($fill->startcolorIndex); // normal color index does not apply, discard $fill->startcolorIndex = null; // normal color index does not apply, discard
} }
} }
@ -2514,7 +2514,7 @@ class Xls extends BaseReader
if (isset($this->mapCellXfIndex[$ixfe])) { if (isset($this->mapCellXfIndex[$ixfe])) {
$fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill(); $fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill();
$fill->getEndColor()->setRGB($rgb); $fill->getEndColor()->setRGB($rgb);
unset($fill->endcolorIndex); // normal color index does not apply, discard $fill->endcolorIndex = null; // normal color index does not apply, discard
} }
} }
@ -2530,7 +2530,7 @@ class Xls extends BaseReader
if (isset($this->mapCellXfIndex[$ixfe])) { if (isset($this->mapCellXfIndex[$ixfe])) {
$top = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getTop(); $top = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getTop();
$top->getColor()->setRGB($rgb); $top->getColor()->setRGB($rgb);
unset($top->colorIndex); // normal color index does not apply, discard $top->colorIndex = null; // normal color index does not apply, discard
} }
} }
@ -2546,7 +2546,7 @@ class Xls extends BaseReader
if (isset($this->mapCellXfIndex[$ixfe])) { if (isset($this->mapCellXfIndex[$ixfe])) {
$bottom = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getBottom(); $bottom = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getBottom();
$bottom->getColor()->setRGB($rgb); $bottom->getColor()->setRGB($rgb);
unset($bottom->colorIndex); // normal color index does not apply, discard $bottom->colorIndex = null; // normal color index does not apply, discard
} }
} }
@ -2562,7 +2562,7 @@ class Xls extends BaseReader
if (isset($this->mapCellXfIndex[$ixfe])) { if (isset($this->mapCellXfIndex[$ixfe])) {
$left = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getLeft(); $left = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getLeft();
$left->getColor()->setRGB($rgb); $left->getColor()->setRGB($rgb);
unset($left->colorIndex); // normal color index does not apply, discard $left->colorIndex = null; // normal color index does not apply, discard
} }
} }
@ -2578,7 +2578,7 @@ class Xls extends BaseReader
if (isset($this->mapCellXfIndex[$ixfe])) { if (isset($this->mapCellXfIndex[$ixfe])) {
$right = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getRight(); $right = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getRight();
$right->getColor()->setRGB($rgb); $right->getColor()->setRGB($rgb);
unset($right->colorIndex); // normal color index does not apply, discard $right->colorIndex = null; // normal color index does not apply, discard
} }
} }
@ -2594,7 +2594,7 @@ class Xls extends BaseReader
if (isset($this->mapCellXfIndex[$ixfe])) { if (isset($this->mapCellXfIndex[$ixfe])) {
$diagonal = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getDiagonal(); $diagonal = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getDiagonal();
$diagonal->getColor()->setRGB($rgb); $diagonal->getColor()->setRGB($rgb);
unset($diagonal->colorIndex); // normal color index does not apply, discard $diagonal->colorIndex = null; // normal color index does not apply, discard
} }
} }
@ -2610,7 +2610,7 @@ class Xls extends BaseReader
if (isset($this->mapCellXfIndex[$ixfe])) { if (isset($this->mapCellXfIndex[$ixfe])) {
$font = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFont(); $font = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFont();
$font->getColor()->setRGB($rgb); $font->getColor()->setRGB($rgb);
unset($font->colorIndex); // normal color index does not apply, discard $font->colorIndex = null; // normal color index does not apply, discard
} }
} }
@ -2625,7 +2625,7 @@ class Xls extends BaseReader
/** /**
* Read STYLE record. * Read STYLE record.
*/ */
private function readStyle() private function readStyle(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2662,7 +2662,7 @@ class Xls extends BaseReader
/** /**
* Read PALETTE record. * Read PALETTE record.
*/ */
private function readPalette() private function readPalette(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2694,7 +2694,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readSheet() private function readSheet(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2749,7 +2749,7 @@ class Xls extends BaseReader
/** /**
* Read EXTERNALBOOK record. * Read EXTERNALBOOK record.
*/ */
private function readExternalBook() private function readExternalBook(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2811,7 +2811,7 @@ class Xls extends BaseReader
/** /**
* Read EXTERNNAME record. * Read EXTERNNAME record.
*/ */
private function readExternName() private function readExternName(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2845,7 +2845,7 @@ class Xls extends BaseReader
/** /**
* Read EXTERNSHEET record. * Read EXTERNSHEET record.
*/ */
private function readExternSheet() private function readExternSheet(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2881,7 +2881,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readDefinedName() private function readDefinedName(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -2935,7 +2935,7 @@ class Xls extends BaseReader
/** /**
* Read MSODRAWINGGROUP record. * Read MSODRAWINGGROUP record.
*/ */
private function readMsoDrawingGroup() private function readMsoDrawingGroup(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
@ -2957,7 +2957,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readSst() private function readSst(): void
{ {
// offset within (spliced) record data // offset within (spliced) record data
$pos = 0; $pos = 0;
@ -3138,7 +3138,7 @@ class Xls extends BaseReader
/** /**
* Read PRINTGRIDLINES record. * Read PRINTGRIDLINES record.
*/ */
private function readPrintGridlines() private function readPrintGridlines(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3156,7 +3156,7 @@ class Xls extends BaseReader
/** /**
* Read DEFAULTROWHEIGHT record. * Read DEFAULTROWHEIGHT record.
*/ */
private function readDefaultRowHeight() private function readDefaultRowHeight(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3173,7 +3173,7 @@ class Xls extends BaseReader
/** /**
* Read SHEETPR record. * Read SHEETPR record.
*/ */
private function readSheetPr() private function readSheetPr(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3199,7 +3199,7 @@ class Xls extends BaseReader
/** /**
* Read HORIZONTALPAGEBREAKS record. * Read HORIZONTALPAGEBREAKS record.
*/ */
private function readHorizontalPageBreaks() private function readHorizontalPageBreaks(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3226,7 +3226,7 @@ class Xls extends BaseReader
/** /**
* Read VERTICALPAGEBREAKS record. * Read VERTICALPAGEBREAKS record.
*/ */
private function readVerticalPageBreaks() private function readVerticalPageBreaks(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3253,7 +3253,7 @@ class Xls extends BaseReader
/** /**
* Read HEADER record. * Read HEADER record.
*/ */
private function readHeader() private function readHeader(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3280,7 +3280,7 @@ class Xls extends BaseReader
/** /**
* Read FOOTER record. * Read FOOTER record.
*/ */
private function readFooter() private function readFooter(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3306,7 +3306,7 @@ class Xls extends BaseReader
/** /**
* Read HCENTER record. * Read HCENTER record.
*/ */
private function readHcenter() private function readHcenter(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3325,7 +3325,7 @@ class Xls extends BaseReader
/** /**
* Read VCENTER record. * Read VCENTER record.
*/ */
private function readVcenter() private function readVcenter(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3344,7 +3344,7 @@ class Xls extends BaseReader
/** /**
* Read LEFTMARGIN record. * Read LEFTMARGIN record.
*/ */
private function readLeftMargin() private function readLeftMargin(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3361,7 +3361,7 @@ class Xls extends BaseReader
/** /**
* Read RIGHTMARGIN record. * Read RIGHTMARGIN record.
*/ */
private function readRightMargin() private function readRightMargin(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3378,7 +3378,7 @@ class Xls extends BaseReader
/** /**
* Read TOPMARGIN record. * Read TOPMARGIN record.
*/ */
private function readTopMargin() private function readTopMargin(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3395,7 +3395,7 @@ class Xls extends BaseReader
/** /**
* Read BOTTOMMARGIN record. * Read BOTTOMMARGIN record.
*/ */
private function readBottomMargin() private function readBottomMargin(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3412,7 +3412,7 @@ class Xls extends BaseReader
/** /**
* Read PAGESETUP record. * Read PAGESETUP record.
*/ */
private function readPageSetup() private function readPageSetup(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3475,7 +3475,7 @@ class Xls extends BaseReader
* PROTECT - Sheet protection (BIFF2 through BIFF8) * PROTECT - Sheet protection (BIFF2 through BIFF8)
* if this record is omitted, then it also means no sheet protection. * if this record is omitted, then it also means no sheet protection.
*/ */
private function readProtect() private function readProtect(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3497,7 +3497,7 @@ class Xls extends BaseReader
/** /**
* SCENPROTECT. * SCENPROTECT.
*/ */
private function readScenProtect() private function readScenProtect(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3520,7 +3520,7 @@ class Xls extends BaseReader
/** /**
* OBJECTPROTECT. * OBJECTPROTECT.
*/ */
private function readObjectProtect() private function readObjectProtect(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3543,7 +3543,7 @@ class Xls extends BaseReader
/** /**
* PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8). * PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8).
*/ */
private function readPassword() private function readPassword(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3561,7 +3561,7 @@ class Xls extends BaseReader
/** /**
* Read DEFCOLWIDTH record. * Read DEFCOLWIDTH record.
*/ */
private function readDefColWidth() private function readDefColWidth(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3579,7 +3579,7 @@ class Xls extends BaseReader
/** /**
* Read COLINFO record. * Read COLINFO record.
*/ */
private function readColInfo() private function readColInfo(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3637,7 +3637,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readRow() private function readRow(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3706,7 +3706,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readRk() private function readRk(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3750,7 +3750,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readLabelSst() private function readLabelSst(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3834,7 +3834,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readMulRk() private function readMulRk(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3887,7 +3887,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readNumber() private function readNumber(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -3928,7 +3928,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readFormula() private function readFormula(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4054,7 +4054,7 @@ class Xls extends BaseReader
* which usually contains relative references. * which usually contains relative references.
* These will be used to construct the formula in each shared formula part after the sheet is read. * These will be used to construct the formula in each shared formula part after the sheet is read.
*/ */
private function readSharedFmla() private function readSharedFmla(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4112,7 +4112,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readBoolErr() private function readBoolErr(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4171,7 +4171,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readMulBlank() private function readMulBlank(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4212,7 +4212,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readLabel() private function readLabel(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4256,7 +4256,7 @@ class Xls extends BaseReader
/** /**
* Read BLANK record. * Read BLANK record.
*/ */
private function readBlank() private function readBlank(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4286,7 +4286,7 @@ class Xls extends BaseReader
/** /**
* Read MSODRAWING record. * Read MSODRAWING record.
*/ */
private function readMsoDrawing() private function readMsoDrawing(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
@ -4300,7 +4300,7 @@ class Xls extends BaseReader
/** /**
* Read OBJ record. * Read OBJ record.
*/ */
private function readObj() private function readObj(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4340,7 +4340,7 @@ class Xls extends BaseReader
/** /**
* Read WINDOW2 record. * Read WINDOW2 record.
*/ */
private function readWindow2() private function readWindow2(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4411,7 +4411,7 @@ class Xls extends BaseReader
/** /**
* Read PLV Record(Created by Excel2007 or upper). * Read PLV Record(Created by Excel2007 or upper).
*/ */
private function readPageLayoutView() private function readPageLayoutView(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4448,7 +4448,7 @@ class Xls extends BaseReader
/** /**
* Read SCL record. * Read SCL record.
*/ */
private function readScl() private function readScl(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4469,7 +4469,7 @@ class Xls extends BaseReader
/** /**
* Read PANE record. * Read PANE record.
*/ */
private function readPane() private function readPane(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4503,7 +4503,7 @@ class Xls extends BaseReader
/** /**
* Read SELECTION record. There is one such record for each pane in the sheet. * Read SELECTION record. There is one such record for each pane in the sheet.
*/ */
private function readSelection() private function readSelection(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4580,7 +4580,7 @@ class Xls extends BaseReader
* -- "OpenOffice.org's Documentation of the Microsoft * -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format" * Excel File Format"
*/ */
private function readMergedCells() private function readMergedCells(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4602,7 +4602,7 @@ class Xls extends BaseReader
/** /**
* Read HYPERLINK record. * Read HYPERLINK record.
*/ */
private function readHyperLink() private function readHyperLink(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4775,7 +4775,7 @@ class Xls extends BaseReader
/** /**
* Read DATAVALIDATIONS record. * Read DATAVALIDATIONS record.
*/ */
private function readDataValidations() private function readDataValidations(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4787,7 +4787,7 @@ class Xls extends BaseReader
/** /**
* Read DATAVALIDATION record. * Read DATAVALIDATION record.
*/ */
private function readDataValidation() private function readDataValidation(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -4997,7 +4997,7 @@ class Xls extends BaseReader
/** /**
* Read SHEETLAYOUT record. Stores sheet tab color information. * Read SHEETLAYOUT record. Stores sheet tab color information.
*/ */
private function readSheetLayout() private function readSheetLayout(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -5037,7 +5037,7 @@ class Xls extends BaseReader
/** /**
* Read SHEETPROTECTION record (FEATHEADR). * Read SHEETPROTECTION record (FEATHEADR).
*/ */
private function readSheetProtection() private function readSheetProtection(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -5137,7 +5137,7 @@ class Xls extends BaseReader
* Reading of this record is based on Microsoft Office Excel 97-2000 Binary File Format Specification, * Reading of this record is based on Microsoft Office Excel 97-2000 Binary File Format Specification,
* where it is referred to as FEAT record. * where it is referred to as FEAT record.
*/ */
private function readRangeProtection() private function readRangeProtection(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -5199,7 +5199,7 @@ class Xls extends BaseReader
* When MSODRAWING data on a sheet exceeds 8224 bytes, CONTINUE records are used instead. Undocumented. * When MSODRAWING data on a sheet exceeds 8224 bytes, CONTINUE records are used instead. Undocumented.
* In this case, we must treat the CONTINUE record as a MSODRAWING record. * In this case, we must treat the CONTINUE record as a MSODRAWING record.
*/ */
private function readContinue() private function readContinue(): void
{ {
$length = self::getUInt2d($this->data, $this->pos + 2); $length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
@ -5319,7 +5319,7 @@ class Xls extends BaseReader
// start parsing the formula data // start parsing the formula data
$tokens = []; $tokens = [];
while (strlen($formulaData) > 0 and $token = $this->getNextToken($formulaData, $baseCell)) { while (strlen($formulaData) > 0 && $token = $this->getNextToken($formulaData, $baseCell)) {
$tokens[] = $token; $tokens[] = $token;
$formulaData = substr($formulaData, $token['size']); $formulaData = substr($formulaData, $token['size']);
} }
@ -7203,7 +7203,7 @@ class Xls extends BaseReader
$fc = Coordinate::stringFromColumnIndex($fc + 1); $fc = Coordinate::stringFromColumnIndex($fc + 1);
$lc = Coordinate::stringFromColumnIndex($lc + 1); $lc = Coordinate::stringFromColumnIndex($lc + 1);
if ($fr == $lr and $fc == $lc) { if ($fr == $lr && $fc == $lc) {
return "$fc$fr"; return "$fc$fr";
} }
@ -7242,7 +7242,7 @@ class Xls extends BaseReader
$fc = Coordinate::stringFromColumnIndex($fc + 1); $fc = Coordinate::stringFromColumnIndex($fc + 1);
$lc = Coordinate::stringFromColumnIndex($lc + 1); $lc = Coordinate::stringFromColumnIndex($lc + 1);
if ($fr == $lr and $fc == $lc) { if ($fr == $lr && $fc == $lc) {
return "$fc$fr"; return "$fc$fr";
} }
@ -7463,7 +7463,7 @@ class Xls extends BaseReader
switch ($type) { switch ($type) {
case 'internal': case 'internal':
// check if we have a deleted 3d reference // check if we have a deleted 3d reference
if ($this->ref[$index]['firstSheetIndex'] == 0xFFFF or $this->ref[$index]['lastSheetIndex'] == 0xFFFF) { if ($this->ref[$index]['firstSheetIndex'] == 0xFFFF || $this->ref[$index]['lastSheetIndex'] == 0xFFFF) {
throw new Exception('Deleted sheet reference'); throw new Exception('Deleted sheet reference');
} }
@ -7688,7 +7688,7 @@ class Xls extends BaseReader
$string = self::readUnicodeString(substr($subData, 1), $characterCount); $string = self::readUnicodeString(substr($subData, 1), $characterCount);
// add 1 for the string length // add 1 for the string length
$string['size'] += 1; ++$string['size'];
return $string; return $string;
} }
@ -7781,13 +7781,13 @@ class Xls extends BaseReader
$mantissa = (0x100000 | ($rknumhigh & 0x000fffff)); $mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
$mantissalow1 = ($rknumlow & 0x80000000) >> 31; $mantissalow1 = ($rknumlow & 0x80000000) >> 31;
$mantissalow2 = ($rknumlow & 0x7fffffff); $mantissalow2 = ($rknumlow & 0x7fffffff);
$value = $mantissa / pow(2, (20 - $exp)); $value = $mantissa / 2 ** (20 - $exp);
if ($mantissalow1 != 0) { if ($mantissalow1 != 0) {
$value += 1 / pow(2, (21 - $exp)); $value += 1 / 2 ** (21 - $exp);
} }
$value += $mantissalow2 / pow(2, (52 - $exp)); $value += $mantissalow2 / 2 ** (52 - $exp);
if ($sign) { if ($sign) {
$value *= -1; $value *= -1;
} }
@ -7813,7 +7813,7 @@ class Xls extends BaseReader
$sign = ($rknum & 0x80000000) >> 31; $sign = ($rknum & 0x80000000) >> 31;
$exp = ($rknum & 0x7ff00000) >> 20; $exp = ($rknum & 0x7ff00000) >> 20;
$mantissa = (0x100000 | ($rknum & 0x000ffffc)); $mantissa = (0x100000 | ($rknum & 0x000ffffc));
$value = $mantissa / pow(2, (20 - ($exp - 1023))); $value = $mantissa / 2 ** (20 - ($exp - 1023));
if ($sign) { if ($sign) {
$value = -1 * $value; $value = -1 * $value;
} }

View File

@ -178,7 +178,7 @@ class Escher
/** /**
* Read a generic record. * Read a generic record.
*/ */
private function readDefault() private function readDefault(): void
{ {
// offset 0; size: 2; recVer and recInstance // offset 0; size: 2; recVer and recInstance
$verInstance = Xls::getUInt2d($this->data, $this->pos); $verInstance = Xls::getUInt2d($this->data, $this->pos);
@ -199,7 +199,7 @@ class Escher
/** /**
* Read DggContainer record (Drawing Group Container). * Read DggContainer record (Drawing Group Container).
*/ */
private function readDggContainer() private function readDggContainer(): void
{ {
$length = Xls::getInt4d($this->data, $this->pos + 4); $length = Xls::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
@ -217,7 +217,7 @@ class Escher
/** /**
* Read Dgg record (Drawing Group). * Read Dgg record (Drawing Group).
*/ */
private function readDgg() private function readDgg(): void
{ {
$length = Xls::getInt4d($this->data, $this->pos + 4); $length = Xls::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
@ -229,7 +229,7 @@ class Escher
/** /**
* Read BstoreContainer record (Blip Store Container). * Read BstoreContainer record (Blip Store Container).
*/ */
private function readBstoreContainer() private function readBstoreContainer(): void
{ {
$length = Xls::getInt4d($this->data, $this->pos + 4); $length = Xls::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
@ -247,7 +247,7 @@ class Escher
/** /**
* Read BSE record. * Read BSE record.
*/ */
private function readBSE() private function readBSE(): void
{ {
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
@ -313,7 +313,7 @@ class Escher
/** /**
* Read BlipJPEG record. Holds raw JPEG image data. * Read BlipJPEG record. Holds raw JPEG image data.
*/ */
private function readBlipJPEG() private function readBlipJPEG(): void
{ {
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
@ -340,7 +340,7 @@ class Escher
// offset: var; size: 1; tag // offset: var; size: 1; tag
$tag = ord($recordData[$pos]); $tag = ord($recordData[$pos]);
$pos += 1; ++$pos;
// offset: var; size: var; the raw image data // offset: var; size: var; the raw image data
$data = substr($recordData, $pos); $data = substr($recordData, $pos);
@ -354,7 +354,7 @@ class Escher
/** /**
* Read BlipPNG record. Holds raw PNG image data. * Read BlipPNG record. Holds raw PNG image data.
*/ */
private function readBlipPNG() private function readBlipPNG(): void
{ {
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
@ -381,7 +381,7 @@ class Escher
// offset: var; size: 1; tag // offset: var; size: 1; tag
$tag = ord($recordData[$pos]); $tag = ord($recordData[$pos]);
$pos += 1; ++$pos;
// offset: var; size: var; the raw image data // offset: var; size: var; the raw image data
$data = substr($recordData, $pos); $data = substr($recordData, $pos);
@ -395,7 +395,7 @@ class Escher
/** /**
* Read OPT record. This record may occur within DggContainer record or SpContainer. * Read OPT record. This record may occur within DggContainer record or SpContainer.
*/ */
private function readOPT() private function readOPT(): void
{ {
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
@ -414,7 +414,7 @@ class Escher
/** /**
* Read TertiaryOPT record. * Read TertiaryOPT record.
*/ */
private function readTertiaryOPT() private function readTertiaryOPT(): void
{ {
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
@ -431,7 +431,7 @@ class Escher
/** /**
* Read SplitMenuColors record. * Read SplitMenuColors record.
*/ */
private function readSplitMenuColors() private function readSplitMenuColors(): void
{ {
$length = Xls::getInt4d($this->data, $this->pos + 4); $length = Xls::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
@ -443,7 +443,7 @@ class Escher
/** /**
* Read DgContainer record (Drawing Container). * Read DgContainer record (Drawing Container).
*/ */
private function readDgContainer() private function readDgContainer(): void
{ {
$length = Xls::getInt4d($this->data, $this->pos + 4); $length = Xls::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
@ -461,7 +461,7 @@ class Escher
/** /**
* Read Dg record (Drawing). * Read Dg record (Drawing).
*/ */
private function readDg() private function readDg(): void
{ {
$length = Xls::getInt4d($this->data, $this->pos + 4); $length = Xls::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
@ -473,7 +473,7 @@ class Escher
/** /**
* Read SpgrContainer record (Shape Group Container). * Read SpgrContainer record (Shape Group Container).
*/ */
private function readSpgrContainer() private function readSpgrContainer(): void
{ {
// context is either context DgContainer or SpgrContainer // context is either context DgContainer or SpgrContainer
@ -501,7 +501,7 @@ class Escher
/** /**
* Read SpContainer record (Shape Container). * Read SpContainer record (Shape Container).
*/ */
private function readSpContainer() private function readSpContainer(): void
{ {
$length = Xls::getInt4d($this->data, $this->pos + 4); $length = Xls::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
@ -521,7 +521,7 @@ class Escher
/** /**
* Read Spgr record (Shape Group). * Read Spgr record (Shape Group).
*/ */
private function readSpgr() private function readSpgr(): void
{ {
$length = Xls::getInt4d($this->data, $this->pos + 4); $length = Xls::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
@ -533,7 +533,7 @@ class Escher
/** /**
* Read Sp record (Shape). * Read Sp record (Shape).
*/ */
private function readSp() private function readSp(): void
{ {
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
@ -550,7 +550,7 @@ class Escher
/** /**
* Read ClientTextbox record. * Read ClientTextbox record.
*/ */
private function readClientTextbox() private function readClientTextbox(): void
{ {
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
@ -567,7 +567,7 @@ class Escher
/** /**
* Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet. * Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet.
*/ */
private function readClientAnchor() private function readClientAnchor(): void
{ {
$length = Xls::getInt4d($this->data, $this->pos + 4); $length = Xls::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
@ -621,7 +621,7 @@ class Escher
/** /**
* Read ClientData record. * Read ClientData record.
*/ */
private function readClientData() private function readClientData(): void
{ {
$length = Xls::getInt4d($this->data, $this->pos + 4); $length = Xls::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
@ -636,7 +636,7 @@ class Escher
* @param string $data Binary data * @param string $data Binary data
* @param int $n Number of properties * @param int $n Number of properties
*/ */
private function readOfficeArtRGFOPTE($data, $n) private function readOfficeArtRGFOPTE($data, $n): void
{ {
$splicedComplexData = substr($data, 6 * $n); $splicedComplexData = substr($data, 6 * $n);

View File

@ -24,7 +24,7 @@ class MD5
/** /**
* Reset the MD5 stream context. * Reset the MD5 stream context.
*/ */
public function reset() public function reset(): void
{ {
$this->a = 0x67452301; $this->a = 0x67452301;
$this->b = 0xEFCDAB89; $this->b = 0xEFCDAB89;
@ -56,7 +56,7 @@ class MD5
* *
* @param string $data Data to add * @param string $data Data to add
*/ */
public function add($data) public function add($data): void
{ {
$words = array_values(unpack('V16', $data)); $words = array_values(unpack('V16', $data));
@ -168,7 +168,7 @@ class MD5
return $Y ^ ($X | (~$Z)); // Y XOR (X OR NOT Z) return $Y ^ ($X | (~$Z)); // Y XOR (X OR NOT Z)
} }
private static function step($func, &$A, $B, $C, $D, $M, $s, $t) private static function step($func, &$A, $B, $C, $D, $M, $s, $t): void
{ {
$A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff; $A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff;
$A = self::rotate($A, $s); $A = self::rotate($A, $s);

View File

@ -35,6 +35,8 @@ use PhpOffice\PhpSpreadsheet\Style\Style;
use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing; use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use SimpleXMLElement; use SimpleXMLElement;
use stdClass;
use Throwable;
use XMLReader; use XMLReader;
use ZipArchive; use ZipArchive;
@ -256,7 +258,7 @@ class Xlsx extends BaseReader
return isset($c->v) ? (string) $c->v : null; return isset($c->v) ? (string) $c->v : null;
} }
private function castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType) private function castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType): void
{ {
$cellDataType = 'f'; $cellDataType = 'f';
$value = "={$c->f}"; $value = "={$c->f}";
@ -282,7 +284,6 @@ class Xlsx extends BaseReader
} }
/** /**
* @param ZipArchive $archive
* @param string $fileName * @param string $fileName
* *
* @return string * @return string
@ -658,7 +659,7 @@ class Xlsx extends BaseReader
$coordinates = Coordinate::coordinateFromString($r); $coordinates = Coordinate::coordinateFromString($r);
if (!$this->getReadFilter()->readCell($coordinates[0], (int) $coordinates[1], $docSheet->getTitle())) { if (!$this->getReadFilter()->readCell($coordinates[0], (int) $coordinates[1], $docSheet->getTitle())) {
$rowIndex += 1; ++$rowIndex;
continue; continue;
} }
@ -744,9 +745,9 @@ class Xlsx extends BaseReader
(int) ($c['s']) : 0); (int) ($c['s']) : 0);
} }
} }
$rowIndex += 1; ++$rowIndex;
} }
$cIndex += 1; ++$cIndex;
} }
} }
@ -891,7 +892,7 @@ class Xlsx extends BaseReader
Settings::getLibXmlLoaderOptions() Settings::getLibXmlLoaderOptions()
); );
$vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
} catch (\Throwable $ex) { } catch (Throwable $ex) {
//Ignore unparsable vmlDrawings. Later they will be moved from $unparsedVmlDrawings to $unparsedLoadedData //Ignore unparsable vmlDrawings. Later they will be moved from $unparsedVmlDrawings to $unparsedLoadedData
continue; continue;
} }
@ -1115,7 +1116,7 @@ class Xlsx extends BaseReader
$xfrm = $oneCellAnchor->pic->spPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->xfrm; $xfrm = $oneCellAnchor->pic->spPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->xfrm;
/** @var SimpleXMLElement $outerShdw */ /** @var SimpleXMLElement $outerShdw */
$outerShdw = $oneCellAnchor->pic->spPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->effectLst->outerShdw; $outerShdw = $oneCellAnchor->pic->spPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->effectLst->outerShdw;
/** @var \SimpleXMLElement $hlinkClick */ /** @var SimpleXMLElement $hlinkClick */
$hlinkClick = $oneCellAnchor->pic->nvPicPr->cNvPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->hlinkClick; $hlinkClick = $oneCellAnchor->pic->nvPicPr->cNvPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->hlinkClick;
$objDrawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); $objDrawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
@ -1556,10 +1557,9 @@ class Xlsx extends BaseReader
} }
/** /**
* @param Style $docStyle * @param SimpleXMLElement|stdClass $style
* @param SimpleXMLElement|\stdClass $style
*/ */
private static function readStyle(Style $docStyle, $style) private static function readStyle(Style $docStyle, $style): void
{ {
$docStyle->getNumberFormat()->setFormatCode($style->numFmt); $docStyle->getNumberFormat()->setFormatCode($style->numFmt);
@ -1684,10 +1684,9 @@ class Xlsx extends BaseReader
} }
/** /**
* @param Border $docBorder
* @param SimpleXMLElement $eleBorder * @param SimpleXMLElement $eleBorder
*/ */
private static function readBorder(Border $docBorder, $eleBorder) private static function readBorder(Border $docBorder, $eleBorder): void
{ {
if (isset($eleBorder['style'])) { if (isset($eleBorder['style'])) {
$docBorder->setBorderStyle((string) $eleBorder['style']); $docBorder->setBorderStyle((string) $eleBorder['style']);
@ -1760,11 +1759,10 @@ class Xlsx extends BaseReader
} }
/** /**
* @param Spreadsheet $excel
* @param mixed $customUITarget * @param mixed $customUITarget
* @param mixed $zip * @param mixed $zip
*/ */
private function readRibbon(Spreadsheet $excel, $customUITarget, $zip) private function readRibbon(Spreadsheet $excel, $customUITarget, $zip): void
{ {
$baseDir = dirname($customUITarget); $baseDir = dirname($customUITarget);
$nameCustomUI = basename($customUITarget); $nameCustomUI = basename($customUITarget);
@ -1866,10 +1864,10 @@ class Xlsx extends BaseReader
/** /**
* @param \PhpOffice\PhpSpreadsheet\Worksheet\Drawing $objDrawing * @param \PhpOffice\PhpSpreadsheet\Worksheet\Drawing $objDrawing
* @param \SimpleXMLElement $cellAnchor * @param SimpleXMLElement $cellAnchor
* @param array $hyperlinks * @param array $hyperlinks
*/ */
private function readHyperLinkDrawing($objDrawing, $cellAnchor, $hyperlinks) private function readHyperLinkDrawing($objDrawing, $cellAnchor, $hyperlinks): void
{ {
$hlinkClick = $cellAnchor->pic->nvPicPr->cNvPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->hlinkClick; $hlinkClick = $cellAnchor->pic->nvPicPr->cNvPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->hlinkClick;
@ -1885,7 +1883,7 @@ class Xlsx extends BaseReader
$objDrawing->setHyperlink($hyperlink); $objDrawing->setHyperlink($hyperlink);
} }
private function readProtection(Spreadsheet $excel, SimpleXMLElement $xmlWorkbook) private function readProtection(Spreadsheet $excel, SimpleXMLElement $xmlWorkbook): void
{ {
if (!$xmlWorkbook->workbookProtection) { if (!$xmlWorkbook->workbookProtection) {
return; return;
@ -1912,7 +1910,7 @@ class Xlsx extends BaseReader
} }
} }
private function readFormControlProperties(Spreadsheet $excel, ZipArchive $zip, $dir, $fileWorksheet, $docSheet, array &$unparsedLoadedData) private function readFormControlProperties(Spreadsheet $excel, ZipArchive $zip, $dir, $fileWorksheet, $docSheet, array &$unparsedLoadedData): void
{ {
if (!$zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) { if (!$zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
return; return;
@ -1944,7 +1942,7 @@ class Xlsx extends BaseReader
unset($unparsedCtrlProps); unset($unparsedCtrlProps);
} }
private function readPrinterSettings(Spreadsheet $excel, ZipArchive $zip, $dir, $fileWorksheet, $docSheet, array &$unparsedLoadedData) private function readPrinterSettings(Spreadsheet $excel, ZipArchive $zip, $dir, $fileWorksheet, $docSheet, array &$unparsedLoadedData): void
{ {
if (!$zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) { if (!$zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
return; return;

View File

@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column; use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule; use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use SimpleXMLElement;
class AutoFilter class AutoFilter
{ {
@ -12,13 +13,13 @@ class AutoFilter
private $worksheetXml; private $worksheetXml;
public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml) public function __construct(Worksheet $workSheet, SimpleXMLElement $worksheetXml)
{ {
$this->worksheet = $workSheet; $this->worksheet = $workSheet;
$this->worksheetXml = $worksheetXml; $this->worksheetXml = $worksheetXml;
} }
public function load() public function load(): void
{ {
// Remove all "$" in the auto filter range // Remove all "$" in the auto filter range
$autoFilterRange = preg_replace('/\$/', '', $this->worksheetXml->autoFilter['ref']); $autoFilterRange = preg_replace('/\$/', '', $this->worksheetXml->autoFilter['ref']);
@ -27,7 +28,7 @@ class AutoFilter
} }
} }
private function readAutoFilter($autoFilterRange, $xmlSheet) private function readAutoFilter($autoFilterRange, $xmlSheet): void
{ {
$autoFilter = $this->worksheet->getAutoFilter(); $autoFilter = $this->worksheet->getAutoFilter();
$autoFilter->setRange($autoFilterRange); $autoFilter->setRange($autoFilterRange);
@ -62,7 +63,7 @@ class AutoFilter
} }
} }
private function readDateRangeAutoFilter(\SimpleXMLElement $filters, Column $column) private function readDateRangeAutoFilter(SimpleXMLElement $filters, Column $column): void
{ {
foreach ($filters->dateGroupItem as $dateGroupItem) { foreach ($filters->dateGroupItem as $dateGroupItem) {
// Operator is undefined, but always treated as EQUAL // Operator is undefined, but always treated as EQUAL
@ -81,7 +82,7 @@ class AutoFilter
} }
} }
private function readCustomAutoFilter(\SimpleXMLElement $filterColumn, Column $column) private function readCustomAutoFilter(SimpleXMLElement $filterColumn, Column $column): void
{ {
if ($filterColumn->customFilters) { if ($filterColumn->customFilters) {
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER); $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER);
@ -100,7 +101,7 @@ class AutoFilter
} }
} }
private function readDynamicAutoFilter(\SimpleXMLElement $filterColumn, Column $column) private function readDynamicAutoFilter(SimpleXMLElement $filterColumn, Column $column): void
{ {
if ($filterColumn->dynamicFilter) { if ($filterColumn->dynamicFilter) {
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
@ -122,7 +123,7 @@ class AutoFilter
} }
} }
private function readTopTenAutoFilter(\SimpleXMLElement $filterColumn, Column $column) private function readTopTenAutoFilter(SimpleXMLElement $filterColumn, Column $column): void
{ {
if ($filterColumn->top10) { if ($filterColumn->top10) {
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER); $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER);

View File

@ -17,7 +17,6 @@ use SimpleXMLElement;
class Chart class Chart
{ {
/** /**
* @param SimpleXMLElement $component
* @param string $name * @param string $name
* @param string $format * @param string $format
* *
@ -51,7 +50,6 @@ class Chart
} }
/** /**
* @param SimpleXMLElement $chartElements
* @param string $chartName * @param string $chartName
* *
* @return \PhpOffice\PhpSpreadsheet\Chart\Chart * @return \PhpOffice\PhpSpreadsheet\Chart\Chart
@ -529,10 +527,9 @@ class Chart
} }
/** /**
* @param Layout $plotArea
* @param mixed $plotAttributes * @param mixed $plotAttributes
*/ */
private static function setChartAttributes(Layout $plotArea, $plotAttributes) private static function setChartAttributes(Layout $plotArea, $plotAttributes): void
{ {
foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) { foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
switch ($plotAttributeKey) { switch ($plotAttributeKey) {

View File

@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter; use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use SimpleXMLElement;
class ColumnAndRowAttributes extends BaseParserClass class ColumnAndRowAttributes extends BaseParserClass
{ {
@ -12,7 +13,7 @@ class ColumnAndRowAttributes extends BaseParserClass
private $worksheetXml; private $worksheetXml;
public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml = null) public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXml = null)
{ {
$this->worksheet = $workSheet; $this->worksheet = $workSheet;
$this->worksheetXml = $worksheetXml; $this->worksheetXml = $worksheetXml;
@ -25,7 +26,7 @@ class ColumnAndRowAttributes extends BaseParserClass
* @param array $columnAttributes array of attributes (indexes are attribute name, values are value) * @param array $columnAttributes array of attributes (indexes are attribute name, values are value)
* 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'width', ... ? * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'width', ... ?
*/ */
private function setColumnAttributes($columnAddress, array $columnAttributes) private function setColumnAttributes($columnAddress, array $columnAttributes): void
{ {
if (isset($columnAttributes['xfIndex'])) { if (isset($columnAttributes['xfIndex'])) {
$this->worksheet->getColumnDimension($columnAddress)->setXfIndex($columnAttributes['xfIndex']); $this->worksheet->getColumnDimension($columnAddress)->setXfIndex($columnAttributes['xfIndex']);
@ -51,7 +52,7 @@ class ColumnAndRowAttributes extends BaseParserClass
* @param array $rowAttributes array of attributes (indexes are attribute name, values are value) * @param array $rowAttributes array of attributes (indexes are attribute name, values are value)
* 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'rowHeight', ... ? * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'rowHeight', ... ?
*/ */
private function setRowAttributes($rowNumber, array $rowAttributes) private function setRowAttributes($rowNumber, array $rowAttributes): void
{ {
if (isset($rowAttributes['xfIndex'])) { if (isset($rowAttributes['xfIndex'])) {
$this->worksheet->getRowDimension($rowNumber)->setXfIndex($rowAttributes['xfIndex']); $this->worksheet->getRowDimension($rowNumber)->setXfIndex($rowAttributes['xfIndex']);
@ -74,7 +75,7 @@ class ColumnAndRowAttributes extends BaseParserClass
* @param IReadFilter $readFilter * @param IReadFilter $readFilter
* @param bool $readDataOnly * @param bool $readDataOnly
*/ */
public function load(IReadFilter $readFilter = null, $readDataOnly = false) public function load(?IReadFilter $readFilter = null, $readDataOnly = false): void
{ {
if ($this->worksheetXml === null) { if ($this->worksheetXml === null) {
return; return;
@ -125,7 +126,7 @@ class ColumnAndRowAttributes extends BaseParserClass
return false; return false;
} }
private function readColumnAttributes(\SimpleXMLElement $worksheetCols, $readDataOnly) private function readColumnAttributes(SimpleXMLElement $worksheetCols, $readDataOnly)
{ {
$columnAttributes = []; $columnAttributes = [];
@ -145,7 +146,7 @@ class ColumnAndRowAttributes extends BaseParserClass
return $columnAttributes; return $columnAttributes;
} }
private function readColumnRangeAttributes(\SimpleXMLElement $column, $readDataOnly) private function readColumnRangeAttributes(SimpleXMLElement $column, $readDataOnly)
{ {
$columnAttributes = []; $columnAttributes = [];
@ -177,7 +178,7 @@ class ColumnAndRowAttributes extends BaseParserClass
return false; return false;
} }
private function readRowAttributes(\SimpleXMLElement $worksheetRow, $readDataOnly) private function readRowAttributes(SimpleXMLElement $worksheetRow, $readDataOnly)
{ {
$rowAttributes = []; $rowAttributes = [];

View File

@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Style\Conditional; use PhpOffice\PhpSpreadsheet\Style\Conditional;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use SimpleXMLElement;
class ConditionalStyles class ConditionalStyles
{ {
@ -13,14 +14,14 @@ class ConditionalStyles
private $dxfs; private $dxfs;
public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml, array $dxfs = []) public function __construct(Worksheet $workSheet, SimpleXMLElement $worksheetXml, array $dxfs = [])
{ {
$this->worksheet = $workSheet; $this->worksheet = $workSheet;
$this->worksheetXml = $worksheetXml; $this->worksheetXml = $worksheetXml;
$this->dxfs = $dxfs; $this->dxfs = $dxfs;
} }
public function load() public function load(): void
{ {
$this->setConditionalStyles( $this->setConditionalStyles(
$this->worksheet, $this->worksheet,
@ -48,7 +49,7 @@ class ConditionalStyles
return $conditionals; return $conditionals;
} }
private function setConditionalStyles(Worksheet $worksheet, array $conditionals) private function setConditionalStyles(Worksheet $worksheet, array $conditionals): void
{ {
foreach ($conditionals as $ref => $cfRules) { foreach ($conditionals as $ref => $cfRules) {
ksort($cfRules); ksort($cfRules);

View File

@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use SimpleXMLElement;
class DataValidations class DataValidations
{ {
@ -11,13 +12,13 @@ class DataValidations
private $worksheetXml; private $worksheetXml;
public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml) public function __construct(Worksheet $workSheet, SimpleXMLElement $worksheetXml)
{ {
$this->worksheet = $workSheet; $this->worksheet = $workSheet;
$this->worksheetXml = $worksheetXml; $this->worksheetXml = $worksheetXml;
} }
public function load() public function load(): void
{ {
foreach ($this->worksheetXml->dataValidations->dataValidation as $dataValidation) { foreach ($this->worksheetXml->dataValidations->dataValidation as $dataValidation) {
// Uppercase coordinate // Uppercase coordinate

View File

@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use SimpleXMLElement;
class Hyperlinks class Hyperlinks
{ {
@ -16,7 +17,7 @@ class Hyperlinks
$this->worksheet = $workSheet; $this->worksheet = $workSheet;
} }
public function readHyperlinks(\SimpleXMLElement $relsWorksheet) public function readHyperlinks(SimpleXMLElement $relsWorksheet): void
{ {
foreach ($relsWorksheet->Relationship as $element) { foreach ($relsWorksheet->Relationship as $element) {
if ($element['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink') { if ($element['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink') {
@ -25,14 +26,14 @@ class Hyperlinks
} }
} }
public function setHyperlinks(\SimpleXMLElement $worksheetXml) public function setHyperlinks(SimpleXMLElement $worksheetXml): void
{ {
foreach ($worksheetXml->hyperlink as $hyperlink) { foreach ($worksheetXml->hyperlink as $hyperlink) {
$this->setHyperlink($hyperlink, $this->worksheet); $this->setHyperlink($hyperlink, $this->worksheet);
} }
} }
private function setHyperlink(\SimpleXMLElement $hyperlink, Worksheet $worksheet) private function setHyperlink(SimpleXMLElement $hyperlink, Worksheet $worksheet): void
{ {
// Link url // Link url
$linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships');

View File

@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use SimpleXMLElement;
class PageSetup extends BaseParserClass class PageSetup extends BaseParserClass
{ {
@ -11,7 +12,7 @@ class PageSetup extends BaseParserClass
private $worksheetXml; private $worksheetXml;
public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml = null) public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXml = null)
{ {
$this->worksheet = $workSheet; $this->worksheet = $workSheet;
$this->worksheetXml = $worksheetXml; $this->worksheetXml = $worksheetXml;
@ -31,7 +32,7 @@ class PageSetup extends BaseParserClass
return $unparsedLoadedData; return $unparsedLoadedData;
} }
private function margins(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) private function margins(SimpleXMLElement $xmlSheet, Worksheet $worksheet): void
{ {
if ($xmlSheet->pageMargins) { if ($xmlSheet->pageMargins) {
$docPageMargins = $worksheet->getPageMargins(); $docPageMargins = $worksheet->getPageMargins();
@ -44,7 +45,7 @@ class PageSetup extends BaseParserClass
} }
} }
private function pageSetup(\SimpleXMLElement $xmlSheet, Worksheet $worksheet, array $unparsedLoadedData) private function pageSetup(SimpleXMLElement $xmlSheet, Worksheet $worksheet, array $unparsedLoadedData)
{ {
if ($xmlSheet->pageSetup) { if ($xmlSheet->pageSetup) {
$docPageSetup = $worksheet->getPageSetup(); $docPageSetup = $worksheet->getPageSetup();
@ -78,7 +79,7 @@ class PageSetup extends BaseParserClass
return $unparsedLoadedData; return $unparsedLoadedData;
} }
private function headerFooter(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) private function headerFooter(SimpleXMLElement $xmlSheet, Worksheet $worksheet): void
{ {
if ($xmlSheet->headerFooter) { if ($xmlSheet->headerFooter) {
$docHeaderFooter = $worksheet->getHeaderFooter(); $docHeaderFooter = $worksheet->getHeaderFooter();
@ -117,7 +118,7 @@ class PageSetup extends BaseParserClass
} }
} }
private function pageBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) private function pageBreaks(SimpleXMLElement $xmlSheet, Worksheet $worksheet): void
{ {
if ($xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk) { if ($xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk) {
$this->rowBreaks($xmlSheet, $worksheet); $this->rowBreaks($xmlSheet, $worksheet);
@ -127,7 +128,7 @@ class PageSetup extends BaseParserClass
} }
} }
private function rowBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) private function rowBreaks(SimpleXMLElement $xmlSheet, Worksheet $worksheet): void
{ {
foreach ($xmlSheet->rowBreaks->brk as $brk) { foreach ($xmlSheet->rowBreaks->brk as $brk) {
if ($brk['man']) { if ($brk['man']) {
@ -136,7 +137,7 @@ class PageSetup extends BaseParserClass
} }
} }
private function columnBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) private function columnBreaks(SimpleXMLElement $xmlSheet, Worksheet $worksheet): void
{ {
foreach ($xmlSheet->colBreaks->brk as $brk) { foreach ($xmlSheet->colBreaks->brk as $brk) {
if ($brk['man']) { if ($brk['man']) {

View File

@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Document\Properties as DocumentProperties; use PhpOffice\PhpSpreadsheet\Document\Properties as DocumentProperties;
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner; use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
use PhpOffice\PhpSpreadsheet\Settings; use PhpOffice\PhpSpreadsheet\Settings;
use SimpleXMLElement;
class Properties class Properties
{ {
@ -27,7 +28,7 @@ class Properties
); );
} }
public function readCoreProperties($propertyData) public function readCoreProperties($propertyData): void
{ {
$xmlCore = $this->extractPropertyData($propertyData); $xmlCore = $this->extractPropertyData($propertyData);
@ -48,7 +49,7 @@ class Properties
} }
} }
public function readExtendedProperties($propertyData) public function readExtendedProperties($propertyData): void
{ {
$xmlCore = $this->extractPropertyData($propertyData); $xmlCore = $this->extractPropertyData($propertyData);
@ -62,13 +63,13 @@ class Properties
} }
} }
public function readCustomProperties($propertyData) public function readCustomProperties($propertyData): void
{ {
$xmlCore = $this->extractPropertyData($propertyData); $xmlCore = $this->extractPropertyData($propertyData);
if (is_object($xmlCore)) { if (is_object($xmlCore)) {
foreach ($xmlCore as $xmlProperty) { foreach ($xmlCore as $xmlProperty) {
/** @var \SimpleXMLElement $xmlProperty */ /** @var SimpleXMLElement $xmlProperty */
$cellDataOfficeAttributes = $xmlProperty->attributes(); $cellDataOfficeAttributes = $xmlProperty->attributes();
if (isset($cellDataOfficeAttributes['name'])) { if (isset($cellDataOfficeAttributes['name'])) {
$propertyName = (string) $cellDataOfficeAttributes['name']; $propertyName = (string) $cellDataOfficeAttributes['name'];

View File

@ -3,6 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use SimpleXMLElement;
class SheetViewOptions extends BaseParserClass class SheetViewOptions extends BaseParserClass
{ {
@ -10,7 +11,7 @@ class SheetViewOptions extends BaseParserClass
private $worksheetXml; private $worksheetXml;
public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml = null) public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXml = null)
{ {
$this->worksheet = $workSheet; $this->worksheet = $workSheet;
$this->worksheetXml = $worksheetXml; $this->worksheetXml = $worksheetXml;
@ -19,7 +20,7 @@ class SheetViewOptions extends BaseParserClass
/** /**
* @param bool $readDataOnly * @param bool $readDataOnly
*/ */
public function load($readDataOnly = false) public function load($readDataOnly = false): void
{ {
if ($this->worksheetXml === null) { if ($this->worksheetXml === null) {
return; return;
@ -41,21 +42,21 @@ class SheetViewOptions extends BaseParserClass
} }
} }
private function tabColor(\SimpleXMLElement $sheetPr) private function tabColor(SimpleXMLElement $sheetPr): void
{ {
if (isset($sheetPr->tabColor, $sheetPr->tabColor['rgb'])) { if (isset($sheetPr->tabColor, $sheetPr->tabColor['rgb'])) {
$this->worksheet->getTabColor()->setARGB((string) $sheetPr->tabColor['rgb']); $this->worksheet->getTabColor()->setARGB((string) $sheetPr->tabColor['rgb']);
} }
} }
private function codeName(\SimpleXMLElement $sheetPr) private function codeName(SimpleXMLElement $sheetPr): void
{ {
if (isset($sheetPr['codeName'])) { if (isset($sheetPr['codeName'])) {
$this->worksheet->setCodeName((string) $sheetPr['codeName'], false); $this->worksheet->setCodeName((string) $sheetPr['codeName'], false);
} }
} }
private function outlines(\SimpleXMLElement $sheetPr) private function outlines(SimpleXMLElement $sheetPr): void
{ {
if (isset($sheetPr->outlinePr)) { if (isset($sheetPr->outlinePr)) {
if (isset($sheetPr->outlinePr['summaryRight']) && if (isset($sheetPr->outlinePr['summaryRight']) &&
@ -74,7 +75,7 @@ class SheetViewOptions extends BaseParserClass
} }
} }
private function pageSetup(\SimpleXMLElement $sheetPr) private function pageSetup(SimpleXMLElement $sheetPr): void
{ {
if (isset($sheetPr->pageSetUpPr)) { if (isset($sheetPr->pageSetUpPr)) {
if (isset($sheetPr->pageSetUpPr['fitToPage']) && if (isset($sheetPr->pageSetUpPr['fitToPage']) &&
@ -86,7 +87,7 @@ class SheetViewOptions extends BaseParserClass
} }
} }
private function sheetFormat(\SimpleXMLElement $sheetFormatPr) private function sheetFormat(SimpleXMLElement $sheetFormatPr): void
{ {
if (isset($sheetFormatPr['customHeight']) && if (isset($sheetFormatPr['customHeight']) &&
self::boolean((string) $sheetFormatPr['customHeight']) && self::boolean((string) $sheetFormatPr['customHeight']) &&
@ -106,7 +107,7 @@ class SheetViewOptions extends BaseParserClass
} }
} }
private function printOptions(\SimpleXMLElement $printOptions) private function printOptions(SimpleXMLElement $printOptions): void
{ {
if (self::boolean((string) $printOptions['gridLinesSet'])) { if (self::boolean((string) $printOptions['gridLinesSet'])) {
$this->worksheet->setShowGridlines(true); $this->worksheet->setShowGridlines(true);

View File

@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use SimpleXMLElement;
class SheetViews extends BaseParserClass class SheetViews extends BaseParserClass
{ {
@ -11,13 +12,13 @@ class SheetViews extends BaseParserClass
private $worksheet; private $worksheet;
public function __construct(\SimpleXMLElement $sheetViewXml, Worksheet $workSheet) public function __construct(SimpleXMLElement $sheetViewXml, Worksheet $workSheet)
{ {
$this->sheetViewXml = $sheetViewXml; $this->sheetViewXml = $sheetViewXml;
$this->worksheet = $workSheet; $this->worksheet = $workSheet;
} }
public function load() public function load(): void
{ {
$this->zoomScale(); $this->zoomScale();
$this->view(); $this->view();
@ -34,7 +35,7 @@ class SheetViews extends BaseParserClass
} }
} }
private function zoomScale() private function zoomScale(): void
{ {
if (isset($this->sheetViewXml['zoomScale'])) { if (isset($this->sheetViewXml['zoomScale'])) {
$zoomScale = (int) ($this->sheetViewXml['zoomScale']); $zoomScale = (int) ($this->sheetViewXml['zoomScale']);
@ -59,14 +60,14 @@ class SheetViews extends BaseParserClass
} }
} }
private function view() private function view(): void
{ {
if (isset($this->sheetViewXml['view'])) { if (isset($this->sheetViewXml['view'])) {
$this->worksheet->getSheetView()->setView((string) $this->sheetViewXml['view']); $this->worksheet->getSheetView()->setView((string) $this->sheetViewXml['view']);
} }
} }
private function gridLines() private function gridLines(): void
{ {
if (isset($this->sheetViewXml['showGridLines'])) { if (isset($this->sheetViewXml['showGridLines'])) {
$this->worksheet->setShowGridLines( $this->worksheet->setShowGridLines(
@ -75,7 +76,7 @@ class SheetViews extends BaseParserClass
} }
} }
private function headers() private function headers(): void
{ {
if (isset($this->sheetViewXml['showRowColHeaders'])) { if (isset($this->sheetViewXml['showRowColHeaders'])) {
$this->worksheet->setShowRowColHeaders( $this->worksheet->setShowRowColHeaders(
@ -84,7 +85,7 @@ class SheetViews extends BaseParserClass
} }
} }
private function direction() private function direction(): void
{ {
if (isset($this->sheetViewXml['rightToLeft'])) { if (isset($this->sheetViewXml['rightToLeft'])) {
$this->worksheet->setRightToLeft( $this->worksheet->setRightToLeft(
@ -93,7 +94,7 @@ class SheetViews extends BaseParserClass
} }
} }
private function showZeros() private function showZeros(): void
{ {
if (isset($this->sheetViewXml['showZeros'])) { if (isset($this->sheetViewXml['showZeros'])) {
$this->worksheet->getSheetView()->setShowZeros( $this->worksheet->getSheetView()->setShowZeros(
@ -102,7 +103,7 @@ class SheetViews extends BaseParserClass
} }
} }
private function pane() private function pane(): void
{ {
$xSplit = 0; $xSplit = 0;
$ySplit = 0; $ySplit = 0;
@ -126,7 +127,7 @@ class SheetViews extends BaseParserClass
); );
} }
private function selection() private function selection(): void
{ {
$sqref = (string) $this->sheetViewXml->selection['sqref']; $sqref = (string) $this->sheetViewXml->selection['sqref'];
$sqref = explode(' ', $sqref); $sqref = explode(' ', $sqref);

View File

@ -11,6 +11,7 @@ use PhpOffice\PhpSpreadsheet\Style\Font;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Style\Protection; use PhpOffice\PhpSpreadsheet\Style\Protection;
use PhpOffice\PhpSpreadsheet\Style\Style; use PhpOffice\PhpSpreadsheet\Style\Style;
use SimpleXMLElement;
class Styles extends BaseParserClass class Styles extends BaseParserClass
{ {
@ -27,19 +28,19 @@ class Styles extends BaseParserClass
private $styleXml; private $styleXml;
public function __construct(\SimpleXMLElement $styleXml) public function __construct(SimpleXMLElement $styleXml)
{ {
$this->styleXml = $styleXml; $this->styleXml = $styleXml;
} }
public function setStyleBaseData(Theme $theme = null, $styles = [], $cellStyles = []) public function setStyleBaseData(?Theme $theme = null, $styles = [], $cellStyles = []): void
{ {
self::$theme = $theme; self::$theme = $theme;
$this->styles = $styles; $this->styles = $styles;
$this->cellStyles = $cellStyles; $this->cellStyles = $cellStyles;
} }
private static function readFontStyle(Font $fontStyle, \SimpleXMLElement $fontStyleXml) private static function readFontStyle(Font $fontStyle, SimpleXMLElement $fontStyleXml): void
{ {
$fontStyle->setName((string) $fontStyleXml->name['val']); $fontStyle->setName((string) $fontStyleXml->name['val']);
$fontStyle->setSize((float) $fontStyleXml->sz['val']); $fontStyle->setSize((float) $fontStyleXml->sz['val']);
@ -72,7 +73,7 @@ class Styles extends BaseParserClass
} }
} }
private static function readNumberFormat(NumberFormat $numfmtStyle, \SimpleXMLElement $numfmtStyleXml) private static function readNumberFormat(NumberFormat $numfmtStyle, SimpleXMLElement $numfmtStyleXml): void
{ {
if ($numfmtStyleXml->count() === 0) { if ($numfmtStyleXml->count() === 0) {
return; return;
@ -83,10 +84,10 @@ class Styles extends BaseParserClass
} }
} }
private static function readFillStyle(Fill $fillStyle, \SimpleXMLElement $fillStyleXml) private static function readFillStyle(Fill $fillStyle, SimpleXMLElement $fillStyleXml): void
{ {
if ($fillStyleXml->gradientFill) { if ($fillStyleXml->gradientFill) {
/** @var \SimpleXMLElement $gradientFill */ /** @var SimpleXMLElement $gradientFill */
$gradientFill = $fillStyleXml->gradientFill[0]; $gradientFill = $fillStyleXml->gradientFill[0];
if (!empty($gradientFill['type'])) { if (!empty($gradientFill['type'])) {
$fillStyle->setFillType((string) $gradientFill['type']); $fillStyle->setFillType((string) $gradientFill['type']);
@ -109,7 +110,7 @@ class Styles extends BaseParserClass
} }
} }
private static function readBorderStyle(Borders $borderStyle, \SimpleXMLElement $borderStyleXml) private static function readBorderStyle(Borders $borderStyle, SimpleXMLElement $borderStyleXml): void
{ {
$diagonalUp = self::boolean((string) $borderStyleXml['diagonalUp']); $diagonalUp = self::boolean((string) $borderStyleXml['diagonalUp']);
$diagonalDown = self::boolean((string) $borderStyleXml['diagonalDown']); $diagonalDown = self::boolean((string) $borderStyleXml['diagonalDown']);
@ -130,7 +131,7 @@ class Styles extends BaseParserClass
self::readBorder($borderStyle->getDiagonal(), $borderStyleXml->diagonal); self::readBorder($borderStyle->getDiagonal(), $borderStyleXml->diagonal);
} }
private static function readBorder(Border $border, \SimpleXMLElement $borderXml) private static function readBorder(Border $border, SimpleXMLElement $borderXml): void
{ {
if (isset($borderXml['style'])) { if (isset($borderXml['style'])) {
$border->setBorderStyle((string) $borderXml['style']); $border->setBorderStyle((string) $borderXml['style']);
@ -140,7 +141,7 @@ class Styles extends BaseParserClass
} }
} }
private static function readAlignmentStyle(Alignment $alignment, \SimpleXMLElement $alignmentXml) private static function readAlignmentStyle(Alignment $alignment, SimpleXMLElement $alignmentXml): void
{ {
$alignment->setHorizontal((string) $alignmentXml->alignment['horizontal']); $alignment->setHorizontal((string) $alignmentXml->alignment['horizontal']);
$alignment->setVertical((string) $alignmentXml->alignment['vertical']); $alignment->setVertical((string) $alignmentXml->alignment['vertical']);
@ -159,9 +160,9 @@ class Styles extends BaseParserClass
$alignment->setReadOrder((int) ((string) $alignmentXml->alignment['readingOrder']) > 0 ? (int) ((string) $alignmentXml->alignment['readingOrder']) : 0); $alignment->setReadOrder((int) ((string) $alignmentXml->alignment['readingOrder']) > 0 ? (int) ((string) $alignmentXml->alignment['readingOrder']) : 0);
} }
private function readStyle(Style $docStyle, $style) private function readStyle(Style $docStyle, $style): void
{ {
if ($style->numFmt instanceof \SimpleXMLElement) { if ($style->numFmt instanceof SimpleXMLElement) {
self::readNumberFormat($docStyle->getNumberFormat(), $style->numFmt); self::readNumberFormat($docStyle->getNumberFormat(), $style->numFmt);
} else { } else {
$docStyle->getNumberFormat()->setFormatCode($style->numFmt); $docStyle->getNumberFormat()->setFormatCode($style->numFmt);
@ -195,7 +196,7 @@ class Styles extends BaseParserClass
} }
} }
private function readProtectionLocked(Style $docStyle, $style) private function readProtectionLocked(Style $docStyle, $style): void
{ {
if (isset($style->protection['locked'])) { if (isset($style->protection['locked'])) {
if (self::boolean((string) $style->protection['locked'])) { if (self::boolean((string) $style->protection['locked'])) {
@ -206,7 +207,7 @@ class Styles extends BaseParserClass
} }
} }
private function readProtectionHidden(Style $docStyle, $style) private function readProtectionHidden(Style $docStyle, $style): void
{ {
if (isset($style->protection['hidden'])) { if (isset($style->protection['hidden'])) {
if (self::boolean((string) $style->protection['hidden'])) { if (self::boolean((string) $style->protection['hidden'])) {

View File

@ -101,7 +101,7 @@ class Xml extends BaseReader
* *
* @param string $pFilename * @param string $pFilename
* *
* @return false|\SimpleXMLElement * @return false|SimpleXMLElement
*/ */
public function trySimpleXMLLoadString($pFilename) public function trySimpleXMLLoadString($pFilename)
{ {
@ -288,7 +288,6 @@ class Xml extends BaseReader
* Loads from file into Spreadsheet instance. * Loads from file into Spreadsheet instance.
* *
* @param string $pFilename * @param string $pFilename
* @param Spreadsheet $spreadsheet
* *
* @return Spreadsheet * @return Spreadsheet
*/ */
@ -653,11 +652,7 @@ class Xml extends BaseReader
return $value; return $value;
} }
/** private function parseStyles(SimpleXMLElement $xml, array $namespaces): void
* @param SimpleXMLElement $xml
* @param array $namespaces
*/
private function parseStyles(SimpleXMLElement $xml, array $namespaces)
{ {
if (!isset($xml->Styles)) { if (!isset($xml->Styles)) {
return; return;
@ -697,9 +692,8 @@ class Xml extends BaseReader
/** /**
* @param string $styleID * @param string $styleID
* @param SimpleXMLElement $styleAttributes
*/ */
private function parseStyleAlignment($styleID, SimpleXMLElement $styleAttributes) private function parseStyleAlignment($styleID, SimpleXMLElement $styleAttributes): void
{ {
$verticalAlignmentStyles = [ $verticalAlignmentStyles = [
Alignment::VERTICAL_BOTTOM, Alignment::VERTICAL_BOTTOM,
@ -741,10 +735,8 @@ class Xml extends BaseReader
/** /**
* @param $styleID * @param $styleID
* @param SimpleXMLElement $styleData
* @param array $namespaces
*/ */
private function parseStyleBorders($styleID, SimpleXMLElement $styleData, array $namespaces) private function parseStyleBorders($styleID, SimpleXMLElement $styleData, array $namespaces): void
{ {
foreach ($styleData->Border as $borderStyle) { foreach ($styleData->Border as $borderStyle) {
$borderAttributes = $borderStyle->attributes($namespaces['ss']); $borderAttributes = $borderStyle->attributes($namespaces['ss']);
@ -778,9 +770,8 @@ class Xml extends BaseReader
/** /**
* @param $styleID * @param $styleID
* @param SimpleXMLElement $styleAttributes
*/ */
private function parseStyleFont($styleID, SimpleXMLElement $styleAttributes) private function parseStyleFont($styleID, SimpleXMLElement $styleAttributes): void
{ {
$underlineStyles = [ $underlineStyles = [
Font::UNDERLINE_NONE, Font::UNDERLINE_NONE,
@ -825,9 +816,8 @@ class Xml extends BaseReader
/** /**
* @param $styleID * @param $styleID
* @param SimpleXMLElement $styleAttributes
*/ */
private function parseStyleInterior($styleID, SimpleXMLElement $styleAttributes) private function parseStyleInterior($styleID, SimpleXMLElement $styleAttributes): void
{ {
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
@ -845,9 +835,8 @@ class Xml extends BaseReader
/** /**
* @param $styleID * @param $styleID
* @param SimpleXMLElement $styleAttributes
*/ */
private function parseStyleNumberFormat($styleID, SimpleXMLElement $styleAttributes) private function parseStyleNumberFormat($styleID, SimpleXMLElement $styleAttributes): void
{ {
$fromFormats = ['\-', '\ ']; $fromFormats = ['\-', '\ '];
$toFormats = ['-', ' ']; $toFormats = ['-', ' '];

View File

@ -152,7 +152,7 @@ class ReferenceHelper
* @param int $beforeRow Number of the row we're inserting/deleting before * @param int $beforeRow Number of the row we're inserting/deleting before
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/ */
protected function adjustPageBreaks(Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function adjustPageBreaks(Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void
{ {
$aBreaks = $pSheet->getBreaks(); $aBreaks = $pSheet->getBreaks();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
@ -185,7 +185,7 @@ class ReferenceHelper
* @param int $beforeRow Number of the row we're inserting/deleting before * @param int $beforeRow Number of the row we're inserting/deleting before
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/ */
protected function adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void
{ {
$aComments = $pSheet->getComments(); $aComments = $pSheet->getComments();
$aNewComments = []; // the new array of all comments $aNewComments = []; // the new array of all comments
@ -212,7 +212,7 @@ class ReferenceHelper
* @param int $beforeRow Number of the row we're inserting/deleting before * @param int $beforeRow Number of the row we're inserting/deleting before
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/ */
protected function adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void
{ {
$aHyperlinkCollection = $pSheet->getHyperlinkCollection(); $aHyperlinkCollection = $pSheet->getHyperlinkCollection();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
@ -237,7 +237,7 @@ class ReferenceHelper
* @param int $beforeRow Number of the row we're inserting/deleting before * @param int $beforeRow Number of the row we're inserting/deleting before
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/ */
protected function adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void
{ {
$aDataValidationCollection = $pSheet->getDataValidationCollection(); $aDataValidationCollection = $pSheet->getDataValidationCollection();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
@ -262,7 +262,7 @@ class ReferenceHelper
* @param int $beforeRow Number of the row we're inserting/deleting before * @param int $beforeRow Number of the row we're inserting/deleting before
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/ */
protected function adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void
{ {
$aMergeCells = $pSheet->getMergeCells(); $aMergeCells = $pSheet->getMergeCells();
$aNewMergeCells = []; // the new array of all merge cells $aNewMergeCells = []; // the new array of all merge cells
@ -283,7 +283,7 @@ class ReferenceHelper
* @param int $beforeRow Number of the row we're inserting/deleting before * @param int $beforeRow Number of the row we're inserting/deleting before
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/ */
protected function adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void
{ {
$aProtectedCells = $pSheet->getProtectedCells(); $aProtectedCells = $pSheet->getProtectedCells();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
@ -307,7 +307,7 @@ class ReferenceHelper
* @param int $beforeRow Number of the row we're inserting/deleting before * @param int $beforeRow Number of the row we're inserting/deleting before
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/ */
protected function adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void
{ {
$aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true); $aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true);
if (!empty($aColumnDimensions)) { if (!empty($aColumnDimensions)) {
@ -332,7 +332,7 @@ class ReferenceHelper
* @param int $beforeRow Number of the row we're inserting/deleting before * @param int $beforeRow Number of the row we're inserting/deleting before
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
*/ */
protected function adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void
{ {
$aRowDimensions = array_reverse($pSheet->getRowDimensions(), true); $aRowDimensions = array_reverse($pSheet->getRowDimensions(), true);
if (!empty($aRowDimensions)) { if (!empty($aRowDimensions)) {
@ -364,7 +364,7 @@ class ReferenceHelper
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
* @param Worksheet $pSheet The worksheet that we're editing * @param Worksheet $pSheet The worksheet that we're editing
*/ */
public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pSheet) public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pSheet): void
{ {
$remove = ($pNumCols < 0 || $pNumRows < 0); $remove = ($pNumCols < 0 || $pNumRows < 0);
$allCoordinates = $pSheet->getCoordinates(); $allCoordinates = $pSheet->getCoordinates();
@ -789,7 +789,7 @@ class ReferenceHelper
* @param string $oldName Old name (name to replace) * @param string $oldName Old name (name to replace)
* @param string $newName New name * @param string $newName New name
*/ */
public function updateNamedFormulas(Spreadsheet $spreadsheet, $oldName = '', $newName = '') public function updateNamedFormulas(Spreadsheet $spreadsheet, $oldName = '', $newName = ''): void
{ {
if ($oldName == '') { if ($oldName == '') {
return; return;

View File

@ -20,7 +20,7 @@ class RichText implements IComparable
* *
* @param Cell $pCell * @param Cell $pCell
*/ */
public function __construct(Cell $pCell = null) public function __construct(?Cell $pCell = null)
{ {
// Initialise variables // Initialise variables
$this->richTextElements = []; $this->richTextElements = [];

View File

@ -42,7 +42,7 @@ class Run extends TextElement implements ITextElement
* *
* @return $this * @return $this
*/ */
public function setFont(Font $pFont = null) public function setFont(?Font $pFont = null)
{ {
$this->font = $pFont; $this->font = $pFont;

View File

@ -60,7 +60,7 @@ class Settings
* @param string $rendererClass Class name of the chart renderer * @param string $rendererClass Class name of the chart renderer
* eg: PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph * eg: PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph
*/ */
public static function setChartRenderer($rendererClass) public static function setChartRenderer($rendererClass): void
{ {
if (!is_a($rendererClass, IRenderer::class, true)) { if (!is_a($rendererClass, IRenderer::class, true)) {
throw new Exception('Chart renderer must implement ' . IRenderer::class); throw new Exception('Chart renderer must implement ' . IRenderer::class);
@ -85,7 +85,7 @@ class Settings
* *
* @param int $options Default options for libxml loader * @param int $options Default options for libxml loader
*/ */
public static function setLibXmlLoaderOptions($options) public static function setLibXmlLoaderOptions($options): void
{ {
if ($options === null && defined('LIBXML_DTDLOAD')) { if ($options === null && defined('LIBXML_DTDLOAD')) {
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR; $options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
@ -120,7 +120,7 @@ class Settings
* *
* @param bool $state * @param bool $state
*/ */
public static function setLibXmlDisableEntityLoader($state) public static function setLibXmlDisableEntityLoader($state): void
{ {
self::$libXmlDisableEntityLoader = (bool) $state; self::$libXmlDisableEntityLoader = (bool) $state;
} }
@ -137,10 +137,8 @@ class Settings
/** /**
* Sets the implementation of cache that should be used for cell collection. * Sets the implementation of cache that should be used for cell collection.
*
* @param CacheInterface $cache
*/ */
public static function setCache(CacheInterface $cache) public static function setCache(CacheInterface $cache): void
{ {
self::$cache = $cache; self::$cache = $cache;
} }

View File

@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Shared;
use DateTimeInterface; use DateTimeInterface;
use DateTimeZone; use DateTimeZone;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\Cell;
@ -57,7 +58,7 @@ class Date
/** /**
* Default timezone to use for DateTime objects. * Default timezone to use for DateTime objects.
* *
* @var null|\DateTimeZone * @var null|DateTimeZone
*/ */
protected static $defaultTimeZone; protected static $defaultTimeZone;
@ -139,7 +140,7 @@ class Date
return new DateTimeZone($timeZone); return new DateTimeZone($timeZone);
} }
throw new \Exception('Invalid timezone'); throw new Exception('Invalid timezone');
} }
/** /**
@ -311,8 +312,6 @@ class Date
/** /**
* Is a given cell a date/time? * Is a given cell a date/time?
* *
* @param Cell $pCell
*
* @return bool * @return bool
*/ */
public static function isDateTime(Cell $pCell) public static function isDateTime(Cell $pCell)
@ -328,8 +327,6 @@ class Date
/** /**
* Is a given number format a date/time? * Is a given number format a date/time?
* *
* @param NumberFormat $pFormat
*
* @return bool * @return bool
*/ */
public static function isDateTimeFormat(NumberFormat $pFormat) public static function isDateTimeFormat(NumberFormat $pFormat)

View File

@ -25,7 +25,7 @@ class DgContainer
return $this->dgId; return $this->dgId;
} }
public function setDgId($value) public function setDgId($value): void
{ {
$this->dgId = $value; $this->dgId = $value;
} }
@ -35,7 +35,7 @@ class DgContainer
return $this->lastSpId; return $this->lastSpId;
} }
public function setLastSpId($value) public function setLastSpId($value): void
{ {
$this->lastSpId = $value; $this->lastSpId = $value;
} }

View File

@ -23,7 +23,7 @@ class SpgrContainer
* *
* @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer $parent * @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer $parent
*/ */
public function setParent($parent) public function setParent($parent): void
{ {
$this->parent = $parent; $this->parent = $parent;
} }
@ -43,7 +43,7 @@ class SpgrContainer
* *
* @param mixed $child * @param mixed $child
*/ */
public function addChild($child) public function addChild($child): void
{ {
$this->children[] = $child; $this->children[] = $child;
$child->setParent($this); $child->setParent($this);

View File

@ -95,7 +95,7 @@ class SpContainer
* *
* @param SpgrContainer $parent * @param SpgrContainer $parent
*/ */
public function setParent($parent) public function setParent($parent): void
{ {
$this->parent = $parent; $this->parent = $parent;
} }
@ -115,7 +115,7 @@ class SpContainer
* *
* @param bool $value * @param bool $value
*/ */
public function setSpgr($value) public function setSpgr($value): void
{ {
$this->spgr = $value; $this->spgr = $value;
} }
@ -135,7 +135,7 @@ class SpContainer
* *
* @param int $value * @param int $value
*/ */
public function setSpType($value) public function setSpType($value): void
{ {
$this->spType = $value; $this->spType = $value;
} }
@ -155,7 +155,7 @@ class SpContainer
* *
* @param int $value * @param int $value
*/ */
public function setSpFlag($value) public function setSpFlag($value): void
{ {
$this->spFlag = $value; $this->spFlag = $value;
} }
@ -175,7 +175,7 @@ class SpContainer
* *
* @param int $value * @param int $value
*/ */
public function setSpId($value) public function setSpId($value): void
{ {
$this->spId = $value; $this->spId = $value;
} }
@ -196,7 +196,7 @@ class SpContainer
* @param int $property The number specifies the option * @param int $property The number specifies the option
* @param mixed $value * @param mixed $value
*/ */
public function setOPT($property, $value) public function setOPT($property, $value): void
{ {
$this->OPT[$property] = $value; $this->OPT[$property] = $value;
} }
@ -232,7 +232,7 @@ class SpContainer
* *
* @param string $value eg: 'A1' * @param string $value eg: 'A1'
*/ */
public function setStartCoordinates($value) public function setStartCoordinates($value): void
{ {
$this->startCoordinates = $value; $this->startCoordinates = $value;
} }
@ -252,7 +252,7 @@ class SpContainer
* *
* @param int $startOffsetX * @param int $startOffsetX
*/ */
public function setStartOffsetX($startOffsetX) public function setStartOffsetX($startOffsetX): void
{ {
$this->startOffsetX = $startOffsetX; $this->startOffsetX = $startOffsetX;
} }
@ -272,7 +272,7 @@ class SpContainer
* *
* @param int $startOffsetY * @param int $startOffsetY
*/ */
public function setStartOffsetY($startOffsetY) public function setStartOffsetY($startOffsetY): void
{ {
$this->startOffsetY = $startOffsetY; $this->startOffsetY = $startOffsetY;
} }
@ -292,7 +292,7 @@ class SpContainer
* *
* @param string $value eg: 'A1' * @param string $value eg: 'A1'
*/ */
public function setEndCoordinates($value) public function setEndCoordinates($value): void
{ {
$this->endCoordinates = $value; $this->endCoordinates = $value;
} }
@ -312,7 +312,7 @@ class SpContainer
* *
* @param int $endOffsetX * @param int $endOffsetX
*/ */
public function setEndOffsetX($endOffsetX) public function setEndOffsetX($endOffsetX): void
{ {
$this->endOffsetX = $endOffsetX; $this->endOffsetX = $endOffsetX;
} }
@ -332,7 +332,7 @@ class SpContainer
* *
* @param int $endOffsetY * @param int $endOffsetY
*/ */
public function setEndOffsetY($endOffsetY) public function setEndOffsetY($endOffsetY): void
{ {
$this->endOffsetY = $endOffsetY; $this->endOffsetY = $endOffsetY;
} }

View File

@ -61,7 +61,7 @@ class DggContainer
* *
* @param int $value * @param int $value
*/ */
public function setSpIdMax($value) public function setSpIdMax($value): void
{ {
$this->spIdMax = $value; $this->spIdMax = $value;
} }
@ -81,7 +81,7 @@ class DggContainer
* *
* @param int $value * @param int $value
*/ */
public function setCDgSaved($value) public function setCDgSaved($value): void
{ {
$this->cDgSaved = $value; $this->cDgSaved = $value;
} }
@ -101,7 +101,7 @@ class DggContainer
* *
* @param int $value * @param int $value
*/ */
public function setCSpSaved($value) public function setCSpSaved($value): void
{ {
$this->cSpSaved = $value; $this->cSpSaved = $value;
} }
@ -121,7 +121,7 @@ class DggContainer
* *
* @param DggContainer\BstoreContainer $bstoreContainer * @param DggContainer\BstoreContainer $bstoreContainer
*/ */
public function setBstoreContainer($bstoreContainer) public function setBstoreContainer($bstoreContainer): void
{ {
$this->bstoreContainer = $bstoreContainer; $this->bstoreContainer = $bstoreContainer;
} }
@ -132,7 +132,7 @@ class DggContainer
* @param int $property The number specifies the option * @param int $property The number specifies the option
* @param mixed $value * @param mixed $value
*/ */
public function setOPT($property, $value) public function setOPT($property, $value): void
{ {
$this->OPT[$property] = $value; $this->OPT[$property] = $value;
} }
@ -168,7 +168,7 @@ class DggContainer
* *
* @param array $pValue * @param array $pValue
*/ */
public function setIDCLs($pValue) public function setIDCLs($pValue): void
{ {
$this->IDCLs = $pValue; $this->IDCLs = $pValue;
} }

View File

@ -16,7 +16,7 @@ class BstoreContainer
* *
* @param BstoreContainer\BSE $BSE * @param BstoreContainer\BSE $BSE
*/ */
public function addBSE($BSE) public function addBSE($BSE): void
{ {
$this->BSECollection[] = $BSE; $this->BSECollection[] = $BSE;
$BSE->setParent($this); $BSE->setParent($this);

View File

@ -41,7 +41,7 @@ class BSE
* *
* @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer $parent * @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer $parent
*/ */
public function setParent($parent) public function setParent($parent): void
{ {
$this->parent = $parent; $this->parent = $parent;
} }
@ -61,7 +61,7 @@ class BSE
* *
* @param BSE\Blip $blip * @param BSE\Blip $blip
*/ */
public function setBlip($blip) public function setBlip($blip): void
{ {
$this->blip = $blip; $this->blip = $blip;
$blip->setParent($this); $blip->setParent($this);
@ -82,7 +82,7 @@ class BSE
* *
* @param int $blipType * @param int $blipType
*/ */
public function setBlipType($blipType) public function setBlipType($blipType): void
{ {
$this->blipType = $blipType; $this->blipType = $blipType;
} }

View File

@ -33,7 +33,7 @@ class Blip
* *
* @param string $data * @param string $data
*/ */
public function setData($data) public function setData($data): void
{ {
$this->data = $data; $this->data = $data;
} }
@ -43,7 +43,7 @@ class Blip
* *
* @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE $parent * @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE $parent
*/ */
public function setParent($parent) public function setParent($parent): void
{ {
$this->parent = $parent; $this->parent = $parent;
} }

View File

@ -19,7 +19,7 @@ class File
* *
* @param bool $useUploadTempDir Use File Upload Temporary directory (true or false) * @param bool $useUploadTempDir Use File Upload Temporary directory (true or false)
*/ */
public static function setUseUploadTempDirectory($useUploadTempDir) public static function setUseUploadTempDirectory($useUploadTempDir): void
{ {
self::$useUploadTempDirectory = (bool) $useUploadTempDir; self::$useUploadTempDirectory = (bool) $useUploadTempDir;
} }
@ -129,7 +129,7 @@ class File
* *
* @param string $filename * @param string $filename
*/ */
public static function assertFile($filename) public static function assertFile($filename): void
{ {
if (!is_file($filename)) { if (!is_file($filename)) {
throw new InvalidArgumentException('File "' . $filename . '" does not exist.'); throw new InvalidArgumentException('File "' . $filename . '" does not exist.');

View File

@ -198,7 +198,7 @@ class Font
* *
* @param string $pValue * @param string $pValue
*/ */
public static function setTrueTypeFontPath($pValue) public static function setTrueTypeFontPath($pValue): void
{ {
self::$trueTypeFontPath = $pValue; self::$trueTypeFontPath = $pValue;
} }
@ -223,7 +223,7 @@ class Font
* *
* @return int Column width * @return int Column width
*/ */
public static function calculateColumnWidth(\PhpOffice\PhpSpreadsheet\Style\Font $font, $cellText = '', $rotation = 0, \PhpOffice\PhpSpreadsheet\Style\Font $defaultFont = null) public static function calculateColumnWidth(\PhpOffice\PhpSpreadsheet\Style\Font $font, $cellText = '', $rotation = 0, ?\PhpOffice\PhpSpreadsheet\Style\Font $defaultFont = null)
{ {
// If it is rich text, use plain text // If it is rich text, use plain text
if ($cellText instanceof RichText) { if ($cellText instanceof RichText) {
@ -303,7 +303,6 @@ class Font
* Get approximate width in pixels for a string of text in a certain font at a certain rotation angle. * Get approximate width in pixels for a string of text in a certain font at a certain rotation angle.
* *
* @param string $columnText * @param string $columnText
* @param \PhpOffice\PhpSpreadsheet\Style\Font $font
* @param int $rotation * @param int $rotation
* *
* @return int Text width in pixels (no padding added) * @return int Text width in pixels (no padding added)

View File

@ -73,7 +73,7 @@ class EigenvalueDecomposition
/** /**
* Symmetric Householder reduction to tridiagonal form. * Symmetric Householder reduction to tridiagonal form.
*/ */
private function tred2() private function tred2(): void
{ {
// This is derived from the Algol procedures tred2 by // This is derived from the Algol procedures tred2 by
// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
@ -96,7 +96,7 @@ class EigenvalueDecomposition
// Generate Householder vector. // Generate Householder vector.
for ($k = 0; $k < $i; ++$k) { for ($k = 0; $k < $i; ++$k) {
$this->d[$k] /= $scale; $this->d[$k] /= $scale;
$h += pow($this->d[$k], 2); $h += $this->d[$k] ** 2;
} }
$f = $this->d[$i_]; $f = $this->d[$i_];
$g = sqrt($h); $g = sqrt($h);
@ -180,7 +180,7 @@ class EigenvalueDecomposition
* Auto. Comp., Vol.ii-Linear Algebra, and the corresponding * Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
* Fortran subroutine in EISPACK. * Fortran subroutine in EISPACK.
*/ */
private function tql2() private function tql2(): void
{ {
for ($i = 1; $i < $this->n; ++$i) { for ($i = 1; $i < $this->n; ++$i) {
$this->e[$i - 1] = $this->e[$i]; $this->e[$i - 1] = $this->e[$i];
@ -188,7 +188,7 @@ class EigenvalueDecomposition
$this->e[$this->n - 1] = 0.0; $this->e[$this->n - 1] = 0.0;
$f = 0.0; $f = 0.0;
$tst1 = 0.0; $tst1 = 0.0;
$eps = pow(2.0, -52.0); $eps = 2.0 ** (-52.0);
for ($l = 0; $l < $this->n; ++$l) { for ($l = 0; $l < $this->n; ++$l) {
// Find small subdiagonal element // Find small subdiagonal element
@ -206,7 +206,7 @@ class EigenvalueDecomposition
$iter = 0; $iter = 0;
do { do {
// Could check iteration count here. // Could check iteration count here.
$iter += 1; ++$iter;
// Compute implicit shift // Compute implicit shift
$g = $this->d[$l]; $g = $this->d[$l];
$p = ($this->d[$l + 1] - $g) / (2.0 * $this->e[$l]); $p = ($this->d[$l + 1] - $g) / (2.0 * $this->e[$l]);
@ -287,7 +287,7 @@ class EigenvalueDecomposition
* Vol.ii-Linear Algebra, and the corresponding * Vol.ii-Linear Algebra, and the corresponding
* Fortran subroutines in EISPACK. * Fortran subroutines in EISPACK.
*/ */
private function orthes() private function orthes(): void
{ {
$low = 0; $low = 0;
$high = $this->n - 1; $high = $this->n - 1;
@ -372,7 +372,7 @@ class EigenvalueDecomposition
* @param mixed $yr * @param mixed $yr
* @param mixed $yi * @param mixed $yi
*/ */
private function cdiv($xr, $xi, $yr, $yi) private function cdiv($xr, $xi, $yr, $yi): void
{ {
if (abs($yr) > abs($yi)) { if (abs($yr) > abs($yi)) {
$r = $yi / $yr; $r = $yi / $yr;
@ -395,21 +395,21 @@ class EigenvalueDecomposition
* Vol.ii-Linear Algebra, and the corresponding * Vol.ii-Linear Algebra, and the corresponding
* Fortran subroutine in EISPACK. * Fortran subroutine in EISPACK.
*/ */
private function hqr2() private function hqr2(): void
{ {
// Initialize // Initialize
$nn = $this->n; $nn = $this->n;
$n = $nn - 1; $n = $nn - 1;
$low = 0; $low = 0;
$high = $nn - 1; $high = $nn - 1;
$eps = pow(2.0, -52.0); $eps = 2.0 ** (-52.0);
$exshift = 0.0; $exshift = 0.0;
$p = $q = $r = $s = $z = 0; $p = $q = $r = $s = $z = 0;
// Store roots isolated by balanc and compute matrix norm // Store roots isolated by balanc and compute matrix norm
$norm = 0.0; $norm = 0.0;
for ($i = 0; $i < $nn; ++$i) { for ($i = 0; $i < $nn; ++$i) {
if (($i < $low) or ($i > $high)) { if (($i < $low) || ($i > $high)) {
$this->d[$i] = $this->H[$i][$i]; $this->d[$i] = $this->H[$i][$i];
$this->e[$i] = 0.0; $this->e[$i] = 0.0;
} }

View File

@ -159,11 +159,6 @@ class Matrix
* *
* Get a submatrix * Get a submatrix
* *
* @param int $i0 Initial row index
* @param int $iF Final row index
* @param int $j0 Initial column index
* @param int $jF Final column index
*
* @return Matrix Submatrix * @return Matrix Submatrix
*/ */
public function getMatrix(...$args) public function getMatrix(...$args)
@ -477,8 +472,6 @@ class Matrix
* *
* A + B * A + B
* *
* @param mixed $B Matrix/Array
*
* @return Matrix Sum * @return Matrix Sum
*/ */
public function plus(...$args) public function plus(...$args)
@ -522,8 +515,6 @@ class Matrix
* *
* A = A + B * A = A + B
* *
* @param mixed $B Matrix/Array
*
* @return $this * @return $this
*/ */
public function plusEquals(...$args) public function plusEquals(...$args)
@ -581,8 +572,6 @@ class Matrix
* *
* A - B * A - B
* *
* @param mixed $B Matrix/Array
*
* @return Matrix Sum * @return Matrix Sum
*/ */
public function minus(...$args) public function minus(...$args)
@ -626,8 +615,6 @@ class Matrix
* *
* A = A - B * A = A - B
* *
* @param mixed $B Matrix/Array
*
* @return $this * @return $this
*/ */
public function minusEquals(...$args) public function minusEquals(...$args)
@ -686,8 +673,6 @@ class Matrix
* Element-by-element multiplication * Element-by-element multiplication
* Cij = Aij * Bij * Cij = Aij * Bij
* *
* @param mixed $B Matrix/Array
*
* @return Matrix Matrix Cij * @return Matrix Matrix Cij
*/ */
public function arrayTimes(...$args) public function arrayTimes(...$args)
@ -732,8 +717,6 @@ class Matrix
* Element-by-element multiplication * Element-by-element multiplication
* Aij = Aij * Bij * Aij = Aij * Bij
* *
* @param mixed $B Matrix/Array
*
* @return $this * @return $this
*/ */
public function arrayTimesEquals(...$args) public function arrayTimesEquals(...$args)
@ -792,8 +775,6 @@ class Matrix
* Element-by-element right division * Element-by-element right division
* A / B * A / B
* *
* @param Matrix $B Matrix B
*
* @return Matrix Division result * @return Matrix Division result
*/ */
public function arrayRightDivide(...$args) public function arrayRightDivide(...$args)
@ -857,8 +838,6 @@ class Matrix
* Element-by-element right division * Element-by-element right division
* Aij = Aij / Bij * Aij = Aij / Bij
* *
* @param mixed $B Matrix/Array
*
* @return Matrix Matrix Aij * @return Matrix Matrix Aij
*/ */
public function arrayRightDivideEquals(...$args) public function arrayRightDivideEquals(...$args)
@ -903,8 +882,6 @@ class Matrix
* Element-by-element Left division * Element-by-element Left division
* A / B * A / B
* *
* @param Matrix $B Matrix B
*
* @return Matrix Division result * @return Matrix Division result
*/ */
public function arrayLeftDivide(...$args) public function arrayLeftDivide(...$args)
@ -949,8 +926,6 @@ class Matrix
* Element-by-element Left division * Element-by-element Left division
* Aij = Aij / Bij * Aij = Aij / Bij
* *
* @param mixed $B Matrix/Array
*
* @return Matrix Matrix Aij * @return Matrix Matrix Aij
*/ */
public function arrayLeftDivideEquals(...$args) public function arrayLeftDivideEquals(...$args)
@ -994,8 +969,6 @@ class Matrix
* *
* Matrix multiplication * Matrix multiplication
* *
* @param mixed $n Matrix/Array/Scalar
*
* @return Matrix Product * @return Matrix Product
*/ */
public function times(...$args) public function times(...$args)
@ -1089,8 +1062,6 @@ class Matrix
* *
* A = A ^ B * A = A ^ B
* *
* @param mixed $B Matrix/Array
*
* @return $this * @return $this
*/ */
public function power(...$args) public function power(...$args)
@ -1130,7 +1101,7 @@ class Matrix
$validValues &= StringHelper::convertToNumberIfFraction($value); $validValues &= StringHelper::convertToNumberIfFraction($value);
} }
if ($validValues) { if ($validValues) {
$this->A[$i][$j] = pow($this->A[$i][$j], $value); $this->A[$i][$j] = $this->A[$i][$j] ** $value;
} else { } else {
$this->A[$i][$j] = Functions::NAN(); $this->A[$i][$j] = Functions::NAN();
} }
@ -1148,8 +1119,6 @@ class Matrix
* *
* A = A & B * A = A & B
* *
* @param mixed $B Matrix/Array
*
* @return $this * @return $this
*/ */
public function concat(...$args) public function concat(...$args)

View File

@ -117,7 +117,7 @@ class SingularValueDecomposition
} }
} }
if ($wantu and ($k < $nct)) { if ($wantu && ($k < $nct)) {
// Place the transformation in U for subsequent back // Place the transformation in U for subsequent back
// multiplication. // multiplication.
for ($i = $k; $i < $this->m; ++$i) { for ($i = $k; $i < $this->m; ++$i) {
@ -143,7 +143,7 @@ class SingularValueDecomposition
$e[$k + 1] += 1.0; $e[$k + 1] += 1.0;
} }
$e[$k] = -$e[$k]; $e[$k] = -$e[$k];
if (($k + 1 < $this->m) and ($e[$k] != 0.0)) { if (($k + 1 < $this->m) && ($e[$k] != 0.0)) {
// Apply the transformation. // Apply the transformation.
for ($i = $k + 1; $i < $this->m; ++$i) { for ($i = $k + 1; $i < $this->m; ++$i) {
$work[$i] = 0.0; $work[$i] = 0.0;
@ -221,7 +221,7 @@ class SingularValueDecomposition
// If required, generate V. // If required, generate V.
if ($wantv) { if ($wantv) {
for ($k = $this->n - 1; $k >= 0; --$k) { for ($k = $this->n - 1; $k >= 0; --$k) {
if (($k < $nrt) and ($e[$k] != 0.0)) { if (($k < $nrt) && ($e[$k] != 0.0)) {
for ($j = $k + 1; $j < $nu; ++$j) { for ($j = $k + 1; $j < $nu; ++$j) {
$t = 0; $t = 0;
for ($i = $k + 1; $i < $this->n; ++$i) { for ($i = $k + 1; $i < $this->n; ++$i) {
@ -243,7 +243,7 @@ class SingularValueDecomposition
// Main iteration loop for the singular values. // Main iteration loop for the singular values.
$pp = $p - 1; $pp = $p - 1;
$iter = 0; $iter = 0;
$eps = pow(2.0, -52.0); $eps = 2.0 ** (-52.0);
while ($p > 0) { while ($p > 0) {
// Here is where a test for too many iterations would go. // Here is where a test for too many iterations would go.
@ -415,14 +415,14 @@ class SingularValueDecomposition
$t = $this->s[$k]; $t = $this->s[$k];
$this->s[$k] = $this->s[$k + 1]; $this->s[$k] = $this->s[$k + 1];
$this->s[$k + 1] = $t; $this->s[$k + 1] = $t;
if ($wantv and ($k < $this->n - 1)) { if ($wantv && ($k < $this->n - 1)) {
for ($i = 0; $i < $this->n; ++$i) { for ($i = 0; $i < $this->n; ++$i) {
$t = $this->V[$i][$k + 1]; $t = $this->V[$i][$k + 1];
$this->V[$i][$k + 1] = $this->V[$i][$k]; $this->V[$i][$k + 1] = $this->V[$i][$k];
$this->V[$i][$k] = $t; $this->V[$i][$k] = $t;
} }
} }
if ($wantu and ($k < $this->m - 1)) { if ($wantu && ($k < $this->m - 1)) {
for ($i = 0; $i < $this->m; ++$i) { for ($i = 0; $i < $this->m; ++$i) {
$t = $this->U[$i][$k + 1]; $t = $this->U[$i][$k + 1];
$this->U[$i][$k + 1] = $this->U[$i][$k]; $this->U[$i][$k + 1] = $this->U[$i][$k];
@ -513,7 +513,7 @@ class SingularValueDecomposition
*/ */
public function rank() public function rank()
{ {
$eps = pow(2.0, -52.0); $eps = 2.0 ** (-52.0);
$tol = max($this->m, $this->n) * $this->s[0] * $eps; $tol = max($this->m, $this->n) * $this->s[0] * $eps;
$r = 0; $r = 0;
$iMax = count($this->s); $iMax = count($this->s);

View File

@ -117,7 +117,7 @@ class OLE
*/ */
public function read($file) public function read($file)
{ {
$fh = fopen($file, 'r'); $fh = fopen($file, 'rb');
if (!$fh) { if (!$fh) {
throw new ReaderException("Can't open file $file"); throw new ReaderException("Can't open file $file");
} }
@ -133,8 +133,8 @@ class OLE
throw new ReaderException('Only Little-Endian encoding is supported.'); throw new ReaderException('Only Little-Endian encoding is supported.');
} }
// Size of blocks and short blocks in bytes // Size of blocks and short blocks in bytes
$this->bigBlockSize = pow(2, self::_readInt2($fh)); $this->bigBlockSize = 2 ** self::_readInt2($fh);
$this->smallBlockSize = pow(2, self::_readInt2($fh)); $this->smallBlockSize = 2 ** self::_readInt2($fh);
// Skip UID, revision number and version number // Skip UID, revision number and version number
fseek($fh, 44); fseek($fh, 44);
@ -239,7 +239,7 @@ class OLE
$path .= '&blockId=' . $blockIdOrPps; $path .= '&blockId=' . $blockIdOrPps;
} }
return fopen($path, 'r'); return fopen($path, 'rb');
} }
/** /**
@ -502,7 +502,7 @@ 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 = 2 ** 32;
// days from 1-1-1601 until the beggining of UNIX era // days from 1-1-1601 until the beggining of UNIX era
$days = 134774; $days = 134774;

View File

@ -101,7 +101,7 @@ class ChainedBlockStream
/** /**
* Implements support for fclose(). * Implements support for fclose().
*/ */
public function stream_close() // @codingStandardsIgnoreLine public function stream_close(): void // @codingStandardsIgnoreLine
{ {
$this->ole = null; $this->ole = null;
unset($GLOBALS['_OLE_INSTANCES']); unset($GLOBALS['_OLE_INSTANCES']);

View File

@ -59,7 +59,7 @@ class File extends PPS
* *
* @param string $data The data to append * @param string $data The data to append
*/ */
public function append($data) public function append($data): void
{ {
$this->_data .= $data; $this->_data .= $data;
} }

View File

@ -73,12 +73,10 @@ class Root extends PPS
$this->fileHandle = $fileHandle; $this->fileHandle = $fileHandle;
// Initial Setting for saving // Initial Setting for saving
$this->bigBlockSize = pow( $this->bigBlockSize = 2 ** (
2,
(isset($this->bigBlockSize)) ? self::adjust2($this->bigBlockSize) : 9 (isset($this->bigBlockSize)) ? self::adjust2($this->bigBlockSize) : 9
); );
$this->smallBlockSize = pow( $this->smallBlockSize = 2 ** (
2,
(isset($this->smallBlockSize)) ? self::adjust2($this->smallBlockSize) : 6 (isset($this->smallBlockSize)) ? self::adjust2($this->smallBlockSize) : 6
); );
@ -146,9 +144,9 @@ class Root extends PPS
* *
* @param int $i2 The argument * @param int $i2 The argument
* *
* @see save()
*
* @return float * @return float
*
* @see save()
*/ */
private static function adjust2($i2) private static function adjust2($i2)
{ {
@ -164,7 +162,7 @@ class Root extends PPS
* @param int $iBBcnt * @param int $iBBcnt
* @param int $iPPScnt * @param int $iPPScnt
*/ */
public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt) public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt): void
{ {
$FILE = $this->fileHandle; $FILE = $this->fileHandle;
@ -243,7 +241,7 @@ class Root extends PPS
* @param int $iStBlk * @param int $iStBlk
* @param array &$raList Reference to array of PPS's * @param array &$raList Reference to array of PPS's
*/ */
public function _saveBigData($iStBlk, &$raList) public function _saveBigData($iStBlk, &$raList): void
{ {
$FILE = $this->fileHandle; $FILE = $this->fileHandle;
@ -325,7 +323,7 @@ class Root extends PPS
* *
* @param array $raList Reference to an array with all PPS's * @param array $raList Reference to an array with all PPS's
*/ */
public function _savePps(&$raList) public function _savePps(&$raList): void
{ {
// Save each PPS WK // Save each PPS WK
$iC = count($raList); $iC = count($raList);
@ -347,7 +345,7 @@ class Root extends PPS
* @param int $iBsize * @param int $iBsize
* @param int $iPpsCnt * @param int $iPpsCnt
*/ */
public function _saveBbd($iSbdSize, $iBsize, $iPpsCnt) public function _saveBbd($iSbdSize, $iBsize, $iPpsCnt): void
{ {
$FILE = $this->fileHandle; $FILE = $this->fileHandle;
// Calculate Basic Setting // Calculate Basic Setting

View File

@ -95,7 +95,7 @@ class OLERead
* *
* @param $pFilename string Filename * @param $pFilename string Filename
*/ */
public function read($pFilename) public function read($pFilename): void
{ {
File::assertFile($pFilename); File::assertFile($pFilename);
@ -258,7 +258,7 @@ class OLERead
/** /**
* Read entries in the directory stream. * Read entries in the directory stream.
*/ */
private function readPropertySets() private function readPropertySets(): void
{ {
$offset = 0; $offset = 0;

View File

@ -63,7 +63,7 @@ class StringHelper
/** /**
* Build control characters array. * Build control characters array.
*/ */
private static function buildControlCharacters() private static function buildControlCharacters(): void
{ {
for ($i = 0; $i <= 31; ++$i) { for ($i = 0; $i <= 31; ++$i) {
if ($i != 9 && $i != 10 && $i != 13) { if ($i != 9 && $i != 10 && $i != 13) {
@ -77,7 +77,7 @@ class StringHelper
/** /**
* Build SYLK characters array. * Build SYLK characters array.
*/ */
private static function buildSYLKCharacters() private static function buildSYLKCharacters(): void
{ {
self::$SYLKCharacters = [ self::$SYLKCharacters = [
"\x1B 0" => chr(0), "\x1B 0" => chr(0),
@ -272,7 +272,7 @@ class StringHelper
return self::$isIconvEnabled; return self::$isIconvEnabled;
} }
private static function buildCharacterSets() private static function buildCharacterSets(): void
{ {
if (empty(self::$controlCharacters)) { if (empty(self::$controlCharacters)) {
self::buildControlCharacters(); self::buildControlCharacters();
@ -603,7 +603,7 @@ class StringHelper
* *
* @param string $pValue Character for decimal separator * @param string $pValue Character for decimal separator
*/ */
public static function setDecimalSeparator($pValue) public static function setDecimalSeparator($pValue): void
{ {
self::$decimalSeparator = $pValue; self::$decimalSeparator = $pValue;
} }
@ -636,7 +636,7 @@ class StringHelper
* *
* @param string $pValue Character for thousands separator * @param string $pValue Character for thousands separator
*/ */
public static function setThousandsSeparator($pValue) public static function setThousandsSeparator($pValue): void
{ {
self::$thousandsSeparator = $pValue; self::$thousandsSeparator = $pValue;
} }
@ -674,7 +674,7 @@ class StringHelper
* *
* @param string $pValue Character for currency code * @param string $pValue Character for currency code
*/ */
public static function setCurrencyCode($pValue) public static function setCurrencyCode($pValue): void
{ {
self::$currencyCode = $pValue; self::$currencyCode = $pValue;
} }

View File

@ -341,7 +341,7 @@ class BestFit
return $this->yBestFitValues; return $this->yBestFitValues;
} }
protected function calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const) protected function calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const): void
{ {
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0; $SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
foreach ($this->xValues as $xKey => $xValue) { foreach ($this->xValues as $xKey => $xValue) {
@ -377,7 +377,7 @@ class BestFit
$this->SSRegression = $this->goodnessOfFit * $SStot; $this->SSRegression = $this->goodnessOfFit * $SStot;
$this->covariance = $SScov / $this->valueCount; $this->covariance = $SScov / $this->valueCount;
$this->correlation = ($this->valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->valueCount * $sumX2 - pow($sumX, 2)) * ($this->valueCount * $sumY2 - pow($sumY, 2))); $this->correlation = ($this->valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->valueCount * $sumX2 - $sumX ** 2) * ($this->valueCount * $sumY2 - $sumY ** 2));
$this->slopeSE = $this->stdevOfResiduals / sqrt($SSsex); $this->slopeSE = $this->stdevOfResiduals / sqrt($SSsex);
$this->intersectSE = $this->stdevOfResiduals * sqrt(1 / ($this->valueCount - ($sumX * $sumX) / $sumX2)); $this->intersectSE = $this->stdevOfResiduals * sqrt(1 / ($this->valueCount - ($sumX * $sumX) / $sumX2));
if ($this->SSResiduals != 0.0) { if ($this->SSResiduals != 0.0) {
@ -400,7 +400,7 @@ class BestFit
* @param float[] $xValues * @param float[] $xValues
* @param bool $const * @param bool $const
*/ */
protected function leastSquareFit(array $yValues, array $xValues, $const) protected function leastSquareFit(array $yValues, array $xValues, $const): void
{ {
// calculate sums // calculate sums
$x_sum = array_sum($xValues); $x_sum = array_sum($xValues);

View File

@ -21,7 +21,7 @@ class ExponentialBestFit extends BestFit
*/ */
public function getValueOfYForX($xValue) public function getValueOfYForX($xValue)
{ {
return $this->getIntersect() * pow($this->getSlope(), ($xValue - $this->xOffset)); return $this->getIntersect() * $this->getSlope() ** ($xValue - $this->xOffset);
} }
/** /**
@ -90,7 +90,7 @@ class ExponentialBestFit extends BestFit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param bool $const * @param bool $const
*/ */
private function exponentialRegression($yValues, $xValues, $const) private function exponentialRegression($yValues, $xValues, $const): void
{ {
foreach ($yValues as &$value) { foreach ($yValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {

View File

@ -58,7 +58,7 @@ class LinearBestFit extends BestFit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param bool $const * @param bool $const
*/ */
private function linearRegression($yValues, $xValues, $const) private function linearRegression($yValues, $xValues, $const): void
{ {
$this->leastSquareFit($yValues, $xValues, $const); $this->leastSquareFit($yValues, $xValues, $const);
} }

View File

@ -58,7 +58,7 @@ class LogarithmicBestFit extends BestFit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param bool $const * @param bool $const
*/ */
private function logarithmicRegression($yValues, $xValues, $const) private function logarithmicRegression($yValues, $xValues, $const): void
{ {
foreach ($xValues as &$value) { foreach ($xValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {

View File

@ -44,7 +44,7 @@ class PolynomialBestFit extends BestFit
$slope = $this->getSlope(); $slope = $this->getSlope();
foreach ($slope as $key => $value) { foreach ($slope as $key => $value) {
if ($value != 0.0) { if ($value != 0.0) {
$retVal += $value * pow($xValue, $key + 1); $retVal += $value * $xValue ** ($key + 1);
} }
} }
@ -121,7 +121,7 @@ class PolynomialBestFit extends BestFit
* @param float[] $yValues The set of Y-values for this regression * @param float[] $yValues The set of Y-values for this regression
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
*/ */
private function polynomialRegression($order, $yValues, $xValues) private function polynomialRegression($order, $yValues, $xValues): void
{ {
// calculate sums // calculate sums
$x_sum = array_sum($xValues); $x_sum = array_sum($xValues);
@ -144,7 +144,7 @@ class PolynomialBestFit extends BestFit
$B = []; $B = [];
for ($i = 0; $i < $this->valueCount; ++$i) { for ($i = 0; $i < $this->valueCount; ++$i) {
for ($j = 0; $j <= $order; ++$j) { for ($j = 0; $j <= $order; ++$j) {
$A[$i][$j] = pow($xValues[$i], $j); $A[$i][$j] = $xValues[$i] ** $j;
} }
} }
for ($i = 0; $i < $this->valueCount; ++$i) { for ($i = 0; $i < $this->valueCount; ++$i) {
@ -157,7 +157,7 @@ class PolynomialBestFit extends BestFit
$coefficients = []; $coefficients = [];
for ($i = 0; $i < $C->getRowDimension(); ++$i) { for ($i = 0; $i < $C->getRowDimension(); ++$i) {
$r = $C->get($i, 0); $r = $C->get($i, 0);
if (abs($r) <= pow(10, -9)) { if (abs($r) <= 10 ** (-9)) {
$r = 0; $r = 0;
} }
$coefficients[] = $r; $coefficients[] = $r;

View File

@ -21,7 +21,7 @@ class PowerBestFit extends BestFit
*/ */
public function getValueOfYForX($xValue) public function getValueOfYForX($xValue)
{ {
return $this->getIntersect() * pow(($xValue - $this->xOffset), $this->getSlope()); return $this->getIntersect() * ($xValue - $this->xOffset) ** $this->getSlope();
} }
/** /**
@ -33,7 +33,7 @@ class PowerBestFit extends BestFit
*/ */
public function getValueOfXForY($yValue) public function getValueOfXForY($yValue)
{ {
return pow((($yValue + $this->yOffset) / $this->getIntersect()), (1 / $this->getSlope())); return (($yValue + $this->yOffset) / $this->getIntersect()) ** (1 / $this->getSlope());
} }
/** /**
@ -74,7 +74,7 @@ class PowerBestFit extends BestFit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param bool $const * @param bool $const
*/ */
private function powerRegression($yValues, $xValues, $const) private function powerRegression($yValues, $xValues, $const): void
{ {
foreach ($xValues as &$value) { foreach ($xValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {

View File

@ -25,7 +25,7 @@ class Xls
$columnDimensions = $sheet->getColumnDimensions(); $columnDimensions = $sheet->getColumnDimensions();
// first find the true column width in pixels (uncollapsed and unhidden) // first find the true column width in pixels (uncollapsed and unhidden)
if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) { if (isset($columnDimensions[$col]) && $columnDimensions[$col]->getWidth() != -1) {
// then we have column dimension with explicit width // then we have column dimension with explicit width
$columnDimension = $columnDimensions[$col]; $columnDimension = $columnDimensions[$col];
$width = $columnDimension->getWidth(); $width = $columnDimension->getWidth();
@ -41,7 +41,7 @@ class Xls
} }
// now find the effective column width in pixels // now find the effective column width in pixels
if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) { if (isset($columnDimensions[$col]) && !$columnDimensions[$col]->getVisible()) {
$effectivePixelWidth = 0; $effectivePixelWidth = 0;
} else { } else {
$effectivePixelWidth = $pixelWidth; $effectivePixelWidth = $pixelWidth;
@ -68,7 +68,7 @@ class Xls
$rowDimensions = $sheet->getRowDimensions(); $rowDimensions = $sheet->getRowDimensions();
// first find the true row height in pixels (uncollapsed and unhidden) // first find the true row height in pixels (uncollapsed and unhidden)
if (isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) { if (isset($rowDimensions[$row]) && $rowDimensions[$row]->getRowHeight() != -1) {
// then we have a row dimension // then we have a row dimension
$rowDimension = $rowDimensions[$row]; $rowDimension = $rowDimensions[$row];
$rowHeight = $rowDimension->getRowHeight(); $rowHeight = $rowDimension->getRowHeight();
@ -85,7 +85,7 @@ class Xls
} }
// now find the effective row height in pixels // now find the effective row height in pixels
if (isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible()) { if (isset($rowDimensions[$row]) && !$rowDimensions[$row]->getVisible()) {
$effectivePixelRowHeight = 0; $effectivePixelRowHeight = 0;
} else { } else {
$effectivePixelRowHeight = $pixelRowHeight; $effectivePixelRowHeight = $pixelRowHeight;
@ -98,7 +98,6 @@ class Xls
* Get the horizontal distance in pixels between two anchors * Get the horizontal distance in pixels between two anchors
* The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets. * The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets.
* *
* @param Worksheet $sheet
* @param string $startColumn * @param string $startColumn
* @param int $startOffsetX Offset within start cell measured in 1/1024 of the cell width * @param int $startOffsetX Offset within start cell measured in 1/1024 of the cell width
* @param string $endColumn * @param string $endColumn
@ -130,7 +129,6 @@ class Xls
* Get the vertical distance in pixels between two anchors * Get the vertical distance in pixels between two anchors
* The distanceY is found as sum of all the spanning rows minus two offsets. * The distanceY is found as sum of all the spanning rows minus two offsets.
* *
* @param Worksheet $sheet
* @param int $startRow (1-based) * @param int $startRow (1-based)
* @param int $startOffsetY Offset within start cell measured in 1/256 of the cell height * @param int $startOffsetY Offset within start cell measured in 1/256 of the cell height
* @param int $endRow (1-based) * @param int $endRow (1-based)

View File

@ -210,7 +210,7 @@ class Spreadsheet
* *
* @param bool $hasMacros true|false * @param bool $hasMacros true|false
*/ */
public function setHasMacros($hasMacros) public function setHasMacros($hasMacros): void
{ {
$this->hasMacros = (bool) $hasMacros; $this->hasMacros = (bool) $hasMacros;
} }
@ -220,7 +220,7 @@ class Spreadsheet
* *
* @param string $macroCode string|null * @param string $macroCode string|null
*/ */
public function setMacrosCode($macroCode) public function setMacrosCode($macroCode): void
{ {
$this->macrosCode = $macroCode; $this->macrosCode = $macroCode;
$this->setHasMacros($macroCode !== null); $this->setHasMacros($macroCode !== null);
@ -241,7 +241,7 @@ class Spreadsheet
* *
* @param null|string $certificate * @param null|string $certificate
*/ */
public function setMacrosCertificate($certificate) public function setMacrosCertificate($certificate): void
{ {
$this->macrosCertificate = $certificate; $this->macrosCertificate = $certificate;
} }
@ -269,7 +269,7 @@ class Spreadsheet
/** /**
* Remove all macros, certificate from spreadsheet. * Remove all macros, certificate from spreadsheet.
*/ */
public function discardMacros() public function discardMacros(): void
{ {
$this->hasMacros = false; $this->hasMacros = false;
$this->macrosCode = null; $this->macrosCode = null;
@ -282,7 +282,7 @@ class Spreadsheet
* @param null|mixed $target * @param null|mixed $target
* @param null|mixed $xmlData * @param null|mixed $xmlData
*/ */
public function setRibbonXMLData($target, $xmlData) public function setRibbonXMLData($target, $xmlData): void
{ {
if ($target !== null && $xmlData !== null) { if ($target !== null && $xmlData !== null) {
$this->ribbonXMLData = ['target' => $target, 'data' => $xmlData]; $this->ribbonXMLData = ['target' => $target, 'data' => $xmlData];
@ -327,7 +327,7 @@ class Spreadsheet
* @param null|mixed $BinObjectsNames * @param null|mixed $BinObjectsNames
* @param null|mixed $BinObjectsData * @param null|mixed $BinObjectsData
*/ */
public function setRibbonBinObjects($BinObjectsNames, $BinObjectsData) public function setRibbonBinObjects($BinObjectsNames, $BinObjectsData): void
{ {
if ($BinObjectsNames !== null && $BinObjectsData !== null) { if ($BinObjectsNames !== null && $BinObjectsData !== null) {
$this->ribbonBinObjects = ['names' => $BinObjectsNames, 'data' => $BinObjectsData]; $this->ribbonBinObjects = ['names' => $BinObjectsNames, 'data' => $BinObjectsData];
@ -354,10 +354,8 @@ class Spreadsheet
* It has to be minimized when the library start to support currently unparsed data. * It has to be minimized when the library start to support currently unparsed data.
* *
* @internal * @internal
*
* @param array $unparsedLoadedData
*/ */
public function setUnparsedLoadedData(array $unparsedLoadedData) public function setUnparsedLoadedData(array $unparsedLoadedData): void
{ {
$this->unparsedLoadedData = $unparsedLoadedData; $this->unparsedLoadedData = $unparsedLoadedData;
} }
@ -507,7 +505,7 @@ class Spreadsheet
* Disconnect all worksheets from this PhpSpreadsheet workbook object, * Disconnect all worksheets from this PhpSpreadsheet workbook object,
* typically so that the PhpSpreadsheet object can be unset. * typically so that the PhpSpreadsheet object can be unset.
*/ */
public function disconnectWorksheets() public function disconnectWorksheets(): void
{ {
$worksheet = null; $worksheet = null;
foreach ($this->workSheetCollection as $k => &$worksheet) { foreach ($this->workSheetCollection as $k => &$worksheet) {
@ -540,10 +538,8 @@ class Spreadsheet
/** /**
* Set properties. * Set properties.
*
* @param Document\Properties $pValue
*/ */
public function setProperties(Document\Properties $pValue) public function setProperties(Document\Properties $pValue): void
{ {
$this->properties = $pValue; $this->properties = $pValue;
} }
@ -560,10 +556,8 @@ class Spreadsheet
/** /**
* Set security. * Set security.
*
* @param Document\Security $pValue
*/ */
public function setSecurity(Document\Security $pValue) public function setSecurity(Document\Security $pValue): void
{ {
$this->security = $pValue; $this->security = $pValue;
} }
@ -608,7 +602,6 @@ class Spreadsheet
/** /**
* Add sheet. * Add sheet.
* *
* @param Worksheet $pSheet
* @param null|int $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)
* *
* @return Worksheet * @return Worksheet
@ -653,7 +646,7 @@ class Spreadsheet
* *
* @param int $pIndex Active sheet index * @param int $pIndex Active sheet index
*/ */
public function removeSheetByIndex($pIndex) public function removeSheetByIndex($pIndex): void
{ {
$numSheets = count($this->workSheetCollection); $numSheets = count($this->workSheetCollection);
if ($pIndex > $numSheets - 1) { if ($pIndex > $numSheets - 1) {
@ -722,8 +715,6 @@ class Spreadsheet
/** /**
* Get index for sheet. * Get index for sheet.
* *
* @param Worksheet $pSheet
*
* @return int index * @return int index
*/ */
public function getIndex(Worksheet $pSheet) public function getIndex(Worksheet $pSheet)
@ -885,8 +876,6 @@ class Spreadsheet
/** /**
* Add named range. * Add named range.
* *
* @param NamedRange $namedRange
*
* @return bool * @return bool
*/ */
public function addNamedRange(NamedRange $namedRange) public function addNamedRange(NamedRange $namedRange)
@ -910,7 +899,7 @@ class Spreadsheet
* *
* @return null|NamedRange * @return null|NamedRange
*/ */
public function getNamedRange($namedRange, Worksheet $pSheet = null) public function getNamedRange($namedRange, ?Worksheet $pSheet = null)
{ {
$returnValue = null; $returnValue = null;
@ -937,7 +926,7 @@ class Spreadsheet
* *
* @return $this * @return $this
*/ */
public function removeNamedRange($namedRange, Worksheet $pSheet = null) public function removeNamedRange($namedRange, ?Worksheet $pSheet = null)
{ {
if ($pSheet === null) { if ($pSheet === null) {
if (isset($this->namedRanges[$namedRange])) { if (isset($this->namedRanges[$namedRange])) {
@ -1060,10 +1049,8 @@ class Spreadsheet
/** /**
* Add a cellXf to the workbook. * Add a cellXf to the workbook.
*
* @param Style $style
*/ */
public function addCellXf(Style $style) public function addCellXf(Style $style): void
{ {
$this->cellXfCollection[] = $style; $this->cellXfCollection[] = $style;
$style->setIndex(count($this->cellXfCollection) - 1); $style->setIndex(count($this->cellXfCollection) - 1);
@ -1074,7 +1061,7 @@ class Spreadsheet
* *
* @param int $pIndex Index to cellXf * @param int $pIndex Index to cellXf
*/ */
public function removeCellXfByIndex($pIndex) public function removeCellXfByIndex($pIndex): void
{ {
if ($pIndex > count($this->cellXfCollection) - 1) { if ($pIndex > count($this->cellXfCollection) - 1) {
throw new Exception('CellXf index is out of bounds.'); throw new Exception('CellXf index is out of bounds.');
@ -1151,10 +1138,8 @@ class Spreadsheet
/** /**
* Add a cellStyleXf to the workbook. * Add a cellStyleXf to the workbook.
*
* @param Style $pStyle
*/ */
public function addCellStyleXf(Style $pStyle) public function addCellStyleXf(Style $pStyle): void
{ {
$this->cellStyleXfCollection[] = $pStyle; $this->cellStyleXfCollection[] = $pStyle;
$pStyle->setIndex(count($this->cellStyleXfCollection) - 1); $pStyle->setIndex(count($this->cellStyleXfCollection) - 1);
@ -1165,7 +1150,7 @@ class Spreadsheet
* *
* @param int $pIndex Index to cellXf * @param int $pIndex Index to cellXf
*/ */
public function removeCellStyleXfByIndex($pIndex) public function removeCellStyleXfByIndex($pIndex): void
{ {
if ($pIndex > count($this->cellStyleXfCollection) - 1) { if ($pIndex > count($this->cellStyleXfCollection) - 1) {
throw new Exception('CellStyleXf index is out of bounds.'); throw new Exception('CellStyleXf index is out of bounds.');
@ -1177,7 +1162,7 @@ class Spreadsheet
* Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells * Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells
* and columns in the workbook. * and columns in the workbook.
*/ */
public function garbageCollect() public function garbageCollect(): void
{ {
// how many references are there to each cellXf ? // how many references are there to each cellXf ?
$countReferencesCellXf = []; $countReferencesCellXf = [];
@ -1278,7 +1263,7 @@ class Spreadsheet
* *
* @param bool $showHorizontalScroll True if horizonal scroll bar is visible * @param bool $showHorizontalScroll True if horizonal scroll bar is visible
*/ */
public function setShowHorizontalScroll($showHorizontalScroll) public function setShowHorizontalScroll($showHorizontalScroll): void
{ {
$this->showHorizontalScroll = (bool) $showHorizontalScroll; $this->showHorizontalScroll = (bool) $showHorizontalScroll;
} }
@ -1298,7 +1283,7 @@ class Spreadsheet
* *
* @param bool $showVerticalScroll True if vertical scroll bar is visible * @param bool $showVerticalScroll True if vertical scroll bar is visible
*/ */
public function setShowVerticalScroll($showVerticalScroll) public function setShowVerticalScroll($showVerticalScroll): void
{ {
$this->showVerticalScroll = (bool) $showVerticalScroll; $this->showVerticalScroll = (bool) $showVerticalScroll;
} }
@ -1318,7 +1303,7 @@ class Spreadsheet
* *
* @param bool $showSheetTabs True if sheet tabs are visible * @param bool $showSheetTabs True if sheet tabs are visible
*/ */
public function setShowSheetTabs($showSheetTabs) public function setShowSheetTabs($showSheetTabs): void
{ {
$this->showSheetTabs = (bool) $showSheetTabs; $this->showSheetTabs = (bool) $showSheetTabs;
} }
@ -1338,7 +1323,7 @@ class Spreadsheet
* *
* @param bool $minimized true if workbook window is minimized * @param bool $minimized true if workbook window is minimized
*/ */
public function setMinimized($minimized) public function setMinimized($minimized): void
{ {
$this->minimized = (bool) $minimized; $this->minimized = (bool) $minimized;
} }
@ -1360,7 +1345,7 @@ class Spreadsheet
* *
* @param bool $autoFilterDateGrouping true if workbook window is minimized * @param bool $autoFilterDateGrouping true if workbook window is minimized
*/ */
public function setAutoFilterDateGrouping($autoFilterDateGrouping) public function setAutoFilterDateGrouping($autoFilterDateGrouping): void
{ {
$this->autoFilterDateGrouping = (bool) $autoFilterDateGrouping; $this->autoFilterDateGrouping = (bool) $autoFilterDateGrouping;
} }
@ -1380,7 +1365,7 @@ class Spreadsheet
* *
* @param int $firstSheetIndex First sheet in book view * @param int $firstSheetIndex First sheet in book view
*/ */
public function setFirstSheetIndex($firstSheetIndex) public function setFirstSheetIndex($firstSheetIndex): void
{ {
if ($firstSheetIndex >= 0) { if ($firstSheetIndex >= 0) {
$this->firstSheetIndex = (int) $firstSheetIndex; $this->firstSheetIndex = (int) $firstSheetIndex;
@ -1417,7 +1402,7 @@ class Spreadsheet
* *
* @param string $visibility visibility status of the workbook * @param string $visibility visibility status of the workbook
*/ */
public function setVisibility($visibility) public function setVisibility($visibility): void
{ {
if ($visibility === null) { if ($visibility === null) {
$visibility = self::VISIBILITY_VISIBLE; $visibility = self::VISIBILITY_VISIBLE;
@ -1447,7 +1432,7 @@ class Spreadsheet
* *
* @param int $tabRatio Ratio between the tabs bar and the horizontal scroll bar * @param int $tabRatio Ratio between the tabs bar and the horizontal scroll bar
*/ */
public function setTabRatio($tabRatio) public function setTabRatio($tabRatio): void
{ {
if ($tabRatio >= 0 || $tabRatio <= 1000) { if ($tabRatio >= 0 || $tabRatio <= 1000) {
$this->tabRatio = (int) $tabRatio; $this->tabRatio = (int) $tabRatio;

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