Merge branch 'master' into sheetpasswd

This commit is contained in:
oleibman 2021-07-01 06:52:17 -07:00 committed by GitHub
commit 5523fc935b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 144 additions and 428 deletions

View File

@ -68,7 +68,7 @@
"ext-zlib": "*",
"ezyang/htmlpurifier": "^4.13",
"maennchen/zipstream-php": "^2.1",
"markbaker/complex": "^2.0",
"markbaker/complex": "^3.0",
"markbaker/matrix": "^2.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",

62
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "9158fcde13425499acaf0da201637737",
"content-hash": "475a2da5744e2426d6201ca5d9c56283",
"packages": [
{
"name": "ezyang/htmlpurifier",
@ -133,16 +133,16 @@
},
{
"name": "markbaker/complex",
"version": "2.0.2",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
"reference": "d18272926d58065140314c01e18ec3dd7ae854ea"
"reference": "ab8bc271e404909db09ff2d5ffa1e538085c0f22"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/d18272926d58065140314c01e18ec3dd7ae854ea",
"reference": "d18272926d58065140314c01e18ec3dd7ae854ea",
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/ab8bc271e404909db09ff2d5ffa1e538085c0f22",
"reference": "ab8bc271e404909db09ff2d5ffa1e538085c0f22",
"shasum": ""
},
"require": {
@ -158,51 +158,7 @@
"autoload": {
"psr-4": {
"Complex\\": "classes/src/"
},
"files": [
"classes/src/functions/abs.php",
"classes/src/functions/acos.php",
"classes/src/functions/acosh.php",
"classes/src/functions/acot.php",
"classes/src/functions/acoth.php",
"classes/src/functions/acsc.php",
"classes/src/functions/acsch.php",
"classes/src/functions/argument.php",
"classes/src/functions/asec.php",
"classes/src/functions/asech.php",
"classes/src/functions/asin.php",
"classes/src/functions/asinh.php",
"classes/src/functions/atan.php",
"classes/src/functions/atanh.php",
"classes/src/functions/conjugate.php",
"classes/src/functions/cos.php",
"classes/src/functions/cosh.php",
"classes/src/functions/cot.php",
"classes/src/functions/coth.php",
"classes/src/functions/csc.php",
"classes/src/functions/csch.php",
"classes/src/functions/exp.php",
"classes/src/functions/inverse.php",
"classes/src/functions/ln.php",
"classes/src/functions/log2.php",
"classes/src/functions/log10.php",
"classes/src/functions/negative.php",
"classes/src/functions/pow.php",
"classes/src/functions/rho.php",
"classes/src/functions/sec.php",
"classes/src/functions/sech.php",
"classes/src/functions/sin.php",
"classes/src/functions/sinh.php",
"classes/src/functions/sqrt.php",
"classes/src/functions/tan.php",
"classes/src/functions/tanh.php",
"classes/src/functions/theta.php",
"classes/src/operations/add.php",
"classes/src/operations/subtract.php",
"classes/src/operations/multiply.php",
"classes/src/operations/divideby.php",
"classes/src/operations/divideinto.php"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -222,9 +178,9 @@
],
"support": {
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
"source": "https://github.com/MarkBaker/PHPComplex/tree/2.0.2"
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.1"
},
"time": "2021-05-24T10:53:30+00:00"
"time": "2021-06-29T15:32:53+00:00"
},
{
"name": "markbaker/matrix",
@ -5210,5 +5166,5 @@
"ext-zlib": "*"
},
"platform-dev": [],
"plugin-api-version": "2.0.0"
"plugin-api-version": "2.1.0"
}

View File

@ -525,111 +525,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:bothNegAndPos\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:bothNegAndPos\\(\\) has parameter \\$neg with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:bothNegAndPos\\(\\) has parameter \\$pos with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xirrPart1\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xirrPart1\\(\\) has parameter \\$dates with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xirrPart1\\(\\) has parameter \\$values with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xirrPart2\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xirrPart2\\(\\) has parameter \\$values with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xirrPart3\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xirrPart3\\(\\) has parameter \\$dates with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xirrPart3\\(\\) has parameter \\$values with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xirrPart3\\(\\) has parameter \\$x1 with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xirrPart3\\(\\) has parameter \\$x2 with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xnpvOrdered\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xnpvOrdered\\(\\) has parameter \\$dates with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xnpvOrdered\\(\\) has parameter \\$ordered with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xnpvOrdered\\(\\) has parameter \\$rate with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xnpvOrdered\\(\\) has parameter \\$values with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:validateXnpv\\(\\) has parameter \\$dates with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:validateXnpv\\(\\) has parameter \\$rate with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:validateXnpv\\(\\) has parameter \\$values with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\Periodic\\:\\:presentValue\\(\\) has parameter \\$args with no typehint specified\\.$#"
count: 1
@ -2260,151 +2155,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/BaseReader.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:\\$rowspan has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:readBeginning\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:readEnding\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Parameter \\#2 \\$length of function fread expects int, int\\<min, \\-1\\>\\|int\\<1, 2048\\>\\|false given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:startsWithTag\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:startsWithTag\\(\\) has parameter \\$data with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:endsWithTag\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:endsWithTag\\(\\) has parameter \\$data with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:containsTags\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:containsTags\\(\\) has parameter \\$data with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:\\$dataArray has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:\\$tableLevel has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:\\$nestedColumn has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:setTableStartColumn\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:setTableStartColumn\\(\\) has parameter \\$column with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:getTableStartColumn\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:releaseTableStartColumn\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:flushCell\\(\\) has parameter \\$cellContent with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:flushCell\\(\\) has parameter \\$column with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:flushCell\\(\\) has parameter \\$row with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Argument of an invalid type DOMNamedNodeMap\\|null supplied for foreach, only iterables are supported\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:\\$spanEtc has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:\\$h1Etc has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Parameter \\#2 \\$styleValue of method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:setBorderStyle\\(\\) expects string, string\\|null given\\.$#"
count: 5
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, string\\|null given\\.$#"
count: 2
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Parameter \\#1 \\$pValue of method PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Alignment\\:\\:setHorizontal\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Parameter \\#1 \\$pValue of method PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Alignment\\:\\:setVertical\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:getStyleColor\\(\\) has parameter \\$value with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:\\$borderMappings has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Cannot call method getNamespaces\\(\\) on SimpleXMLElement\\|false\\.$#"
count: 1
@ -2565,41 +2315,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/Security/XmlScanner.php
-
message: "#^Parameter \\#1 \\$haystack of function substr_count expects string, string\\|false given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Slk.php
-
message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|false given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Slk.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Slk\\:\\:\\$colorArray has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Slk.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Slk\\:\\:\\$fontStyleMappings has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Slk.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Slk\\:\\:\\$styleSettingsFont has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Slk.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Slk\\:\\:\\$styleSettingsBorder has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Slk.php
-
message: "#^Parameter \\#1 \\$columnIndex of static method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Coordinate\\:\\:stringFromColumnIndex\\(\\) expects int, string given\\.$#"
count: 3
path: src/PhpSpreadsheet/Reader/Slk.php
-
message: "#^Call to an undefined method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Escher\\|PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Escher\\\\DgContainer\\|PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Escher\\\\DgContainer\\\\SpgrContainer\\|PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Escher\\\\DgContainer\\\\SpgrContainer\\\\SpContainer\\|PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Escher\\\\DggContainer\\|PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Escher\\\\DggContainer\\\\BstoreContainer\\|PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Escher\\\\DggContainer\\\\BstoreContainer\\\\BSE\\:\\:getDgContainer\\(\\)\\.$#"
count: 1
@ -6970,11 +6685,6 @@ parameters:
count: 3
path: tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php
-
message: "#^Parameter \\#1 \\$directory of function chdir expects string, string\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php
-
message: "#^Parameter \\#2 \\$locale of function setlocale expects string\\|null, string\\|false given\\.$#"
count: 1

View File

@ -4477,7 +4477,7 @@ class Calculation
}
// if the token is a binary operator, pop the top two values off the stack, do the operation, and push the result back on the stack
if (isset(self::$binaryOperators[$token])) {
if (!is_numeric($token) && isset(self::$binaryOperators[$token])) {
// We must have two operands, error if we don't
if (($operand2Data = $stack->pop()) === null) {
return $this->raiseFormulaError('Internal error - Operand value missing from stack');

View File

@ -32,7 +32,7 @@ class NonPeriodic
public static function rate($values, $dates, $guess = 0.1)
{
$rslt = self::xirrPart1($values, $dates);
if ($rslt) {
if ($rslt !== '') {
return $rslt;
}
@ -47,6 +47,8 @@ class NonPeriodic
if (!is_numeric($f1) || !is_numeric($f2)) {
break;
}
$f1 = (float) $f1;
$f2 = (float) $f2;
if (($f1 * $f2) < 0.0) {
$found = true;
@ -91,14 +93,18 @@ class NonPeriodic
return self::xnpvOrdered($rate, $values, $dates, true);
}
private static function bothNegAndPos($neg, $pos)
private static function bothNegAndPos(bool $neg, bool $pos): bool
{
return $neg && $pos;
}
private static function xirrPart1(&$values, &$dates)
/**
* @param mixed $values
* @param mixed $dates
*/
private static function xirrPart1(&$values, &$dates): string
{
if ((!is_array($values)) && (!is_array($dates))) {
if (!is_array($values) && !is_array($dates)) {
return Functions::NA();
}
$values = Functions::flattenArray($values);
@ -119,7 +125,7 @@ class NonPeriodic
return self::xirrPart2($values);
}
private static function xirrPart2(&$values)
private static function xirrPart2(array &$values): string
{
$valCount = count($values);
$foundpos = false;
@ -141,7 +147,10 @@ class NonPeriodic
return '';
}
private static function xirrPart3($values, $dates, $x1, $x2)
/**
* @return float|string
*/
private static function xirrPart3(array $values, array $dates, float $x1, float $x2)
{
$f = self::xnpvOrdered($x1, $values, $dates, false);
if ($f < 0.0) {
@ -156,7 +165,7 @@ class NonPeriodic
for ($i = 0; $i < self::FINANCIAL_MAX_ITERATIONS; ++$i) {
$dx *= 0.5;
$x_mid = $rtb + $dx;
$f_mid = self::xnpvOrdered($x_mid, $values, $dates, false);
$f_mid = (float) self::xnpvOrdered($x_mid, $values, $dates, false);
if ($f_mid <= 0.0) {
$rtb = $x_mid;
}
@ -170,7 +179,14 @@ class NonPeriodic
return $rslt;
}
private static function xnpvOrdered($rate, $values, $dates, $ordered = true)
/**
* @param mixed $rate
* @param mixed $values
* @param mixed $dates
*
* @return float|string
*/
private static function xnpvOrdered($rate, $values, $dates, bool $ordered = true)
{
$rate = Functions::flattenSingleValue($rate);
$values = Functions::flattenArray($values);
@ -209,7 +225,10 @@ class NonPeriodic
return is_finite($xnpv) ? $xnpv : Functions::VALUE();
}
private static function validateXnpv($rate, $values, $dates): void
/**
* @param mixed $rate
*/
private static function validateXnpv($rate, array $values, array $dates): void
{
if (!is_numeric($rate)) {
throw new Exception(Functions::VALUE());

View File

@ -123,6 +123,7 @@ class Html extends BaseReader
], // Italic
];
/** @var array */
protected $rowspan = [];
/**
@ -160,19 +161,19 @@ class Html extends BaseReader
return $startWithTag && $containsTags && $endsWithTag;
}
private function readBeginning()
private function readBeginning(): string
{
fseek($this->fileHandle, 0);
return fread($this->fileHandle, self::TEST_SAMPLE_SIZE);
return (string) fread($this->fileHandle, self::TEST_SAMPLE_SIZE);
}
private function readEnding()
private function readEnding(): string
{
$meta = stream_get_meta_data($this->fileHandle);
$filename = $meta['uri'];
$size = filesize($filename);
$size = (int) filesize($filename);
if ($size === 0) {
return '';
}
@ -184,20 +185,20 @@ class Html extends BaseReader
fseek($this->fileHandle, $size - $blockSize);
return fread($this->fileHandle, $blockSize);
return (string) fread($this->fileHandle, $blockSize);
}
private static function startsWithTag($data)
private static function startsWithTag(string $data): bool
{
return '<' === substr(trim($data), 0, 1);
}
private static function endsWithTag($data)
private static function endsWithTag(string $data): bool
{
return '>' === substr(trim($data), -1, 1);
}
private static function containsTags($data)
private static function containsTags(string $data): bool
{
return strlen($data) !== strlen(strip_tags($data));
}
@ -251,13 +252,17 @@ class Html extends BaseReader
}
// Data Array used for testing only, should write to Spreadsheet object on completion of tests
/** @var array */
protected $dataArray = [];
/** @var int */
protected $tableLevel = 0;
/** @var array */
protected $nestedColumn = ['A'];
protected function setTableStartColumn($column)
protected function setTableStartColumn(string $column): string
{
if ($this->tableLevel == 0) {
$column = 'A';
@ -268,18 +273,25 @@ class Html extends BaseReader
return $this->nestedColumn[$this->tableLevel];
}
protected function getTableStartColumn()
protected function getTableStartColumn(): string
{
return $this->nestedColumn[$this->tableLevel];
}
protected function releaseTableStartColumn()
protected function releaseTableStartColumn(): string
{
--$this->tableLevel;
return array_pop($this->nestedColumn);
}
/**
* Flush cell.
*
* @param string $column
* @param int|string $row
* @param mixed $cellContent
*/
protected function flushCell(Worksheet $sheet, $column, $row, &$cellContent): void
{
if (is_string($cellContent)) {
@ -302,7 +314,7 @@ class Html extends BaseReader
private function processDomElementBody(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child): void
{
$attributeArray = [];
foreach ($child->attributes as $attribute) {
foreach (($child->attributes ?? []) as $attribute) {
$attributeArray[$attribute->name] = $attribute->value;
}
@ -328,11 +340,11 @@ class Html extends BaseReader
}
}
private static $spanEtc = ['span', 'div', 'font', 'i', 'em', 'strong', 'b'];
private const SPAN_ETC = ['span', 'div', 'font', 'i', 'em', 'strong', 'b'];
private function processDomElementSpanEtc(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
{
if (in_array($child->nodeName, self::$spanEtc)) {
if (in_array((string) $child->nodeName, self::SPAN_ETC, true)) {
if (isset($attributeArray['class']) && $attributeArray['class'] === 'comment') {
$sheet->getComment($column . $row)
->getText()
@ -405,11 +417,11 @@ class Html extends BaseReader
}
}
private static $h1Etc = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'p'];
private const H1_ETC = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'p'];
private function processDomElementH1Etc(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
{
if (in_array($child->nodeName, self::$h1Etc)) {
if (in_array((string) $child->nodeName, self::H1_ETC, true)) {
if ($this->tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= $cellContent ? "\n" : '';
@ -628,6 +640,16 @@ class Html extends BaseReader
}
}
/**
* Make sure mb_convert_encoding returns string.
*
* @param mixed $result
*/
private static function ensureString($result): string
{
return is_string($result) ? $result : '';
}
/**
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
*
@ -646,7 +668,8 @@ class Html extends BaseReader
$dom = new DOMDocument();
// Reload the HTML file into the DOM object
try {
$loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanner->scanFile($pFilename), 'HTML-ENTITIES', 'UTF-8'));
$convert = mb_convert_encoding($this->securityScanner->scanFile($pFilename), 'HTML-ENTITIES', 'UTF-8');
$loaded = $dom->loadHTML(self::ensureString($convert));
} catch (Throwable $e) {
$loaded = false;
}
@ -668,7 +691,8 @@ class Html extends BaseReader
$dom = new DOMDocument();
// Reload the HTML file into the DOM object
try {
$loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanner->scan($content), 'HTML-ENTITIES', 'UTF-8'));
$convert = mb_convert_encoding($this->securityScanner->scan($content), 'HTML-ENTITIES', 'UTF-8');
$loaded = $dom->loadHTML(self::ensureString($convert));
} catch (Throwable $e) {
$loaded = false;
}
@ -774,6 +798,7 @@ class Html extends BaseReader
$value = explode(':', $st);
$styleName = isset($value[0]) ? trim($value[0]) : null;
$styleValue = isset($value[1]) ? trim($value[1]) : null;
$styleValueString = (string) $styleValue;
if (!$styleName) {
continue;
@ -782,7 +807,7 @@ class Html extends BaseReader
switch ($styleName) {
case 'background':
case 'background-color':
$styleColor = $this->getStyleColor($styleValue);
$styleColor = $this->getStyleColor($styleValueString);
if (!$styleColor) {
continue 2;
@ -792,7 +817,7 @@ class Html extends BaseReader
break;
case 'color':
$styleColor = $this->getStyleColor($styleValue);
$styleColor = $this->getStyleColor($styleValueString);
if (!$styleColor) {
continue 2;
@ -803,27 +828,27 @@ class Html extends BaseReader
break;
case 'border':
$this->setBorderStyle($cellStyle, $styleValue, 'allBorders');
$this->setBorderStyle($cellStyle, $styleValueString, 'allBorders');
break;
case 'border-top':
$this->setBorderStyle($cellStyle, $styleValue, 'top');
$this->setBorderStyle($cellStyle, $styleValueString, 'top');
break;
case 'border-bottom':
$this->setBorderStyle($cellStyle, $styleValue, 'bottom');
$this->setBorderStyle($cellStyle, $styleValueString, 'bottom');
break;
case 'border-left':
$this->setBorderStyle($cellStyle, $styleValue, 'left');
$this->setBorderStyle($cellStyle, $styleValueString, 'left');
break;
case 'border-right':
$this->setBorderStyle($cellStyle, $styleValue, 'right');
$this->setBorderStyle($cellStyle, $styleValueString, 'right');
break;
@ -849,7 +874,7 @@ class Html extends BaseReader
break;
case 'font-family':
$cellStyle->getFont()->setName(str_replace('\'', '', $styleValue));
$cellStyle->getFont()->setName(str_replace('\'', '', $styleValueString));
break;
@ -868,12 +893,12 @@ class Html extends BaseReader
break;
case 'text-align':
$cellStyle->getAlignment()->setHorizontal($styleValue);
$cellStyle->getAlignment()->setHorizontal($styleValueString);
break;
case 'vertical-align':
$cellStyle->getAlignment()->setVertical($styleValue);
$cellStyle->getAlignment()->setVertical($styleValueString);
break;
@ -900,7 +925,7 @@ class Html extends BaseReader
case 'text-indent':
$cellStyle->getAlignment()->setIndent(
(int) str_replace(['px'], '', $styleValue)
(int) str_replace(['px'], '', $styleValueString)
);
break;
@ -911,15 +936,18 @@ class Html extends BaseReader
/**
* Check if has #, so we can get clean hex.
*
* @param mixed $value
*
* @return null|string
*/
public function getStyleColor($value)
{
$value = (string) $value;
if (strpos($value ?? '', '#') === 0) {
return substr($value, 1);
}
return \PhpOffice\PhpSpreadsheet\Helper\Html::colourNameLookup((string) $value);
return \PhpOffice\PhpSpreadsheet\Helper\Html::colourNameLookup($value);
}
/**
@ -966,7 +994,7 @@ class Html extends BaseReader
);
}
private static $borderMappings = [
private const BORDER_MAPPINGS = [
'dash-dot' => Border::BORDER_DASHDOT,
'dash-dot-dot' => Border::BORDER_DASHDOTDOT,
'dashed' => Border::BORDER_DASHED,
@ -985,7 +1013,7 @@ class Html extends BaseReader
public static function getBorderMappings(): array
{
return self::$borderMappings;
return self::BORDER_MAPPINGS;
}
/**
@ -997,7 +1025,7 @@ class Html extends BaseReader
*/
public function getBorderStyle($style)
{
return (array_key_exists($style, self::$borderMappings)) ? self::$borderMappings[$style] : null;
return self::BORDER_MAPPINGS[$style] ?? null;
}
/**

View File

@ -79,7 +79,7 @@ class Slk extends BaseReader
}
// Read sample data (first 2 KB will do)
$data = fread($this->fileHandle, 2048);
$data = (string) fread($this->fileHandle, 2048);
// Count delimiters in file
$delimiterCount = substr_count($data, ';');
@ -210,7 +210,7 @@ class Slk extends BaseReader
return $this->loadIntoExisting($pFilename, $spreadsheet);
}
private $colorArray = [
private const COLOR_ARRAY = [
'FF00FFFF', // 0 - cyan
'FF000000', // 1 - black
'FFFFFFFF', // 2 - white
@ -221,7 +221,7 @@ class Slk extends BaseReader
'FFFF00FF', // 7 - magenta
];
private $fontStyleMappings = [
private const FONT_STYLE_MAPPINGS = [
'B' => 'bold',
'I' => 'italic',
'U' => 'underline',
@ -235,7 +235,8 @@ class Slk extends BaseReader
$key = false;
foreach ($temp as &$value) {
// Only count/replace in alternate array entries
if ($key = !$key) {
$key = !$key;
if ($key) {
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE);
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
// through the formula from left to right. Reversing means that we work right to left.through
@ -357,9 +358,9 @@ class Slk extends BaseReader
$this->addWidth($spreadsheet, $columnWidth, $startCol, $endCol);
}
private $styleSettingsFont = ['D' => 'bold', 'I' => 'italic'];
private const STYLE_SETTINGS_FONT = ['D' => 'bold', 'I' => 'italic'];
private $styleSettingsBorder = [
private const STYLE_SETTINGS_BORDER = [
'B' => 'bottom',
'L' => 'left',
'R' => 'right',
@ -372,10 +373,10 @@ class Slk extends BaseReader
$iMax = strlen($styleSettings);
for ($i = 0; $i < $iMax; ++$i) {
$char = $styleSettings[$i];
if (array_key_exists($char, $this->styleSettingsFont)) {
$styleData['font'][$this->styleSettingsFont[$char]] = true;
} elseif (array_key_exists($char, $this->styleSettingsBorder)) {
$styleData['borders'][$this->styleSettingsBorder[$char]]['borderStyle'] = Border::BORDER_THIN;
if (array_key_exists($char, self::STYLE_SETTINGS_FONT)) {
$styleData['font'][self::STYLE_SETTINGS_FONT[$char]] = true;
} elseif (array_key_exists($char, self::STYLE_SETTINGS_BORDER)) {
$styleData['borders'][self::STYLE_SETTINGS_BORDER[$char]]['borderStyle'] = Border::BORDER_THIN;
} elseif ($char == 'S') {
$styleData['fill']['fillType'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125;
} elseif ($char == 'M') {
@ -409,7 +410,7 @@ class Slk extends BaseReader
private function addStyle(Spreadsheet &$spreadsheet, array $styleData, string $row, string $column): void
{
if ((!empty($styleData)) && $column > '' && $row > '') {
$columnLetter = Coordinate::stringFromColumnIndex($column);
$columnLetter = Coordinate::stringFromColumnIndex((int) $column);
$spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($styleData);
}
}
@ -421,8 +422,8 @@ class Slk extends BaseReader
$startCol = Coordinate::stringFromColumnIndex((int) $startCol);
$spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth((float) $columnWidth);
} else {
$startCol = Coordinate::stringFromColumnIndex($startCol);
$endCol = Coordinate::stringFromColumnIndex($endCol);
$startCol = Coordinate::stringFromColumnIndex((int) $startCol);
$endCol = Coordinate::stringFromColumnIndex((int) $endCol);
$spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth((float) $columnWidth);
do {
$spreadsheet->getActiveSheet()->getColumnDimension(++$startCol)->setWidth((float) $columnWidth);
@ -469,7 +470,7 @@ class Slk extends BaseReader
{
if (preg_match('/L([1-9]\\d*)/', $rowDatum, $matches)) {
$fontColor = $matches[1] % 8;
$formatArray['font']['color']['argb'] = $this->colorArray[$fontColor];
$formatArray['font']['color']['argb'] = self::COLOR_ARRAY[$fontColor];
}
}
@ -478,8 +479,8 @@ class Slk extends BaseReader
$styleSettings = substr($rowDatum, 1);
$iMax = strlen($styleSettings);
for ($i = 0; $i < $iMax; ++$i) {
if (array_key_exists($styleSettings[$i], $this->fontStyleMappings)) {
$formatArray['font'][$this->fontStyleMappings[$styleSettings[$i]]] = true;
if (array_key_exists($styleSettings[$i], self::FONT_STYLE_MAPPINGS)) {
$formatArray['font'][self::FONT_STYLE_MAPPINGS[$styleSettings[$i]]] = true;
}
}
}

View File

@ -502,9 +502,6 @@ class OLE
}
$dateTime = Date::dateTimeFromTimestamp("$date");
// factor used for separating numbers into 4 bytes parts
$factor = 2 ** 32;
// days from 1-1-1601 until the beggining of UNIX era
$days = 134774;
// calculate seconds
@ -512,22 +509,15 @@ class OLE
// multiply just to make MS happy
$big_date *= 10000000;
$high_part = floor($big_date / $factor);
// lower 4 bytes
$low_part = floor((($big_date / $factor) - $high_part) * $factor);
// Make HEX string
$res = '';
for ($i = 0; $i < 4; ++$i) {
$hex = $low_part % 0x100;
$res .= pack('c', $hex);
$low_part /= 0x100;
}
for ($i = 0; $i < 4; ++$i) {
$hex = $high_part % 0x100;
$res .= pack('c', $hex);
$high_part /= 0x100;
$factor = 2 ** 56;
while ($factor >= 1) {
$hex = (int) floor($big_date / $factor);
$res = pack('c', $hex) . $res;
$big_date = fmod($big_date, $factor);
$factor /= 256;
}
return $res;

View File

@ -42,8 +42,8 @@ class StringTable extends WriterPart
!is_object($cellValue) &&
($cellValue !== null) &&
$cellValue !== '' &&
!isset($aFlippedStringTable[$cellValue]) &&
($cell->getDataType() == DataType::TYPE_STRING || $cell->getDataType() == DataType::TYPE_STRING2 || $cell->getDataType() == DataType::TYPE_NULL)
($cell->getDataType() == DataType::TYPE_STRING || $cell->getDataType() == DataType::TYPE_STRING2 || $cell->getDataType() == DataType::TYPE_NULL) &&
!isset($aFlippedStringTable[$cellValue])
) {
$aStringTable[] = $cellValue;
$aFlippedStringTable[$cellValue] = true;

View File

@ -92,7 +92,7 @@ class SubTotalTest extends AllSetupTeardown
'12' => false,
];
foreach ($visibleRows as $row => $visible) {
$rowDimension = $sheet->getRowDimension($row);
$rowDimension = $sheet->getRowDimension((int) $row);
$rowDimension->setVisible($visible);
}
$sheet->getCell('D2')->setValue("=SUBTOTAL($type, A1:$maxCol$maxRow)");

View File

@ -11,10 +11,13 @@ class EpochTest extends AbstractFunctional
public function providerFormats(): array
{
return [
['Ods', '1921-03-17 11:30:00Z'],
['Ods', '2021-03-17 11:30:00Z'],
['Ods', '2041-03-17 11:30:00Z'],
['Xls', '1921-03-17 11:30:00Z'],
['Xls', '2021-03-17 11:30:00Z'],
['Xls', '2041-03-17 11:30:00Z'],
['Xlsx', '1921-03-17 11:30:00Z'],
['Xlsx', '2021-03-17 11:30:00Z'],
['Xlsx', '2041-03-17 11:30:00Z'],
];

View File

@ -1,6 +1,6 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Reader;
namespace PhpOffice\PhpSpreadsheetTests\Reader\Slk;
use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
use PhpOffice\PhpSpreadsheet\Reader\Slk;
@ -14,7 +14,7 @@ class SlkTest extends \PHPUnit\Framework\TestCase
/**
* @var string
*/
private static $testbook = __DIR__ . '/../../../samples/templates/SylkTest.slk';
private static $testbook = __DIR__ . '/../../../../samples/templates/SylkTest.slk';
/**
* @var string
@ -23,7 +23,7 @@ class SlkTest extends \PHPUnit\Framework\TestCase
protected function teardown(): void
{
if ($this->filename) {
if ($this->filename !== '') {
unlink($this->filename);
$this->filename = '';
}
@ -134,6 +134,7 @@ class SlkTest extends \PHPUnit\Framework\TestCase
self::assertEquals(Border::BORDER_THIN, $sheet->getCell('C18')->getStyle()->getBorders()->getBottom()->getBorderStyle());
self::assertEquals(Border::BORDER_THIN, $sheet->getCell('C18')->getStyle()->getBorders()->getLeft()->getBorderStyle());
// Have not yet figured out how C6/C7 are centred
$spreadsheet->disconnectWorksheets();
}
public function testSheetIndex(): void
@ -147,6 +148,7 @@ class SlkTest extends \PHPUnit\Framework\TestCase
self::assertEquals('SylkTest', $sheet->getTitle());
self::assertEquals('FFFF0000', $sheet->getCell('A1')->getStyle()->getFont()->getColor()->getARGB());
$spreadsheet->disconnectWorksheets();
}
public function testLongName(): void
@ -160,5 +162,6 @@ class SlkTest extends \PHPUnit\Framework\TestCase
$sheet = $spreadsheet->getActiveSheet();
self::assertEquals('123456789a123456789b123456789c1', $sheet->getTitle());
self::assertEquals('FFFF0000', $sheet->getCell('A1')->getStyle()->getFont()->getColor()->getARGB());
$spreadsheet->disconnectWorksheets();
}
}

View File

@ -10,13 +10,18 @@ use PhpOffice\PhpSpreadsheetTests\Functional;
class ImagesRootTest extends Functional\AbstractFunctional
{
/**
* @var false|string
* @var string
*/
private $curdir;
private $curdir = '';
protected function setUp(): void
{
$this->curdir = getcwd();
$curdir = getcwd();
if ($curdir === false) {
self::fail('Unable to obtain current directory');
} else {
$this->curdir = $curdir;
}
}
protected function tearDown(): void
@ -64,5 +69,6 @@ class ImagesRootTest extends Functional\AbstractFunctional
self::assertCount(1, $img);
self::assertEquals("$root/$stub", $img[0]->getAttribute('src'));
self::assertEquals($desc, $img[0]->getAttribute('alt'));
$spreadsheet->disconnectWorksheets();
}
}