Merge branch 'master' into csvdflts

This commit is contained in:
oleibman 2021-05-16 06:13:40 -07:00 committed by GitHub
commit 251df6e61e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
333 changed files with 6463 additions and 6315 deletions

View File

@ -124,6 +124,37 @@ jobs:
- name: Code style with PHP_CodeSniffer
run: ./vendor/bin/phpcs -q --report=checkstyle | cs2pr
versions:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: none
tools: cs2pr
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Code Version Compatibility check with PHP_CodeSniffer
run: ./vendor/bin/phpcs -q --report-width=200 --report=summary,full src/ --standard=PHPCompatibility --runtime-set testVersion 7.2-
phpstan:
runs-on: ubuntu-latest
steps:

View File

@ -9,8 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Added
- Implemented basic AutoFiltering for Ods Reader and Writer [PR #2053](https://github.com/PHPOffice/PhpSpreadsheet/pull/2053)
- Implemented basic AutoFiltering for Gnumeric Reader [PR #2055](https://github.com/PHPOffice/PhpSpreadsheet/pull/2055)
- Improved support for Row and Column ranges in formulae [Issue #1755](https://github.com/PHPOffice/PhpSpreadsheet/issues/1755) [PR #2028](https://github.com/PHPOffice/PhpSpreadsheet/pull/2028)
- Implemented URLENCODE() Web Function
- Implemented the CHITEST(), CHISQ.DIST() and CHISQ.INV() and equivalent Statistical functions, for both left- and right-tailed distributions.
- Support for ActiveSheet and SelectedCells in the ODS Reader and Writer. [PR #1908](https://github.com/PHPOffice/PhpSpreadsheet/pull/1908)
- Support for notContainsText Conditional Style in xlsx [Issue #984](https://github.com/PHPOffice/PhpSpreadsheet/issues/984)
### Changed
@ -18,14 +23,15 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Deprecated
- Nothing.
- All Excel Function implementations in `Calculation\Database`, `Calculation\DateTime`, `Calculation\Engineering`, `Calculation\Financial`, `Calculation\Logical`, `Calculation\LookupRef`, `Calculation\MathTrig`, `Calculation\Statistical`, `Calculation\TextData` and `Calculation\Web` have been moved to dedicated classes for individual functions or groups of related functions. See the docblocks against all the deprecated methods for details of the new methods to call instead. At some point, these old classes will be deleted.
### Removed
- Nothing.
### Fixed
- Correctly handle absolute A1 references when converting to R1C1 format [PR #2060](https://github.com/PHPOffice/PhpSpreadsheet/pull/2060)
- Correct default fill style for conditional without a pattern defined [Issue #2035](https://github.com/PHPOffice/PhpSpreadsheet/issues/2035) [PR #2050](https://github.com/PHPOffice/PhpSpreadsheet/pull/2050)
- Fixed issue where array key check for existince before accessing arrays in Xlsx.php. [PR #1970](https://github.com/PHPOffice/PhpSpreadsheet/pull/1970)
- Fixed issue with quoted strings in number format mask rendered with toFormattedString() [Issue 1972#](https://github.com/PHPOffice/PhpSpreadsheet/issues/1972) [PR #1978](https://github.com/PHPOffice/PhpSpreadsheet/pull/1978)
- Fixed issue with percentage formats in number format mask rendered with toFormattedString() [Issue 1929#](https://github.com/PHPOffice/PhpSpreadsheet/issues/1929) [PR #1928](https://github.com/PHPOffice/PhpSpreadsheet/pull/1928)

View File

@ -53,7 +53,6 @@
},
"require": {
"php": "^7.2 || ^8.0",
"ext-simplexml": "*",
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
@ -61,6 +60,7 @@
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
@ -75,6 +75,7 @@
"psr/simple-cache": "^1.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"dompdf/dompdf": "^1.0",
"friendsofphp/php-cs-fixer": "^2.18",
"jpgraph/jpgraph": "^4.0",

79
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": "3be2673a6367d296c616bf9c34b77953",
"content-hash": "9158fcde13425499acaf0da201637737",
"packages": [
{
"name": "ezyang/htmlpurifier",
@ -802,6 +802,77 @@
],
"time": "2021-03-25T17:01:18+00:00"
},
{
"name": "dealerdirect/phpcodesniffer-composer-installer",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
"reference": "c960cf4629fab7155caca18c038ca7257b7595e3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/c960cf4629fab7155caca18c038ca7257b7595e3",
"reference": "c960cf4629fab7155caca18c038ca7257b7595e3",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0 || ^2.0",
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0"
},
"require-dev": {
"composer/composer": "*",
"enlightn/security-checker": "^1.2",
"phpcompatibility/php-compatibility": "^9.0"
},
"default-branch": true,
"type": "composer-plugin",
"extra": {
"class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
},
"autoload": {
"psr-4": {
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Franck Nijhof",
"email": "franck.nijhof@dealerdirect.com",
"homepage": "http://www.frenck.nl",
"role": "Developer / IT Manager"
}
],
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
"homepage": "http://www.dealerdirect.com",
"keywords": [
"PHPCodeSniffer",
"PHP_CodeSniffer",
"code quality",
"codesniffer",
"composer",
"installer",
"phpcs",
"plugin",
"qa",
"quality",
"standard",
"standards",
"style guide",
"stylecheck",
"tests"
],
"support": {
"issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues",
"source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer"
},
"time": "2021-03-14T13:49:41+00:00"
},
{
"name": "doctrine/annotations",
"version": "1.12.1",
@ -5065,12 +5136,13 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"dealerdirect/phpcodesniffer-composer-installer": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": "^7.2 || ^8.0",
"ext-simplexml": "*",
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
@ -5078,6 +5150,7 @@
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",

View File

@ -1220,13 +1220,13 @@
</tr>
<tr>
<td style="padding-left: 1em;">Merged Cells</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td style="text-align: center; color: green;"></td>
<td style="text-align: center; color: green;"></td>
<td></td>
<td></td>
<td style="text-align: center; color: green;"></td>
<td style="text-align: center; color: green;"></td>
<td>N/A</td>
<td>N/A</td>
<td></td>
<td></td>
<td></td>
@ -1313,13 +1313,13 @@
<td style="text-align: center; color: orange;"></td>
<td style="text-align: center; color: orange;"></td>
<td></td>
<td></td>
<td></td>
<td style="text-align: center; color: orange;"></td>
<td style="text-align: center; color: orange;"></td>
<td></td>
<td></td>
<td style="text-align: center; color: orange;"></td>
<td style="text-align: center; color: orange;"></td>
<td></td>
<td style="text-align: center; color: orange;"></td>
<td></td>
<td></td>
<td></td>

View File

@ -340,141 +340,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTime\\:\\:NETWORKDAYS\\(\\) has parameter \\$dateArgs with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTime.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTime\\:\\:WORKDAY\\(\\) has parameter \\$dateArgs with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTime.php
-
message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, string\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php
-
message: "#^Parameter \\#1 \\$haystack of function strpos expects string, float\\|int\\|string given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php
-
message: "#^Parameter \\#1 \\$PHPDateArray of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\DateValue\\:\\:finalResults\\(\\) expects array\\|false, array\\|bool given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php
-
message: "#^Parameter \\#1 \\$testVal1 of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Helpers\\:\\:adjustYear\\(\\) expects string, string\\|false given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php
-
message: "#^Parameter \\#2 \\$testVal2 of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Helpers\\:\\:adjustYear\\(\\) expects string, string\\|false given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php
-
message: "#^Parameter \\#1 \\$value of static method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\StringHelper\\:\\:testStringAsNumeric\\(\\) expects string, float\\|int\\|string given\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Datefunc.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Day\\:\\:weirdCondition\\(\\) has parameter \\$dateValue with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Day.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Helpers\\:\\:adjustDateByMonths\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Helpers\\:\\:adjustDateByMonths\\(\\) has parameter \\$adjustmentMonths with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Helpers\\:\\:adjustDateByMonths\\(\\) has parameter \\$dateValue with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php
-
message: "#^Parameter \\#1 \\$excelTimestamp of static method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Date\\:\\:excelToTimestamp\\(\\) expects float\\|int, bool\\|float given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Helpers\\:\\:validateNumericNull\\(\\) should return float\\|int but returns float\\|int\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\IsoWeekNum\\:\\:apparentBug\\(\\) has parameter \\$dateValue with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/IsoWeekNum.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\NetworkDays\\:\\:funcNetworkDays\\(\\) has parameter \\$dateArgs with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/NetworkDays.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\NetworkDays\\:\\:applySign\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/NetworkDays.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Time\\:\\:toIntWithNullBool\\(\\) has parameter \\$value with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php
-
message: "#^Cannot access offset 0 on array\\<int, string\\>\\|false\\.$#"
count: 3
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, array\\<int, string\\>\\|false given\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\WeekDay\\:\\:validateStyle\\(\\) has parameter \\$style with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/WeekDay.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\WorkDay\\:\\:funcWorkDay\\(\\) has parameter \\$dateArgs with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php
-
message: "#^Binary operation \"\\-\" between 7 and int\\|string results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php
-
message: "#^Binary operation \"\\-\" between 7 and int\\<5, max\\>\\|string results in an error\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php
-
message: "#^Binary operation \"\\-\" between 4 and int\\<5, max\\>\\|string results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php
-
message: "#^Binary operation \"\\-\" between int\\|string and int\\|string results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php
-
message: "#^Binary operation \"\\*\" between 100 and int\\|string results in an error\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\Logger\\:\\:writeDebugLog\\(\\) has parameter \\$args with no typehint specified\\.$#"
count: 1
@ -960,16 +825,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef.php
-
message: "#^Call to function is_bool\\(\\) with float\\|int\\|\\(string&numeric\\) will always evaluate to false\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef.php
-
message: "#^Cannot call method getCell\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/LookupRef.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\\\Address\\:\\:sheetName\\(\\) has no return typehint specified\\.$#"
count: 1
@ -1120,11 +975,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/LookupBase.php
-
message: "#^Parameter \\#3 \\$rowNum of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\\\Matrix\\:\\:extractRowValue\\(\\) expects int, float\\|int\\<0, max\\>\\|string given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\\\Matrix\\:\\:extractRowValue\\(\\) has no return typehint specified\\.$#"
count: 1
@ -1230,141 +1080,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\:\\:COMBIN\\(\\) should return int\\|string but returns float\\|int\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\:\\:EVEN\\(\\) should return int\\|string but returns float\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\:\\:FACT\\(\\) should return int\\|string but returns float\\|int\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\:\\:FACTDOUBLE\\(\\) should return int\\|string but returns float\\|int\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\:\\:MOD\\(\\) should return int\\|string but returns float\\|int\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\:\\:ODD\\(\\) should return int\\|string but returns float\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\:\\:SUMIFS\\(\\) should return float\\|string but returns float\\|string\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig.php
-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php
-
message: "#^Parameter \\#1 \\$number of function base_convert expects string, int\\<0, 9007199254740991\\> given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Base.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Helpers\\:\\:validateNumericNullBool\\(\\) should return float\\|int but returns float\\|int\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Helpers\\:\\:validateNumericNullSubstitution\\(\\) should return float\\|int but returns float\\|int\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Lcm\\:\\:factors\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Lcm.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Lcm\\:\\:factors\\(\\) has parameter \\$value with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Lcm.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Roman\\:\\:romanCut\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Roman.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Roman\\:\\:romanCut\\(\\) has parameter \\$n with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Roman.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Roman\\:\\:romanCut\\(\\) has parameter \\$num with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Roman.php
-
message: "#^Parameter \\#2 \\$precision of function round expects int, float\\|int given\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/MathTrig/RoundDown.php
-
message: "#^Parameter \\#2 \\$precision of function round expects int, float\\|int given\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/MathTrig/RoundUp.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Subtotal\\:\\:filterHiddenArgs\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Subtotal\\:\\:filterHiddenArgs\\(\\) has parameter \\$args with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Subtotal\\:\\:filterHiddenArgs\\(\\) has parameter \\$cellReference with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Subtotal\\:\\:filterFormulaArgs\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Subtotal\\:\\:filterFormulaArgs\\(\\) has parameter \\$args with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Subtotal\\:\\:filterFormulaArgs\\(\\) has parameter \\$cellReference with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
-
message: "#^Parameter \\#1 \\$function of function call_user_func_array expects callable\\(\\)\\: mixed, array\\('PhpOffice…'\\|'PhpOffice…'\\|'PhpOffice…'\\|'PhpOffice…'\\|'PhpOffice…'\\|'PhpOffice…'\\|'PhpOffice…'\\|'PhpOffice…', string\\) given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
-
message: "#^Parameter \\#1 \\$str of function rtrim expects string, int given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php
-
message: "#^Binary operation \"\\-\" between float\\|int and float\\|string results in an error\\.$#"
count: 4
path: src/PhpSpreadsheet/Calculation/Statistical.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\:\\:MAXIFS\\(\\) should return float but returns float\\|string\\|null\\.$#"
count: 1
@ -2730,91 +2445,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/BaseReader.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Gnumeric\\:\\:\\$referenceHelper has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Parameter \\#1 \\$fp of function fread expects resource, resource\\|false given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Gnumeric\\:\\:\\$mappings has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Offset 'No' does not exist on SimpleXMLElement\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Offset 'Unit' does not exist on SimpleXMLElement\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Cannot call method setWidth\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 3
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Cannot call method setVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Offset 'DefaultSizePts' does not exist on SimpleXMLElement\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Cannot call method setRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Cannot call method setVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Gnumeric\\:\\:parseBorderAttributes\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Gnumeric\\:\\:parseBorderAttributes\\(\\) has parameter \\$borderAttributes with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Gnumeric\\:\\:parseRichText\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Gnumeric\\:\\:parseRichText\\(\\) has parameter \\$is with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Gnumeric\\:\\:parseGnumericColour\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Gnumeric\\:\\:parseGnumericColour\\(\\) has parameter \\$gnmColour with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:\\$rowspan has no typehint specified\\.$#"
count: 1
@ -2930,16 +2560,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Cannot call method setRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 4
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Cannot call method setWidth\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 3
path: src/PhpSpreadsheet/Reader/Html.php
-
message: "#^Parameter \\#2 \\$styleValue of method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Html\\:\\:setBorderStyle\\(\\) expects string, string\\|null given\\.$#"
count: 5
@ -3025,21 +2645,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/Ods.php
-
message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, string\\|null given\\.$#"
count: 7
path: src/PhpSpreadsheet/Reader/Ods.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Ods\\:\\:convertToExcelAddressValue\\(\\) should return string but returns string\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Ods.php
-
message: "#^Parameter \\#3 \\$formula of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:translateSeparator\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Ods.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Ods\\\\PageSettings\\:\\:\\$officeNs has no typehint specified\\.$#"
count: 1
@ -3190,11 +2795,6 @@ parameters:
count: 3
path: src/PhpSpreadsheet/Reader/Slk.php
-
message: "#^Cannot call method setWidth\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
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
@ -3395,56 +2995,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Cannot call method setWidth\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Cannot call method setVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Cannot call method setOutlineLevel\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Cannot call method setCollapsed\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Cannot call method setXfIndex\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Cannot call method setRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Cannot call method setOutlineLevel\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Cannot call method setCollapsed\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Cannot call method setVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Cannot call method setXfIndex\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xls\\:\\:includeCellRangeFiltered\\(\\) has no return typehint specified\\.$#"
count: 1
@ -3630,16 +3180,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/Xls/RC4.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xls\\\\Style\\\\Border\\:\\:\\$map has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls/Style/Border.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xls\\\\Style\\\\FillPattern\\:\\:\\$map has no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php
-
message: "#^Cannot access property \\$Relationship on SimpleXMLElement\\|false\\.$#"
count: 12
@ -3845,31 +3385,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:readColor\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:readColor\\(\\) has parameter \\$background with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:readColor\\(\\) has parameter \\$color with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Parameter \\#1 \\$hex of static method PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Color\\:\\:changeBrightness\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Parameter \\#1 \\$pValue of method PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\:\\:setSize\\(\\) expects float, string given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Cannot access property \\$r on SimpleXMLElement\\|null\\.$#"
count: 2
@ -4645,16 +4160,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/Xml.php
-
message: "#^Cannot call method setWidth\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xml.php
-
message: "#^Cannot call method setRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xml.php
-
message: "#^Parameter \\#2 \\$cmp_function of function uksort expects callable\\(mixed, mixed\\)\\: int, array\\('self', 'cellReverseSort'\\) given\\.$#"
count: 4
@ -4665,61 +4170,11 @@ parameters:
count: 4
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Parameter \\#2 \\$pPassword of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:protectCells\\(\\) expects string, array given\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Parameter \\#1 \\$index of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\:\\:setRowIndex\\(\\) expects int, string given\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Cannot call method getRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Cannot call method setRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Cannot call method getVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Cannot call method setVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Cannot call method getOutlineLevel\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Cannot call method setOutlineLevel\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Cannot call method getCollapsed\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Cannot call method setCollapsed\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Cannot call method setXfIndex\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Cell\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Parameter \\#1 \\$columnIndex of static method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Coordinate\\:\\:stringFromColumnIndex\\(\\) expects int, float\\|int given\\.$#"
count: 1
@ -6135,36 +5590,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Style/Style.php
-
message: "#^Cannot call method getXfIndex\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Style/Style.php
-
message: "#^Cannot call method setXfIndex\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Style/Style.php
-
message: "#^Cannot call method getXfIndex\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 3
path: src/PhpSpreadsheet/Style/Style.php
-
message: "#^Cannot call method setXfIndex\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Style/Style.php
-
message: "#^Cannot call method getXfIndex\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Cell\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Style/Style.php
-
message: "#^Cannot call method setXfIndex\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Cell\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Style/Style.php
-
message: "#^Result of && is always true\\.$#"
count: 1
@ -6255,11 +5680,6 @@ parameters:
count: 2
path: src/PhpSpreadsheet/Worksheet/AutoFilter.php
-
message: "#^Cannot call method setVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Worksheet/AutoFilter.php
-
message: "#^Cannot assign offset 'year' to array\\<string\\>\\|string\\.$#"
count: 1
@ -6535,11 +5955,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^Cannot call method setWidth\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^If condition is always true\\.$#"
count: 2
@ -6555,26 +5970,11 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^Cannot call method setValue\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Cell\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^Cannot call method setValueExplicit\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Cell\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^Parameter \\#2 \\$start of function substr expects int, int\\<0, max\\>\\|false given\\.$#"
count: 2
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^Parameter \\#1 \\$pRow of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:getRowDimension\\(\\) expects int, string given\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^Result of && is always true\\.$#"
count: 1
@ -7335,16 +6735,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
-
message: "#^Parameter \\#2 \\$height of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Worksheet\\:\\:writeRow\\(\\) expects int, float given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
-
message: "#^Parameter \\#4 \\$hidden of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Worksheet\\:\\:writeRow\\(\\) expects bool, string given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
-
message: "#^Cannot call method getHashCode\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null\\.$#"
count: 1
@ -7375,11 +6765,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
-
message: "#^Parameter \\#1 \\$hexadecimal_number of function hexdec expects string, array given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
-
message: "#^Parameter \\#1 \\$coordinates of static method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Coordinate\\:\\:indexesFromString\\(\\) expects string, string\\|null given\\.$#"
count: 1
@ -7480,26 +6865,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
-
message: "#^Parameter \\#1 \\$value of static method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\StringHelper\\:\\:UTF8toBIFF8UnicodeLong\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
-
message: "#^Parameter \\#1 \\$fillType of static method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Xf\\:\\:mapFillType\\(\\) expects string, string\\|null given\\.$#"
count: 2
path: src/PhpSpreadsheet/Writer/Xls/Xf.php
-
message: "#^Parameter \\#1 \\$hAlign of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Xf\\:\\:mapHAlign\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xls/Xf.php
-
message: "#^Parameter \\#1 \\$vAlign of static method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Xf\\:\\:mapVAlign\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xls/Xf.php
-
message: "#^Parameter \\#1 \\$textRotation of static method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Xf\\:\\:mapTextRotation\\(\\) expects int, int\\|null given\\.$#"
count: 1
@ -8010,11 +7375,6 @@ parameters:
count: 2
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, array given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, array\\<string\\>\\|string given\\.$#"
count: 2
@ -8025,31 +7385,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Cannot call method getCollapsed\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Cannot call method getOutlineLevel\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 3
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Cannot call method getRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 3
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Cannot call method getVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Cannot call method getXfIndex\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 3
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Parameter \\#2 \\$content of method XMLWriter\\:\\:writeElement\\(\\) expects string\\|null, int\\|string given\\.$#"
count: 1
@ -8070,21 +7405,6 @@ parameters:
count: 1
path: tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php
-
message: "#^Cannot call method setVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php
-
message: "#^Cannot call method setVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php
-
message: "#^Cannot call method setAutoSize\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Calculation/XlfnFunctionsTest.php
-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with arguments PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Cell, null and 'should get exact…' will always evaluate to false\\.$#"
count: 1
@ -8110,16 +7430,6 @@ parameters:
count: 1
path: tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php
-
message: "#^Cannot call method setWidth\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php
-
message: "#^Cannot call method getWidth\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheetTests\\\\Functional\\\\CommentsTest\\:\\:testComments\\(\\) has parameter \\$format with no typehint specified\\.$#"
count: 1
@ -8130,11 +7440,6 @@ parameters:
count: 2
path: tests/PhpSpreadsheetTests/Functional/ConditionalStopIfTrueTest.php
-
message: "#^Cannot call method setAutoSize\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Functional/ConditionalTextTest.php
-
message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#"
count: 1
@ -8195,26 +7500,6 @@ parameters:
count: 5
path: tests/PhpSpreadsheetTests/NamedRangeTest.php
-
message: "#^Cannot call method getVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericLoadTest.php
-
message: "#^Cannot call method getRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 2
path: tests/PhpSpreadsheetTests/Reader/Html/HtmlTagsTest.php
-
message: "#^Cannot call method getWidth\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 2
path: tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php
-
message: "#^Cannot call method getRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 2
path: tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php
-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
@ -8305,26 +7590,6 @@ parameters:
count: 1
path: tests/PhpSpreadsheetTests/Reader/Xlsx/ConditionalFormattingDataBarXlsxTest.php
-
message: "#^Cannot call method getRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Reader/XlsxTest.php
-
message: "#^Cannot call method getVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Reader/XlsxTest.php
-
message: "#^Cannot call method getWidth\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Reader/XlsxTest.php
-
message: "#^Cannot call method getVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Reader/XlsxTest.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheetTests\\\\Reader\\\\XlsxTest\\:\\:testStripsWhiteSpaceFromStyleString\\(\\) has parameter \\$string with no typehint specified\\.$#"
count: 1
@ -8480,21 +7745,6 @@ parameters:
count: 1
path: tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php
-
message: "#^Cannot call method setVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension\\|null\\.$#"
count: 2
path: tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php
-
message: "#^Cannot call method setVisible\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 3
path: tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php
-
message: "#^Cannot call method setRowHeight\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php
-
message: "#^Parameter \\#1 \\$options of static method PhpOffice\\\\PhpSpreadsheet\\\\Settings\\:\\:setLibXmlLoaderOptions\\(\\) expects int, null given\\.$#"
count: 1

View File

@ -38,7 +38,8 @@ $helper->write($spreadsheetFromCSV, __FILE__, ['Xlsx']);
$filenameCSV = $helper->getFilename(__FILE__, 'csv');
/** @var \PhpOffice\PhpSpreadsheet\Writer\Csv $writerCSV */
$writerCSV = new CsvWriter($spreadsheetFromCSV);
$writerCSV->setExcelCompatibility(true);
//$writerCSV->setExcelCompatibility(true);
$writerCSV->setUseBom(true); // because of non-ASCII chars
$callStartTime = microtime(true);
$writerCSV->save($filenameCSV);

View File

@ -30,6 +30,9 @@ class Calculation
const CALCULATION_REGEXP_CELLREF = '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?\b([a-z]{1,3})\$?(\d{1,7})(?![\w.])';
// Cell reference (with or without a sheet reference) ensuring absolute/relative
const CALCULATION_REGEXP_CELLREF_RELATIVE = '((([^\s\(,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?(\$?\b[a-z]{1,3})(\$?\d{1,7})(?![\w.])';
const CALCULATION_REGEXP_COLUMN_RANGE = '(((([^\s\(,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?(\$?[a-z]{1,3})):(?![.*])';
const CALCULATION_REGEXP_ROW_RANGE = '(((([^\s\(,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?(\$?[1-9][0-9]{0,6})):(?![.*])';
// Cell reference (with or without a sheet reference) ensuring absolute/relative
// Cell ranges ensuring absolute/relative
const CALCULATION_REGEXP_COLUMNRANGE_RELATIVE = '(\$?[a-z]{1,3}):(\$?[a-z]{1,3})';
const CALCULATION_REGEXP_ROWRANGE_RELATIVE = '(\$?\d{1,7}):(\$?\d{1,7})';
@ -243,22 +246,22 @@ class Calculation
],
'ACOS' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Acos::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Cosine::class, 'acos'],
'argumentCount' => '1',
],
'ACOSH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Acosh::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Cosine::class, 'acosh'],
'argumentCount' => '1',
],
'ACOT' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Acot::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Cotangent::class, 'acot'],
'argumentCount' => '1',
],
'ACOTH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Acoth::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Cotangent::class, 'acoth'],
'argumentCount' => '1',
],
'ADDRESS' => [
@ -303,27 +306,27 @@ class Calculation
],
'ASIN' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Asin::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Sine::class, 'asin'],
'argumentCount' => '1',
],
'ASINH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Asinh::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Sine::class, 'asinh'],
'argumentCount' => '1',
],
'ATAN' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Atan::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Tangent::class, 'atan'],
'argumentCount' => '1',
],
'ATAN2' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Atan2::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Tangent::class, 'atan2'],
'argumentCount' => '2',
],
'ATANH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Atanh::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Tangent::class, 'atanh'],
'argumentCount' => '1',
],
'AVEDEV' => [
@ -463,17 +466,17 @@ class Calculation
],
'CEILING' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Ceiling::class, 'evaluate'],
'functionCall' => [MathTrig\Ceiling::class, 'ceiling'],
'argumentCount' => '1-2', // 2 for Excel, 1-2 for Ods/Gnumeric
],
'CEILING.MATH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\CeilingMath::class, 'evaluate'],
'functionCall' => [MathTrig\Ceiling::class, 'math'],
'argumentCount' => '1-3',
],
'CEILING.PRECISE' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\CeilingPrecise::class, 'evaluate'],
'functionCall' => [MathTrig\Ceiling::class, 'precise'],
'argumentCount' => '1,2',
],
'CELL' => [
@ -528,7 +531,7 @@ class Calculation
],
'CHOOSE' => [
'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => [LookupRef::class, 'CHOOSE'],
'functionCall' => [LookupRef\Selection::class, 'CHOOSE'],
'argumentCount' => '2+',
],
'CLEAN' => [
@ -605,22 +608,22 @@ class Calculation
],
'COS' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Cos::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Cosine::class, 'cos'],
'argumentCount' => '1',
],
'COSH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Cosh::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Cosine::class, 'cosh'],
'argumentCount' => '1',
],
'COT' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Cot::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Cotangent::class, 'cot'],
'argumentCount' => '1',
],
'COTH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Coth::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Cotangent::class, 'coth'],
'argumentCount' => '1',
],
'COUNT' => [
@ -700,12 +703,12 @@ class Calculation
],
'CSC' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Csc::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Cosecant::class, 'csc'],
'argumentCount' => '1',
],
'CSCH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Csch::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Cosecant::class, 'csch'],
'argumentCount' => '1',
],
'CUBEKPIMEMBER' => [
@ -755,17 +758,17 @@ class Calculation
],
'DATE' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Datefunc::class, 'funcDate'],
'functionCall' => [DateTimeExcel\Date::class, 'fromYMD'],
'argumentCount' => '3',
],
'DATEDIF' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\DateDif::class, 'funcDateDif'],
'functionCall' => [DateTimeExcel\Difference::class, 'interval'],
'argumentCount' => '2,3',
],
'DATEVALUE' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\DateValue::class, 'funcDateValue'],
'functionCall' => [DateTimeExcel\DateValue::class, 'fromString'],
'argumentCount' => '1',
],
'DAVERAGE' => [
@ -775,22 +778,22 @@ class Calculation
],
'DAY' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Day::class, 'funcDay'],
'functionCall' => [DateTimeExcel\DateParts::class, 'day'],
'argumentCount' => '1',
],
'DAYS' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Days::class, 'funcDays'],
'functionCall' => [DateTimeExcel\Days::class, 'between'],
'argumentCount' => '2',
],
'DAYS360' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Days360::class, 'funcDays360'],
'functionCall' => [DateTimeExcel\Days360::class, 'between'],
'argumentCount' => '2,3',
],
'DB' => [
'category' => Category::CATEGORY_FINANCIAL,
'functionCall' => [Financial::class, 'DB'],
'functionCall' => [Financial\Depreciation::class, 'DB'],
'argumentCount' => '4,5',
],
'DBCS' => [
@ -810,7 +813,7 @@ class Calculation
],
'DDB' => [
'category' => Category::CATEGORY_FINANCIAL,
'functionCall' => [Financial::class, 'DDB'],
'functionCall' => [Financial\Depreciation::class, 'DDB'],
'argumentCount' => '4,5',
],
'DEC2BIN' => [
@ -835,7 +838,7 @@ class Calculation
],
'DEGREES' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Degrees::class, 'evaluate'],
'functionCall' => [MathTrig\Angle::class, 'toDegrees'],
'argumentCount' => '1',
],
'DELTA' => [
@ -845,7 +848,7 @@ class Calculation
],
'DEVSQ' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'DEVSQ'],
'functionCall' => [Statistical\Deviations::class, 'sumSquares'],
'argumentCount' => '1+',
],
'DGET' => [
@ -920,7 +923,7 @@ class Calculation
],
'EDATE' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\EDate::class, 'funcEDate'],
'functionCall' => [DateTimeExcel\Month::class, 'adjust'],
'argumentCount' => '2',
],
'EFFECT' => [
@ -930,12 +933,12 @@ class Calculation
],
'ENCODEURL' => [
'category' => Category::CATEGORY_WEB,
'functionCall' => [Functions::class, 'DUMMY'],
'functionCall' => [Web\Service::class, 'urlEncode'],
'argumentCount' => '1',
],
'EOMONTH' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\EoMonth::class, 'funcEoMonth'],
'functionCall' => [DateTimeExcel\Month::class, 'lastDay'],
'argumentCount' => '2',
],
'ERF' => [
@ -965,7 +968,7 @@ class Calculation
],
'EVEN' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Even::class, 'evaluate'],
'functionCall' => [MathTrig\Round::class, 'even'],
'argumentCount' => '1',
],
'EXACT' => [
@ -990,12 +993,12 @@ class Calculation
],
'FACT' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Fact::class, 'evaluate'],
'functionCall' => [MathTrig\Factorial::class, 'fact'],
'argumentCount' => '1',
],
'FACTDOUBLE' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\FactDouble::class, 'evaluate'],
'functionCall' => [MathTrig\Factorial::class, 'factDouble'],
'argumentCount' => '1',
],
'FALSE' => [
@ -1070,17 +1073,17 @@ class Calculation
],
'FLOOR' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Floor::class, 'evaluate'],
'functionCall' => [MathTrig\Floor::class, 'floor'],
'argumentCount' => '1-2', // Excel requries 2, Ods/Gnumeric 1-2
],
'FLOOR.MATH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\FloorMath::class, 'evaluate'],
'functionCall' => [MathTrig\Floor::class, 'math'],
'argumentCount' => '1-3',
],
'FLOOR.PRECISE' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\FloorPrecise::class, 'evaluate'],
'functionCall' => [MathTrig\Floor::class, 'precise'],
'argumentCount' => '1-2',
],
'FORECAST' => [
@ -1115,7 +1118,7 @@ class Calculation
],
'FORMULATEXT' => [
'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => [LookupRef::class, 'FORMULATEXT'],
'functionCall' => [LookupRef\Formula::class, 'text'],
'argumentCount' => '1',
'passCellReference' => true,
'passByReference' => [true],
@ -1182,7 +1185,7 @@ class Calculation
],
'GAUSS' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'GAUSS'],
'functionCall' => [Statistical\Distributions\StandardNormal::class, 'gauss'],
'argumentCount' => '1',
],
'GCD' => [
@ -1192,7 +1195,7 @@ class Calculation
],
'GEOMEAN' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'GEOMEAN'],
'functionCall' => [Statistical\Averages\Mean::class, 'geometric'],
'argumentCount' => '1+',
],
'GESTEP' => [
@ -1212,7 +1215,7 @@ class Calculation
],
'HARMEAN' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'HARMEAN'],
'functionCall' => [Statistical\Averages\Mean::class, 'harmonic'],
'argumentCount' => '1+',
],
'HEX2BIN' => [
@ -1237,12 +1240,12 @@ class Calculation
],
'HOUR' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Hour::class, 'funcHour'],
'functionCall' => [DateTimeExcel\TimeParts::class, 'hour'],
'argumentCount' => '1',
],
'HYPERLINK' => [
'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => [LookupRef::class, 'HYPERLINK'],
'functionCall' => [LookupRef\Hyperlink::class, 'set'],
'argumentCount' => '1,2',
'passCellReference' => true,
],
@ -1403,7 +1406,7 @@ class Calculation
],
'INDEX' => [
'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => [LookupRef::class, 'INDEX'],
'functionCall' => [LookupRef\Matrix::class, 'index'],
'argumentCount' => '1-4',
],
'INDIRECT' => [
@ -1501,7 +1504,7 @@ class Calculation
],
'ISOWEEKNUM' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\IsoWeekNum::class, 'funcIsoWeekNum'],
'functionCall' => [DateTimeExcel\Week::class, 'isoWeekNumber'],
'argumentCount' => '1',
],
'ISPMT' => [
@ -1526,12 +1529,12 @@ class Calculation
],
'KURT' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'KURT'],
'functionCall' => [Statistical\Deviations::class, 'kurtosis'],
'argumentCount' => '1+',
],
'LARGE' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'LARGE'],
'functionCall' => [Statistical\Size::class, 'large'],
'argumentCount' => '2',
],
'LCM' => [
@ -1621,12 +1624,12 @@ class Calculation
],
'MAX' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical\Maximum::class, 'MAX'],
'functionCall' => [Statistical\Maximum::class, 'max'],
'argumentCount' => '1+',
],
'MAXA' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical\Maximum::class, 'MAXA'],
'functionCall' => [Statistical\Maximum::class, 'maxA'],
'argumentCount' => '1+',
],
'MAXIFS' => [
@ -1666,12 +1669,12 @@ class Calculation
],
'MIN' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical\Minimum::class, 'MIN'],
'functionCall' => [Statistical\Minimum::class, 'min'],
'argumentCount' => '1+',
],
'MINA' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical\Minimum::class, 'MINA'],
'functionCall' => [Statistical\Minimum::class, 'minA'],
'argumentCount' => '1+',
],
'MINIFS' => [
@ -1681,7 +1684,7 @@ class Calculation
],
'MINUTE' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Minute::class, 'funcMinute'],
'functionCall' => [DateTimeExcel\TimeParts::class, 'minute'],
'argumentCount' => '1',
],
'MINVERSE' => [
@ -1701,7 +1704,7 @@ class Calculation
],
'MOD' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Mod::class, 'evaluate'],
'functionCall' => [MathTrig\Operations::class, 'mod'],
'argumentCount' => '2',
],
'MODE' => [
@ -1721,17 +1724,17 @@ class Calculation
],
'MONTH' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Month::class, 'funcMonth'],
'functionCall' => [DateTimeExcel\DateParts::class, 'month'],
'argumentCount' => '1',
],
'MROUND' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Mround::class, 'evaluate'],
'functionCall' => [MathTrig\Round::class, 'multiple'],
'argumentCount' => '2',
],
'MULTINOMIAL' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Multinomial::class, 'evaluate'],
'functionCall' => [MathTrig\Factorial::class, 'multinomial'],
'argumentCount' => '1+',
],
'MUNIT' => [
@ -1761,7 +1764,7 @@ class Calculation
],
'NETWORKDAYS' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\NetworkDays::class, 'funcNetworkDays'],
'functionCall' => [DateTimeExcel\NetworkDays::class, 'count'],
'argumentCount' => '2-3',
],
'NETWORKDAYS.INTL' => [
@ -1821,7 +1824,7 @@ class Calculation
],
'NOW' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Now::class, 'funcNow'],
'functionCall' => [DateTimeExcel\Current::class, 'now'],
'argumentCount' => '0',
],
'NPER' => [
@ -1856,7 +1859,7 @@ class Calculation
],
'ODD' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Odd::class, 'evaluate'],
'functionCall' => [MathTrig\Round::class, 'odd'],
'argumentCount' => '1',
],
'ODDFPRICE' => [
@ -1973,7 +1976,7 @@ class Calculation
],
'POWER' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Power::class, 'evaluate'],
'functionCall' => [MathTrig\Operations::class, 'power'],
'argumentCount' => '2',
],
'PPMT' => [
@ -2003,7 +2006,7 @@ class Calculation
],
'PRODUCT' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Product::class, 'evaluate'],
'functionCall' => [MathTrig\Operations::class, 'product'],
'argumentCount' => '1+',
],
'PROPER' => [
@ -2033,17 +2036,17 @@ class Calculation
],
'QUOTIENT' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Quotient::class, 'evaluate'],
'functionCall' => [MathTrig\Operations::class, 'quotient'],
'argumentCount' => '2',
],
'RADIANS' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Radians::class, 'evaluate'],
'functionCall' => [MathTrig\Angle::class, 'toRadians'],
'argumentCount' => '1',
],
'RAND' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Random::class, 'randNoArgs'],
'functionCall' => [MathTrig\Random::class, 'rand'],
'argumentCount' => '0',
],
'RANDARRAY' => [
@ -2068,7 +2071,7 @@ class Calculation
],
'RANK.EQ' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'RANK'],
'functionCall' => [Statistical\Percentiles::class, 'RANK'],
'argumentCount' => '2,3',
],
'RATE' => [
@ -2113,17 +2116,17 @@ class Calculation
],
'ROUND' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Round::class, 'evaluate'],
'functionCall' => [MathTrig\Round::class, 'round'],
'argumentCount' => '2',
],
'ROUNDDOWN' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\RoundDown::class, 'evaluate'],
'functionCall' => [MathTrig\Round::class, 'down'],
'argumentCount' => '2',
],
'ROUNDUP' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\RoundUp::class, 'evaluate'],
'functionCall' => [MathTrig\Round::class, 'up'],
'argumentCount' => '2',
],
'ROW' => [
@ -2165,17 +2168,17 @@ class Calculation
],
'SEC' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Sec::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Secant::class, 'sec'],
'argumentCount' => '1',
],
'SECH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Sech::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Secant::class, 'sech'],
'argumentCount' => '1',
],
'SECOND' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Second::class, 'funcSecond'],
'functionCall' => [DateTimeExcel\TimeParts::class, 'second'],
'argumentCount' => '1',
],
'SEQUENCE' => [
@ -2205,17 +2208,17 @@ class Calculation
],
'SIN' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Sin::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Sine::class, 'sin'],
'argumentCount' => '1',
],
'SINH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Sinh::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Sine::class, 'sinh'],
'argumentCount' => '1',
],
'SKEW' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'SKEW'],
'functionCall' => [Statistical\Deviations::class, 'skew'],
'argumentCount' => '1+',
],
'SKEW.P' => [
@ -2235,7 +2238,7 @@ class Calculation
],
'SMALL' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'SMALL'],
'functionCall' => [Statistical\Size::class, 'small'],
'argumentCount' => '2',
],
'SORT' => [
@ -2250,17 +2253,17 @@ class Calculation
],
'SQRT' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Sqrt::class, 'evaluate'],
'functionCall' => [MathTrig\Sqrt::class, 'sqrt'],
'argumentCount' => '1',
],
'SQRTPI' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\SqrtPi::class, 'evaluate'],
'functionCall' => [MathTrig\Sqrt::class, 'pi'],
'argumentCount' => '1',
],
'STANDARDIZE' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'STANDARDIZE'],
'functionCall' => [Statistical\Standardize::class, 'execute'],
'argumentCount' => '3',
],
'STDEV' => [
@ -2285,12 +2288,12 @@ class Calculation
],
'STDEVP' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'STDEVP'],
'functionCall' => [Statistical\StandardDeviations::class, 'STDEVP'],
'argumentCount' => '1+',
],
'STDEVPA' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'STDEVPA'],
'functionCall' => [Statistical\StandardDeviations::class, 'STDEVPA'],
'argumentCount' => '1+',
],
'STEYX' => [
@ -2311,7 +2314,7 @@ class Calculation
],
'SUM' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Sum::class, 'funcSumNoStrings'],
'functionCall' => [MathTrig\Sum::class, 'sumErroringStrings'],
'argumentCount' => '1+',
],
'SUMIF' => [
@ -2326,7 +2329,7 @@ class Calculation
],
'SUMPRODUCT' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\SumProduct::class, 'evaluate'],
'functionCall' => [MathTrig\Sum::class, 'product'],
'argumentCount' => '1+',
],
'SUMSQ' => [
@ -2366,12 +2369,12 @@ class Calculation
],
'TAN' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Tan::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Tangent::class, 'tan'],
'argumentCount' => '1',
],
'TANH' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Tanh::class, 'evaluate'],
'functionCall' => [MathTrig\Trig\Tangent::class, 'tanh'],
'argumentCount' => '1',
],
'TBILLEQ' => [
@ -2416,17 +2419,17 @@ class Calculation
],
'TEXTJOIN' => [
'category' => Category::CATEGORY_TEXT_AND_DATA,
'functionCall' => [TextData::class, 'TEXTJOIN'],
'functionCall' => [TextData\Concatenate::class, 'TEXTJOIN'],
'argumentCount' => '3+',
],
'TIME' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Time::class, 'funcTime'],
'functionCall' => [DateTimeExcel\Time::class, 'fromHMS'],
'argumentCount' => '3',
],
'TIMEVALUE' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\TimeValue::class, 'funcTimeValue'],
'functionCall' => [DateTimeExcel\TimeValue::class, 'fromString'],
'argumentCount' => '1',
],
'TINV' => [
@ -2446,7 +2449,7 @@ class Calculation
],
'TODAY' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Today::class, 'funcToday'],
'functionCall' => [DateTimeExcel\Current::class, 'today'],
'argumentCount' => '0',
],
'TRANSPOSE' => [
@ -2466,7 +2469,7 @@ class Calculation
],
'TRIMMEAN' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'TRIMMEAN'],
'functionCall' => [Statistical\Averages\Mean::class, 'trim'],
'argumentCount' => '2',
],
'TRUE' => [
@ -2566,17 +2569,17 @@ class Calculation
],
'WEBSERVICE' => [
'category' => Category::CATEGORY_WEB,
'functionCall' => [Web::class, 'WEBSERVICE'],
'functionCall' => [Web\Service::class, 'webService'],
'argumentCount' => '1',
],
'WEEKDAY' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\WeekDay::class, 'funcWeekDay'],
'functionCall' => [DateTimeExcel\Week::class, 'day'],
'argumentCount' => '1,2',
],
'WEEKNUM' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\WeekNum::class, 'funcWeekNum'],
'functionCall' => [DateTimeExcel\Week::class, 'number'],
'argumentCount' => '1,2',
],
'WEIBULL' => [
@ -2591,7 +2594,7 @@ class Calculation
],
'WORKDAY' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\WorkDay::class, 'funcWorkDay'],
'functionCall' => [DateTimeExcel\WorkDay::class, 'date'],
'argumentCount' => '2-3',
],
'WORKDAY.INTL' => [
@ -2601,7 +2604,7 @@ class Calculation
],
'XIRR' => [
'category' => Category::CATEGORY_FINANCIAL,
'functionCall' => [Financial::class, 'XIRR'],
'functionCall' => [Financial\CashFlow\Variable\NonPeriodic::class, 'rate'],
'argumentCount' => '2,3',
],
'XLOOKUP' => [
@ -2611,7 +2614,7 @@ class Calculation
],
'XNPV' => [
'category' => Category::CATEGORY_FINANCIAL,
'functionCall' => [Financial::class, 'XNPV'],
'functionCall' => [Financial\CashFlow\Variable\NonPeriodic::class, 'presentValue'],
'argumentCount' => '3',
],
'XMATCH' => [
@ -2626,12 +2629,12 @@ class Calculation
],
'YEAR' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\Year::class, 'funcYear'],
'functionCall' => [DateTimeExcel\DateParts::class, 'year'],
'argumentCount' => '1',
],
'YEARFRAC' => [
'category' => Category::CATEGORY_DATE_AND_TIME,
'functionCall' => [DateTimeExcel\YearFrac::class, 'funcYearFrac'],
'functionCall' => [DateTimeExcel\YearFrac::class, 'fraction'],
'argumentCount' => '2,3',
],
'YIELD' => [
@ -3798,6 +3801,8 @@ class Calculation
$regexpMatchString = '/^(' . self::CALCULATION_REGEXP_FUNCTION .
'|' . self::CALCULATION_REGEXP_CELLREF .
'|' . self::CALCULATION_REGEXP_COLUMN_RANGE .
'|' . self::CALCULATION_REGEXP_ROW_RANGE .
'|' . self::CALCULATION_REGEXP_NUMBER .
'|' . self::CALCULATION_REGEXP_STRING .
'|' . self::CALCULATION_REGEXP_OPENBRACE .
@ -3866,7 +3871,8 @@ class Calculation
$opCharacter .= $formula[++$index];
}
// Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand
$isOperandOrFunction = preg_match($regexpMatchString, substr($formula, $index), $match);
$isOperandOrFunction = (bool) preg_match($regexpMatchString, substr($formula, $index), $match);
if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus?
// Put a negation on the stack
$stack->push('Unary Operator', '~', null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);
@ -4038,6 +4044,7 @@ class Calculation
$expectingOperand = false;
$val = $match[1];
$length = strlen($val);
if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $val, $matches)) {
$val = preg_replace('/\s/u', '', $val);
if (isset(self::$phpSpreadsheetFunctions[strtoupper($matches[1])]) || isset(self::$controlFunctions[strtoupper($matches[1])])) { // it's a function
@ -4074,7 +4081,7 @@ class Calculation
// Should only be applied to the actual cell column, not the worksheet name
// If the last entry on the stack was a : operator, then we have a cell range reference
$testPrevOp = $stack->last(1);
if ($testPrevOp !== null && $testPrevOp['value'] == ':') {
if ($testPrevOp !== null && $testPrevOp['value'] === ':') {
// If we have a worksheet reference, then we're playing with a 3D reference
if ($matches[2] == '') {
// Otherwise, we 'inherit' the worksheet reference from the start cell reference
@ -4091,62 +4098,57 @@ class Calculation
return $this->raiseFormulaError('3D Range references are not yet supported');
}
}
} elseif (strpos($val, '!') === false && $pCellParent !== null) {
$worksheet = $pCellParent->getTitle();
$val = "'{$worksheet}'!{$val}";
}
$outputItem = $stack->getStackItem('Cell Reference', $val, $val, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);
$output[] = $outputItem;
} else { // it's a variable, constant, string, number or boolean
$localeConstant = false;
$stackItemType = 'Value';
$stackItemReference = null;
// If the last entry on the stack was a : operator, then we may have a row or column range reference
$testPrevOp = $stack->last(1);
if ($testPrevOp !== null && $testPrevOp['value'] === ':') {
$stackItemType = 'Cell Reference';
$startRowColRef = $output[count($output) - 1]['value'];
[$rangeWS1, $startRowColRef] = Worksheet::extractSheetTitle($startRowColRef, true);
$rangeSheetRef = $rangeWS1;
if ($rangeWS1 != '') {
if ($rangeWS1 !== '') {
$rangeWS1 .= '!';
}
$rangeSheetRef = trim($rangeSheetRef, "'");
[$rangeWS2, $val] = Worksheet::extractSheetTitle($val, true);
if ($rangeWS2 != '') {
if ($rangeWS2 !== '') {
$rangeWS2 .= '!';
} else {
$rangeWS2 = $rangeWS1;
}
$refSheet = $pCellParent;
if ($pCellParent !== null && $rangeSheetRef !== $pCellParent->getTitle()) {
if ($pCellParent !== null && $rangeSheetRef !== '' && $rangeSheetRef !== $pCellParent->getTitle()) {
$refSheet = $pCellParent->getParent()->getSheetByName($rangeSheetRef);
}
if (
(is_int($startRowColRef)) && (ctype_digit($val)) &&
($startRowColRef <= 1048576) && ($val <= 1048576)
) {
// Row range
$endRowColRef = ($refSheet !== null) ? $refSheet->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007
$output[count($output) - 1]['value'] = $rangeWS1 . 'A' . $startRowColRef;
$val = $rangeWS2 . $endRowColRef . $val;
} elseif (
(ctype_alpha($startRowColRef)) && (ctype_alpha($val)) &&
(strlen($startRowColRef) <= 3) && (strlen($val) <= 3)
) {
// Column range
$endRowColRef = ($refSheet !== null) ? $refSheet->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007
$output[count($output) - 1]['value'] = $rangeWS1 . strtoupper($startRowColRef) . '1';
$val = $rangeWS2 . $val . $endRowColRef;
}
}
$localeConstant = false;
$stackItemType = 'Value';
$stackItemReference = null;
if ($opCharacter == self::FORMULA_STRING_QUOTE) {
if (ctype_digit($val) && $val <= 1048576) {
// Row range
$stackItemType = 'Row Reference';
$endRowColRef = ($refSheet !== null) ? $refSheet->getHighestDataColumn($val) : 'XFD'; // Max 16,384 columns for Excel2007
$val = "{$rangeWS2}{$endRowColRef}{$val}";
} elseif (ctype_alpha($val) && strlen($val) <= 3) {
// Column range
$stackItemType = 'Column Reference';
$endRowColRef = ($refSheet !== null) ? $refSheet->getHighestDataRow($val) : 1048576; // Max 1,048,576 rows for Excel2007
$val = "{$rangeWS2}{$val}{$endRowColRef}";
}
$stackItemReference = $val;
} elseif ($opCharacter == self::FORMULA_STRING_QUOTE) {
// UnEscape any quotes within the string
$val = self::wrapResult(str_replace('""', self::FORMULA_STRING_QUOTE, self::unwrapResult($val)));
} elseif (is_numeric($val)) {
if ((strpos($val, '.') !== false) || (stripos($val, 'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
$val = (float) $val;
} else {
$val = (int) $val;
}
} elseif (isset(self::$excelConstants[trim(strtoupper($val))])) {
$stackItemType = 'Constant';
$excelConstant = trim(strtoupper($val));
@ -4154,10 +4156,41 @@ class Calculation
} elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$localeBoolean)) !== false) {
$stackItemType = 'Constant';
$val = self::$excelConstants[$localeConstant];
} elseif (
preg_match('/^' . self::CALCULATION_REGEXP_ROW_RANGE . '/miu', substr($formula, $index), $rowRangeReference)
) {
$val = $rowRangeReference[1];
$length = strlen($rowRangeReference[1]);
$stackItemType = 'Row Reference';
$column = 'A';
if (($testPrevOp !== null && $testPrevOp['value'] === ':') && $pCellParent !== null) {
$column = $pCellParent->getHighestDataColumn($val);
}
$val = "{$rowRangeReference[2]}{$column}{$rowRangeReference[7]}";
$stackItemReference = $val;
} elseif (
preg_match('/^' . self::CALCULATION_REGEXP_COLUMN_RANGE . '/miu', substr($formula, $index), $columnRangeReference)
) {
$val = $columnRangeReference[1];
$length = strlen($val);
$stackItemType = 'Column Reference';
$row = '1';
if (($testPrevOp !== null && $testPrevOp['value'] === ':') && $pCellParent !== null) {
$row = $pCellParent->getHighestDataRow($val);
}
$val = "{$val}{$row}";
$stackItemReference = $val;
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_DEFINEDNAME . '.*/miu', $val, $match)) {
$stackItemType = 'Defined Name';
$stackItemReference = $val;
} elseif (is_numeric($val)) {
if ((strpos($val, '.') !== false) || (stripos($val, 'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
$val = (float) $val;
} else {
$val = (int) $val;
}
}
$details = $stack->getStackItem($stackItemType, $val, $stackItemReference, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);
if ($localeConstant) {
$details['localeValue'] = $localeConstant;
@ -4431,6 +4464,7 @@ class Calculation
} else {
return $this->raiseFormulaError('Unable to access Cell Reference');
}
$stack->push('Cell Reference', $cellValue, $cellRef);
} else {
$stack->push('Error', Functions::REF(), null);
@ -4564,6 +4598,7 @@ class Calculation
}
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $token, $matches)) {
$cellRef = null;
if (isset($matches[8])) {
if ($pCell === null) {
// We can't access the range, so return a REF error
@ -4596,7 +4631,7 @@ class Calculation
}
} else {
if ($pCell === null) {
// We can't access the cell, so return a REF error
// We can't access the cell, so return a REF error
$cellValue = Functions::REF();
} else {
$cellRef = $matches[6] . $matches[7];
@ -4613,6 +4648,7 @@ class Calculation
$cellValue = $this->extractCellRange($cellRef, $this->spreadsheet->getSheetByName($matches[2]), false);
$pCell->attach($pCellParent);
} else {
$cellRef = ($cellSheet !== null) ? "{$matches[2]}!{$cellRef}" : $cellRef;
$cellValue = null;
}
} else {
@ -4631,7 +4667,8 @@ class Calculation
}
}
}
$stack->push('Value', $cellValue, $cellRef);
$stack->push('Cell Value', $cellValue, $cellRef);
if (isset($storeKey)) {
$branchStore[$storeKey] = $cellValue;
}
@ -5116,6 +5153,7 @@ class Calculation
if ($pSheet !== null) {
$pSheetName = $pSheet->getTitle();
if (strpos($pRange, '!') !== false) {
[$pSheetName, $pRange] = Worksheet::extractSheetTitle($pRange, true);
$pSheet = $this->spreadsheet->getSheetByName($pSheetName);

View File

@ -17,7 +17,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DAverage class instead
* @see Database\DAverage::evaluate()
* Use the evaluate() method in the Database\DAverage class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -52,7 +53,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DCount class instead
* @see Database\DCount::evaluate()
* Use the evaluate() method in the Database\DCount class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -89,7 +91,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DCountA class instead
* @see Database\DCountA::evaluate()
* Use the evaluate() method in the Database\DCountA class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -124,7 +127,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DGet class instead
* @see Database\DGet::evaluate()
* Use the evaluate() method in the Database\DGet class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -159,7 +163,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DMax class instead
* @see Database\DMax::evaluate()
* Use the evaluate() method in the Database\DMax class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -194,7 +199,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DMin class instead
* @see Database\DMin::evaluate()
* Use the evaluate() method in the Database\DMin class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -228,7 +234,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DProduct class instead
* @see Database\DProduct::evaluate()
* Use the evaluate() method in the Database\DProduct class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -263,7 +270,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DStDev class instead
* @see Database\DStDev::evaluate()
* Use the evaluate() method in the Database\DStDev class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -298,7 +306,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DStDevP class instead
* @see Database\DStDevP::evaluate()
* Use the evaluate() method in the Database\DStDevP class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -332,7 +341,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DSum class instead
* @see Database\DSum::evaluate()
* Use the evaluate() method in the Database\DSum class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -367,7 +377,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DVar class instead
* @see Database\DVar::evaluate()
* Use the evaluate() method in the Database\DVar class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
@ -402,7 +413,8 @@ class Database
*
* @Deprecated 1.17.0
*
* @see Use the evaluate() method in the Database\DVarP class instead
* @see Database\DVarP::evaluate()
* Use the evaluate() method in the Database\DVarP class instead
*
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related

View File

@ -39,7 +39,7 @@ class DMax extends DatabaseAbstract
return null;
}
return Maximum::MAX(
return Maximum::max(
self::getFilteredColumn($database, $field, $criteria)
);
}

View File

@ -39,7 +39,7 @@ class DMin extends DatabaseAbstract
return null;
}
return Minimum::MIN(
return Minimum::min(
self::getFilteredColumn($database, $field, $criteria)
);
}

View File

@ -38,7 +38,7 @@ class DProduct extends DatabaseAbstract
return null;
}
return MathTrig\Product::evaluate(
return MathTrig\Operations::product(
self::getFilteredColumn($database, $field, $criteria)
);
}

View File

@ -38,7 +38,7 @@ class DSum extends DatabaseAbstract
return null;
}
return MathTrig\Sum::funcSum(
return MathTrig\Sum::sumIgnoringStrings(
self::getFilteredColumn($database, $field, $criteria)
);
}

View File

@ -4,12 +4,18 @@ namespace PhpOffice\PhpSpreadsheet\Calculation;
use DateTimeInterface;
/**
* @deprecated 1.18.0
*/
class DateTime
{
/**
* Identify if a year is a leap year or not.
*
* @Deprecated 2.0.0 Use the method isLeapYear in the DateTimeExcel\Helpers class instead
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Helpers::isLeapYear()
* Use the isLeapYear method in the DateTimeExcel\Helpers class instead
*
* @param int|string $year The year to test
*
@ -23,7 +29,10 @@ class DateTime
/**
* getDateValue.
*
* @Deprecated 2.0.0 Use the method getDateValue in the DateTimeExcel\Helpers class instead
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Helpers::getDateValue()
* Use the getDateValue method in the DateTimeExcel\Helpers class instead
*
* @param mixed $dateValue
*
@ -49,17 +58,20 @@ class DateTime
* NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
* and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
*
* @Deprecated 2.0.0 Use the funcNow method in the DateTimeExcel\Now class instead
*
* Excel Function:
* NOW()
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Current::now()
* Use the now method in the DateTimeExcel\Current class instead
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATETIMENOW()
{
return DateTimeExcel\Now::funcNow();
return DateTimeExcel\Current::now();
}
/**
@ -73,17 +85,20 @@ class DateTime
* NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
* and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
*
* @Deprecated 2.0.0 Use the funcToday method in the DateTimeExcel\Today class instead
*
* Excel Function:
* TODAY()
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Current::today()
* Use the today method in the DateTimeExcel\Current class instead
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATENOW()
{
return DateTimeExcel\Today::funcToday();
return DateTimeExcel\Current::today();
}
/**
@ -94,11 +109,15 @@ class DateTime
* NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
* format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
*
* @Deprecated 2.0.0 Use the funcDate method in the DateTimeExcel\Date class instead
*
* Excel Function:
* DATE(year,month,day)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Date::fromYMD()
* Use the fromYMD method in the DateTimeExcel\Date class instead
*
* PhpSpreadsheet is a lot more forgiving than MS Excel when passing non numeric values to this function.
* A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted,
* as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language.
@ -139,7 +158,7 @@ class DateTime
*/
public static function DATE($year = 0, $month = 1, $day = 1)
{
return DateTimeExcel\Datefunc::funcDate($year, $month, $day);
return DateTimeExcel\Date::fromYMD($year, $month, $day);
}
/**
@ -150,11 +169,14 @@ class DateTime
* NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time
* format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
*
* @Deprecated 2.0.0 Use the funcTime method in the DateTimeExcel\Time class instead
*
* Excel Function:
* TIME(hour,minute,second)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Time::fromHMS()
* Use the fromHMS method in the DateTimeExcel\Time class instead
*
* @param int $hour A number from 0 (zero) to 32767 representing the hour.
* Any value greater than 23 will be divided by 24 and the remainder
* will be treated as the hour value. For example, TIME(27,0,0) =
@ -172,7 +194,7 @@ class DateTime
*/
public static function TIME($hour = 0, $minute = 0, $second = 0)
{
return DateTimeExcel\Time::funcTime($hour, $minute, $second);
return DateTimeExcel\Time::fromHMS($hour, $minute, $second);
}
/**
@ -185,11 +207,14 @@ class DateTime
* NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
* format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
*
* @Deprecated 2.0.0 Use the funcDateValue method in the DateTimeExcel\DateValue class instead
*
* Excel Function:
* DATEVALUE(dateValue)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\DateValue::fromString()
* Use the fromString method in the DateTimeExcel\DateValue class instead
*
* @param string $dateValue Text that represents a date in a Microsoft Excel date format.
* For example, "1/30/2008" or "30-Jan-2008" are text strings within
* quotation marks that represent dates. Using the default date
@ -204,7 +229,7 @@ class DateTime
*/
public static function DATEVALUE($dateValue)
{
return DateTimeExcel\DateValue::funcDateValue($dateValue);
return DateTimeExcel\DateValue::fromString($dateValue);
}
/**
@ -217,11 +242,14 @@ class DateTime
* NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time
* format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
*
* @Deprecated 2.0.0 Use the funcTimeValue method in the DateTimeExcel\TimeValue class instead
*
* Excel Function:
* TIMEVALUE(timeValue)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\TimeValue::fromString()
* Use the fromString method in the DateTimeExcel\TimeValue class instead
*
* @param string $timeValue A text string that represents a time in any one of the Microsoft
* Excel time formats; for example, "6:45 PM" and "18:45" text strings
* within quotation marks that represent time.
@ -232,13 +260,19 @@ class DateTime
*/
public static function TIMEVALUE($timeValue)
{
return DateTimeExcel\TimeValue::funcTimeValue($timeValue);
return DateTimeExcel\TimeValue::fromString($timeValue);
}
/**
* DATEDIF.
*
* @Deprecated 2.0.0 Use the funcDateDif method in the DateTimeExcel\DateDif class instead
* Excel Function:
* DATEDIF(startdate, enddate, unit)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Difference::interval()
* Use the interval method in the DateTimeExcel\Difference class instead
*
* @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object
* or a standard date string
@ -250,7 +284,7 @@ class DateTime
*/
public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D')
{
return DateTimeExcel\DateDif::funcDateDif($startDate, $endDate, $unit);
return DateTimeExcel\Difference::interval($startDate, $endDate, $unit);
}
/**
@ -258,11 +292,14 @@ class DateTime
*
* Returns the number of days between two dates
*
* @Deprecated 2.0.0 Use the funcDays method in the DateTimeExcel\Days class instead
*
* Excel Function:
* DAYS(endDate, startDate)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Days::between()
* Use the between method in the DateTimeExcel\Days class instead
*
* @param DateTimeInterface|float|int|string $endDate Excel date serial value (float),
* PHP date timestamp (integer), PHP DateTime object, or a standard date string
* @param DateTimeInterface|float|int|string $startDate Excel date serial value (float),
@ -272,7 +309,7 @@ class DateTime
*/
public static function DAYS($endDate = 0, $startDate = 0)
{
return DateTimeExcel\Days::funcDays($endDate, $startDate);
return DateTimeExcel\Days::between($endDate, $startDate);
}
/**
@ -282,11 +319,14 @@ class DateTime
* which is used in some accounting calculations. Use this function to help compute payments if
* your accounting system is based on twelve 30-day months.
*
* @Deprecated 2.0.0 Use the funcDays360 method in the DateTimeExcel\Days360 class instead
*
* Excel Function:
* DAYS360(startDate,endDate[,method])
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Days360::between()
* Use the between method in the DateTimeExcel\Days360 class instead
*
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
@ -307,7 +347,7 @@ class DateTime
*/
public static function DAYS360($startDate = 0, $endDate = 0, $method = false)
{
return DateTimeExcel\Days360::funcDays360($startDate, $endDate, $method);
return DateTimeExcel\Days360::between($startDate, $endDate, $method);
}
/**
@ -318,10 +358,14 @@ class DateTime
* Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or
* obligations to assign to a specific term.
*
* @Deprecated 2.0.0 Use the funcYearFrac method in the DateTimeExcel\YearFrac class instead
*
* Excel Function:
* YEARFRAC(startDate,endDate[,method])
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\YearFrac::fraction()
* Use the fraction method in the DateTimeExcel\YearFrac class instead
*
* See https://lists.oasis-open.org/archives/office-formula/200806/msg00039.html
* for description of algorithm used in Excel
*
@ -340,7 +384,7 @@ class DateTime
*/
public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0)
{
return DateTimeExcel\YearFrac::funcYearFrac($startDate, $endDate, $method);
return DateTimeExcel\YearFrac::fraction($startDate, $endDate, $method);
}
/**
@ -351,21 +395,25 @@ class DateTime
* Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days
* worked during a specific term.
*
* @Deprecated 2.0.0 Use the funcNetworkDays method in the DateTimeExcel\NetworkDays class instead
*
* Excel Function:
* NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]])
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\NetworkDays::count()
* Use the count method in the DateTimeExcel\NetworkDays class instead
*
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param mixed $dateArgs
*
* @return int|string Interval between the dates
*/
public static function NETWORKDAYS($startDate, $endDate, ...$dateArgs)
{
return DateTimeExcel\NetworkDays::funcNetworkDays($startDate, $endDate, ...$dateArgs);
return DateTimeExcel\NetworkDays::count($startDate, $endDate, ...$dateArgs);
}
/**
@ -376,23 +424,27 @@ class DateTime
* Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected
* delivery times, or the number of days of work performed.
*
* @Deprecated 2.0.0 Use the funcWorkDay method in the DateTimeExcel\WorkDay class instead
*
* Excel Function:
* WORKDAY(startDate,endDays[,holidays[,holiday[,...]]])
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\WorkDay::date()
* Use the date method in the DateTimeExcel\WorkDay class instead
*
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $endDays The number of nonweekend and nonholiday days before or after
* startDate. A positive value for days yields a future date; a
* negative value yields a past date.
* @param mixed $dateArgs
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function WORKDAY($startDate, $endDays, ...$dateArgs)
{
return DateTimeExcel\WorkDay::funcWorkDay($startDate, $endDays, ...$dateArgs);
return DateTimeExcel\WorkDay::date($startDate, $endDays, ...$dateArgs);
}
/**
@ -401,11 +453,14 @@ class DateTime
* Returns the day of the month, for a specified date. The day is given as an integer
* ranging from 1 to 31.
*
* @Deprecated 2.0.0 Use the funcDay method in the DateTimeExcel\Day class instead
*
* Excel Function:
* DAY(dateValue)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\DateParts::day()
* Use the day method in the DateTimeExcel\DateParts class instead
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
@ -413,7 +468,7 @@ class DateTime
*/
public static function DAYOFMONTH($dateValue = 1)
{
return DateTimeExcel\Day::funcDay($dateValue);
return DateTimeExcel\DateParts::day($dateValue);
}
/**
@ -422,11 +477,14 @@ class DateTime
* Returns the day of the week for a specified date. The day is given as an integer
* ranging from 0 to 7 (dependent on the requested style).
*
* @Deprecated 2.0.0 Use the funcWeekDay method in the DateTimeExcel\WeekDay class instead
*
* Excel Function:
* WEEKDAY(dateValue[,style])
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Week::day()
* Use the day method in the DateTimeExcel\Week class instead
*
* @param float|int|string $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $style A number that determines the type of return value
@ -438,13 +496,13 @@ class DateTime
*/
public static function WEEKDAY($dateValue = 1, $style = 1)
{
return DateTimeExcel\WeekDay::funcWeekDay($dateValue, $style);
return DateTimeExcel\Week::day($dateValue, $style);
}
/**
* STARTWEEK_SUNDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\STARTWEEK_SUNDAY instead
*/
@ -453,7 +511,7 @@ class DateTime
/**
* STARTWEEK_MONDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\STARTWEEK_MONDAY instead
*/
@ -462,7 +520,7 @@ class DateTime
/**
* STARTWEEK_MONDAY_ALT.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\STARTWEEK_MONDAY_ALT instead
*/
@ -471,7 +529,7 @@ class DateTime
/**
* STARTWEEK_TUESDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\STARTWEEK_TUESDAY instead
*/
@ -480,7 +538,7 @@ class DateTime
/**
* STARTWEEK_WEDNESDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\STARTWEEK_WEDNESDAY instead
*/
@ -489,7 +547,7 @@ class DateTime
/**
* STARTWEEK_THURSDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\STARTWEEK_THURSDAY instead
*/
@ -498,7 +556,7 @@ class DateTime
/**
* STARTWEEK_FRIDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\STARTWEEK_FRIDAY instead
*/
@ -507,7 +565,7 @@ class DateTime
/**
* STARTWEEK_SATURDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\STARTWEEK_SATURDAY instead
*/
@ -516,7 +574,7 @@ class DateTime
/**
* STARTWEEK_SUNDAY_ALT.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\STARTWEEK_SUNDAY_ALT instead
*/
@ -525,7 +583,7 @@ class DateTime
/**
* DOW_SUNDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\DOW_SUNDAY instead
*/
@ -534,7 +592,7 @@ class DateTime
/**
* DOW_MONDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\DOW_MONDAY instead
*/
@ -543,7 +601,7 @@ class DateTime
/**
* DOW_TUESDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\DOW_TUESDAY instead
*/
@ -552,7 +610,7 @@ class DateTime
/**
* DOW_WEDNESDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\DOW_WEDNESDAY instead
*/
@ -561,7 +619,7 @@ class DateTime
/**
* DOW_THURSDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\DOW_THURSDAY instead
*/
@ -570,7 +628,7 @@ class DateTime
/**
* DOW_FRIDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\DOW_FRIDAY instead
*/
@ -579,7 +637,7 @@ class DateTime
/**
* DOW_SATURDAY.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\DOW_SATURDAY instead
*/
@ -588,7 +646,7 @@ class DateTime
/**
* STARTWEEK_MONDAY_ISO.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\STARTWEEK_MONDAY_ISO instead
*/
@ -597,7 +655,7 @@ class DateTime
/**
* METHODARR.
*
* @Deprecated 2.0.0
* @Deprecated 1.18.0
*
* @see Use DateTimeExcel\Constants\METHODARR instead
*/
@ -624,11 +682,14 @@ class DateTime
* three days or less in the first week of January, the WEEKNUM function returns week numbers
* that are incorrect according to the European standard.
*
* @Deprecated 2.0.0 Use the funcWeekNum method in the DateTimeExcel\WeekNum class instead
*
* Excel Function:
* WEEKNUM(dateValue[,style])
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Week::number(()
* Use the number method in the DateTimeExcel\Week class instead
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $method Week begins on Sunday or Monday
@ -647,7 +708,7 @@ class DateTime
*/
public static function WEEKNUM($dateValue = 1, $method = self::STARTWEEK_SUNDAY)
{
return DateTimeExcel\WeekNum::funcWeekNum($dateValue, $method);
return DateTimeExcel\Week::number($dateValue, $method);
}
/**
@ -655,11 +716,14 @@ class DateTime
*
* Returns the ISO 8601 week number of the year for a specified date.
*
* @Deprecated 2.0.0 Use the funcIsoWeeknum method in the DateTimeExcel\IsoWeekNum class instead
*
* Excel Function:
* ISOWEEKNUM(dateValue)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Week::isoWeekNumber()
* Use the isoWeekNumber method in the DateTimeExcel\Week class instead
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
@ -667,7 +731,7 @@ class DateTime
*/
public static function ISOWEEKNUM($dateValue = 1)
{
return DateTimeExcel\IsoWeekNum::funcIsoWeekNum($dateValue);
return DateTimeExcel\Week::isoWeekNumber($dateValue);
}
/**
@ -676,11 +740,14 @@ class DateTime
* Returns the month of a date represented by a serial number.
* The month is given as an integer, ranging from 1 (January) to 12 (December).
*
* @Deprecated 2.0.0 Use the funcMonth method in the DateTimeExcel\Month class instead
*
* Excel Function:
* MONTH(dateValue)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\DateParts::month()
* Use the month method in the DateTimeExcel\DateParts class instead
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
@ -688,7 +755,7 @@ class DateTime
*/
public static function MONTHOFYEAR($dateValue = 1)
{
return DateTimeExcel\Month::funcMonth($dateValue);
return DateTimeExcel\DateParts::month($dateValue);
}
/**
@ -697,11 +764,14 @@ class DateTime
* Returns the year corresponding to a date.
* The year is returned as an integer in the range 1900-9999.
*
* @Deprecated 2.0.0 Use the funcYear method in the DateTimeExcel\Year class instead
*
* Excel Function:
* YEAR(dateValue)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\DateParts::year()
* Use the ear method in the DateTimeExcel\DateParts class instead
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
@ -709,7 +779,7 @@ class DateTime
*/
public static function YEAR($dateValue = 1)
{
return DateTimeExcel\Year::funcYear($dateValue);
return DateTimeExcel\DateParts::year($dateValue);
}
/**
@ -718,11 +788,14 @@ class DateTime
* Returns the hour of a time value.
* The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).
*
* @Deprecated 2.0.0 Use the funcHour method in the DateTimeExcel\Hour class instead
*
* Excel Function:
* HOUR(timeValue)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\TimeParts::hour()
* Use the hour method in the DateTimeExcel\TimeParts class instead
*
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string
*
@ -730,7 +803,7 @@ class DateTime
*/
public static function HOUROFDAY($timeValue = 0)
{
return DateTimeExcel\Hour::funcHour($timeValue);
return DateTimeExcel\TimeParts::hour($timeValue);
}
/**
@ -739,11 +812,14 @@ class DateTime
* Returns the minutes of a time value.
* The minute is given as an integer, ranging from 0 to 59.
*
* @Deprecated 2.0.0 Use the funcMinute method in the DateTimeExcel\Minute class instead
*
* Excel Function:
* MINUTE(timeValue)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\TimeParts::minute()
* Use the minute method in the DateTimeExcel\TimeParts class instead
*
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string
*
@ -751,7 +827,7 @@ class DateTime
*/
public static function MINUTE($timeValue = 0)
{
return DateTimeExcel\Minute::funcMinute($timeValue);
return DateTimeExcel\TimeParts::minute($timeValue);
}
/**
@ -760,11 +836,14 @@ class DateTime
* Returns the seconds of a time value.
* The second is given as an integer in the range 0 (zero) to 59.
*
* @Deprecated 2.0.0 Use the funcSecond method in the DateTimeExcel\Second class instead
*
* Excel Function:
* SECOND(timeValue)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\TimeParts::second()
* Use the second method in the DateTimeExcel\TimeParts class instead
*
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string
*
@ -772,7 +851,7 @@ class DateTime
*/
public static function SECOND($timeValue = 0)
{
return DateTimeExcel\Second::funcSecond($timeValue);
return DateTimeExcel\TimeParts::second($timeValue);
}
/**
@ -783,11 +862,14 @@ class DateTime
* Use EDATE to calculate maturity dates or due dates that fall on the same day of the month
* as the date of issue.
*
* @Deprecated 2.0.0 Use the funcEDate method in the DateTimeExcel\EDate class instead
*
* Excel Function:
* EDATE(dateValue,adjustmentMonths)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Month::adjust()
* Use the adjust method in the DateTimeExcel\Edate class instead
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $adjustmentMonths The number of months before or after start_date.
@ -799,7 +881,7 @@ class DateTime
*/
public static function EDATE($dateValue = 1, $adjustmentMonths = 0)
{
return DateTimeExcel\EDate::funcEDate($dateValue, $adjustmentMonths);
return DateTimeExcel\Month::adjust($dateValue, $adjustmentMonths);
}
/**
@ -809,11 +891,14 @@ class DateTime
* before or after start_date.
* Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month.
*
* @Deprecated 2.0.0 Use the funcEoMonth method in the DateTimeExcel\EoMonth class instead
*
* Excel Function:
* EOMONTH(dateValue,adjustmentMonths)
*
* @Deprecated 1.18.0
*
* @See DateTimeExcel\Month::lastDay()
* Use the lastDay method in the DateTimeExcel\EoMonth class instead
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $adjustmentMonths The number of months before or after start_date.
@ -825,6 +910,6 @@ class DateTime
*/
public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0)
{
return DateTimeExcel\EoMonth::funcEoMonth($dateValue, $adjustmentMonths);
return DateTimeExcel\Month::lastDay($dateValue, $adjustmentMonths);
}
}

View File

@ -22,6 +22,7 @@ class Constants
const DOW_FRIDAY = 6;
const DOW_SATURDAY = 7;
const STARTWEEK_MONDAY_ISO = 21;
const METHODARR = [
self::STARTWEEK_SUNDAY => self::DOW_SUNDAY,
self::DOW_MONDAY,

View File

@ -5,8 +5,33 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use DateTimeImmutable;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Now
class Current
{
/**
* DATENOW.
*
* Returns the current date.
* The NOW function is useful when you need to display the current date and time on a worksheet or
* calculate a value based on the current date and time, and have that value updated each time you
* open the worksheet.
*
* NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
* and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
*
* Excel Function:
* TODAY()
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function today()
{
$dti = new DateTimeImmutable();
$dateArray = date_parse($dti->format('c'));
return is_array($dateArray) ? Helpers::returnIn3FormatsArray($dateArray, true) : Functions::VALUE();
}
/**
* DATETIMENOW.
*
@ -24,7 +49,7 @@ class Now
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function funcNow()
public static function now()
{
$dti = new DateTimeImmutable();
$dateArray = date_parse($dti->format('c'));

View File

@ -2,12 +2,12 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
class Datefunc
class Date
{
/**
* DATE.
@ -58,9 +58,9 @@ class Datefunc
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function funcDate($year, $month, $day)
public static function fromYMD($year, $month, $day)
{
$baseYear = Date::getExcelCalendar();
$baseYear = SharedDateHelper::getExcelCalendar();
try {
$year = self::getYear($year, $baseYear);
@ -72,7 +72,7 @@ class Datefunc
}
// Execute function
$excelDateValue = Date::formattedPHPToExcel($year, $month, $day);
$excelDateValue = SharedDateHelper::formattedPHPToExcel($year, $month, $day);
return Helpers::returnIn3FormatsFloat($excelDateValue);
}
@ -85,7 +85,7 @@ class Datefunc
private static function getYear($year, int $baseYear): int
{
$year = Functions::flattenSingleValue($year);
$year = ($year !== null) ? StringHelper::testStringAsNumeric($year) : 0;
$year = ($year !== null) ? StringHelper::testStringAsNumeric((string) $year) : 0;
if (!is_numeric($year)) {
throw new Exception(Functions::VALUE());
}
@ -102,7 +102,7 @@ class Datefunc
$year += 1900;
}
return $year;
return (int) $year;
}
/**
@ -115,10 +115,10 @@ class Datefunc
$month = Functions::flattenSingleValue($month);
if (($month !== null) && (!is_numeric($month))) {
$month = Date::monthStringToNumber($month);
$month = SharedDateHelper::monthStringToNumber($month);
}
$month = ($month !== null) ? StringHelper::testStringAsNumeric($month) : 0;
$month = ($month !== null) ? StringHelper::testStringAsNumeric((string) $month) : 0;
if (!is_numeric($month)) {
throw new Exception(Functions::VALUE());
}
@ -136,10 +136,10 @@ class Datefunc
$day = Functions::flattenSingleValue($day);
if (($day !== null) && (!is_numeric($day))) {
$day = Date::dayStringToNumber($day);
$day = SharedDateHelper::dayStringToNumber($day);
}
$day = ($day !== null) ? StringHelper::testStringAsNumeric($day) : 0;
$day = ($day !== null) ? StringHelper::testStringAsNumeric((string) $day) : 0;
if (!is_numeric($day)) {
throw new Exception(Functions::VALUE());
}

View File

@ -0,0 +1,127 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class DateParts
{
/**
* DAYOFMONTH.
*
* Returns the day of the month, for a specified date. The day is given as an integer
* ranging from 1 to 31.
*
* Excel Function:
* DAY(dateValue)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
* @return int|string Day of the month
*/
public static function day($dateValue)
{
$weirdResult = self::weirdCondition($dateValue);
if ($weirdResult >= 0) {
return $weirdResult;
}
try {
$dateValue = Helpers::getDateValue($dateValue);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$PHPDateObject = SharedDateHelper::excelToDateTimeObject($dateValue);
return (int) $PHPDateObject->format('j');
}
/**
* MONTHOFYEAR.
*
* Returns the month of a date represented by a serial number.
* The month is given as an integer, ranging from 1 (January) to 12 (December).
*
* Excel Function:
* MONTH(dateValue)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
* @return int|string Month of the year
*/
public static function month($dateValue)
{
try {
$dateValue = Helpers::getDateValue($dateValue);
} catch (Exception $e) {
return $e->getMessage();
}
if ($dateValue < 1 && SharedDateHelper::getExcelCalendar() === SharedDateHelper::CALENDAR_WINDOWS_1900) {
return 1;
}
// Execute function
$PHPDateObject = SharedDateHelper::excelToDateTimeObject($dateValue);
return (int) $PHPDateObject->format('n');
}
/**
* YEAR.
*
* Returns the year corresponding to a date.
* The year is returned as an integer in the range 1900-9999.
*
* Excel Function:
* YEAR(dateValue)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
* @return int|string Year
*/
public static function year($dateValue)
{
try {
$dateValue = Helpers::getDateValue($dateValue);
} catch (Exception $e) {
return $e->getMessage();
}
if ($dateValue < 1 && SharedDateHelper::getExcelCalendar() === SharedDateHelper::CALENDAR_WINDOWS_1900) {
return 1900;
}
// Execute function
$PHPDateObject = SharedDateHelper::excelToDateTimeObject($dateValue);
return (int) $PHPDateObject->format('Y');
}
/**
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*/
private static function weirdCondition($dateValue): int
{
// Excel does not treat 0 consistently for DAY vs. (MONTH or YEAR)
if (SharedDateHelper::getExcelCalendar() === SharedDateHelper::CALENDAR_WINDOWS_1900 && Functions::getCompatibilityMode() == Functions::COMPATIBILITY_EXCEL) {
if (is_bool($dateValue)) {
return (int) $dateValue;
}
if ($dateValue === null) {
return 0;
}
if (is_numeric($dateValue) && $dateValue < 1 && $dateValue >= 0) {
return 0;
}
}
return -1;
}
}

View File

@ -4,7 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use DateTimeImmutable;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class DateValue
{
@ -33,13 +33,13 @@ class DateValue
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function funcDateValue($dateValue)
public static function fromString($dateValue)
{
$dti = new DateTimeImmutable();
$baseYear = Date::getExcelCalendar();
$baseYear = SharedDateHelper::getExcelCalendar();
$dateValue = trim(Functions::flattenSingleValue($dateValue), '"');
// Strip any ordinals because they're allowed in Excel (English only)
$dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui', '$1$3', $dateValue);
$dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui', '$1$3', $dateValue) ?? '';
// Convert separators (/ . or space) to hyphens (should also handle dot used for ordinals in some countries, e.g. Denmark, Germany)
$dateValue = str_replace(['/', '.', '-', ' '], ' ', $dateValue);
@ -59,7 +59,7 @@ class DateValue
}
if (count($t1) === 1) {
// We've been fed a time value without any date
return ((strpos($t, ':') === false)) ? Functions::Value() : 0.0;
return ((strpos((string) $t, ':') === false)) ? Functions::Value() : 0.0;
}
unset($t);
@ -105,7 +105,7 @@ class DateValue
$testVal1 = strtok($dateValue, '- ');
$testVal2 = strtok('- ');
$testVal3 = strtok('- ') ?: $dti->format('Y');
Helpers::adjustYear($testVal1, $testVal2, $testVal3);
Helpers::adjustYear((string) $testVal1, (string) $testVal2, $testVal3);
$PHPDateArray = date_parse($testVal1 . '-' . $testVal2 . '-' . $testVal3);
if (($PHPDateArray === false) || ($PHPDateArray['error_count'] > 0)) {
$PHPDateArray = date_parse($testVal2 . '-' . $testVal1 . '-' . $testVal3);
@ -118,7 +118,7 @@ class DateValue
/**
* Final results.
*
* @param array|false $PHPDateArray
* @param array|bool $PHPDateArray
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
@ -126,7 +126,7 @@ class DateValue
private static function finalResults($PHPDateArray, DateTimeImmutable $dti, int $baseYear)
{
$retValue = Functions::Value();
if (($PHPDateArray !== false) && ($PHPDateArray['error_count'] == 0)) {
if (is_array($PHPDateArray) && $PHPDateArray['error_count'] == 0) {
// Execute function
Helpers::replaceIfEmpty($PHPDateArray['year'], $dti->format('Y'));
if ($PHPDateArray['year'] < $baseYear) {

View File

@ -1,61 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class Day
{
/**
* DAYOFMONTH.
*
* Returns the day of the month, for a specified date. The day is given as an integer
* ranging from 1 to 31.
*
* Excel Function:
* DAY(dateValue)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
* @return int|string Day of the month
*/
public static function funcDay($dateValue)
{
$weirdResult = self::weirdCondition($dateValue);
if ($weirdResult >= 0) {
return $weirdResult;
}
try {
$dateValue = Helpers::getDateValue($dateValue);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$PHPDateObject = Date::excelToDateTimeObject($dateValue);
return (int) $PHPDateObject->format('j');
}
private static function weirdCondition($dateValue): int
{
// Excel does not treat 0 consistently for DAY vs. (MONTH or YEAR)
if (Date::getExcelCalendar() === DATE::CALENDAR_WINDOWS_1900 && Functions::getCompatibilityMode() == Functions::COMPATIBILITY_EXCEL) {
if (is_bool($dateValue)) {
return (int) $dateValue;
}
if ($dateValue === null) {
return 0;
}
if (is_numeric($dateValue) && $dateValue < 1 && $dateValue >= 0) {
return 0;
}
}
return -1;
}
}

View File

@ -3,9 +3,9 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use DateTimeInterface;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class Days
{
@ -24,7 +24,7 @@ class Days
*
* @return int|string Number of days between start date and end date or an error
*/
public static function funcDays($endDate, $startDate)
public static function between($endDate, $startDate)
{
try {
$startDate = Helpers::getDateValue($startDate);
@ -34,8 +34,8 @@ class Days
}
// Execute function
$PHPStartDateObject = Date::excelToDateTimeObject($startDate);
$PHPEndDateObject = Date::excelToDateTimeObject($endDate);
$PHPStartDateObject = SharedDateHelper::excelToDateTimeObject($startDate);
$PHPEndDateObject = SharedDateHelper::excelToDateTimeObject($endDate);
$days = Functions::VALUE();
$diff = $PHPStartDateObject->diff($PHPEndDateObject);

View File

@ -4,7 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class Days360
{
@ -36,7 +36,7 @@ class Days360
*
* @return int|string Number of days between start date and end date
*/
public static function funcDays360($startDate = 0, $endDate = 0, $method = false)
public static function between($startDate = 0, $endDate = 0, $method = false)
{
try {
$startDate = Helpers::getDateValue($startDate);
@ -50,12 +50,12 @@ class Days360
}
// Execute function
$PHPStartDateObject = Date::excelToDateTimeObject($startDate);
$PHPStartDateObject = SharedDateHelper::excelToDateTimeObject($startDate);
$startDay = $PHPStartDateObject->format('j');
$startMonth = $PHPStartDateObject->format('n');
$startYear = $PHPStartDateObject->format('Y');
$PHPEndDateObject = Date::excelToDateTimeObject($endDate);
$PHPEndDateObject = SharedDateHelper::excelToDateTimeObject($endDate);
$endDay = $PHPEndDateObject->format('j');
$endMonth = $PHPEndDateObject->format('n');
$endYear = $PHPEndDateObject->format('Y');

View File

@ -4,11 +4,11 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use DateInterval;
use DateTime;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class DateDif
class Difference
{
/**
* DATEDIF.
@ -21,7 +21,7 @@ class DateDif
*
* @return int|string Interval between the dates
*/
public static function funcDateDif($startDate, $endDate, $unit = 'D')
public static function interval($startDate, $endDate, $unit = 'D')
{
try {
$startDate = Helpers::getDateValue($startDate);
@ -33,12 +33,12 @@ class DateDif
}
// Execute function
$PHPStartDateObject = Date::excelToDateTimeObject($startDate);
$PHPStartDateObject = SharedDateHelper::excelToDateTimeObject($startDate);
$startDays = (int) $PHPStartDateObject->format('j');
$startMonths = (int) $PHPStartDateObject->format('n');
$startYears = (int) $PHPStartDateObject->format('Y');
$PHPEndDateObject = Date::excelToDateTimeObject($endDate);
$PHPEndDateObject = SharedDateHelper::excelToDateTimeObject($endDate);
$endDays = (int) $PHPEndDateObject->format('j');
$endMonths = (int) $PHPEndDateObject->format('n');
$endYears = (int) $PHPEndDateObject->format('Y');

View File

@ -1,45 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class EDate
{
/**
* EDATE.
*
* Returns the serial number that represents the date that is the indicated number of months
* before or after a specified date (the start_date).
* Use EDATE to calculate maturity dates or due dates that fall on the same day of the month
* as the date of issue.
*
* Excel Function:
* EDATE(dateValue,adjustmentMonths)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $adjustmentMonths The number of months before or after start_date.
* A positive value for months yields a future date;
* a negative value yields a past date.
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function funcEDate($dateValue, $adjustmentMonths)
{
try {
$dateValue = Helpers::getDateValue($dateValue, false);
$adjustmentMonths = Helpers::validateNumericNull($adjustmentMonths);
} catch (Exception $e) {
return $e->getMessage();
}
$adjustmentMonths = floor($adjustmentMonths);
// Execute function
$PHPDateObject = Helpers::adjustDateByMonths($dateValue, $adjustmentMonths);
return Helpers::returnIn3FormatsObject($PHPDateObject);
}
}

View File

@ -1,47 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class EoMonth
{
/**
* EOMONTH.
*
* Returns the date value for the last day of the month that is the indicated number of months
* before or after start_date.
* Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month.
*
* Excel Function:
* EOMONTH(dateValue,adjustmentMonths)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $adjustmentMonths The number of months before or after start_date.
* A positive value for months yields a future date;
* a negative value yields a past date.
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function funcEoMonth($dateValue, $adjustmentMonths)
{
try {
$dateValue = Helpers::getDateValue($dateValue, false);
$adjustmentMonths = Helpers::validateNumericNull($adjustmentMonths);
} catch (Exception $e) {
return $e->getMessage();
}
$adjustmentMonths = floor($adjustmentMonths);
// Execute function
$PHPDateObject = Helpers::adjustDateByMonths($dateValue, $adjustmentMonths + 1);
$adjustDays = (int) $PHPDateObject->format('d');
$adjustDaysString = '-' . $adjustDays . ' days';
$PHPDateObject->modify($adjustDaysString);
return Helpers::returnIn3FormatsObject($PHPDateObject);
}
}

View File

@ -5,7 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class Helpers
{
@ -31,7 +31,7 @@ class Helpers
public static function getDateValue($dateValue, bool $allowBool = true): float
{
if (is_object($dateValue)) {
$retval = Date::PHPToExcel($dateValue);
$retval = SharedDateHelper::PHPToExcel($dateValue);
if (is_bool($retval)) {
throw new Exception(Functions::VALUE());
}
@ -43,7 +43,7 @@ class Helpers
if (!is_numeric($dateValue)) {
$saveReturnDateType = Functions::getReturnDateType();
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
$dateValue = DateValue::funcDateValue($dateValue);
$dateValue = DateValue::fromString($dateValue);
Functions::setReturnDateType($saveReturnDateType);
if (!is_numeric($dateValue)) {
throw new Exception(Functions::VALUE());
@ -67,16 +67,21 @@ class Helpers
{
$saveReturnDateType = Functions::getReturnDateType();
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
$timeValue = TimeValue::funcTimeValue($timeValue);
$timeValue = TimeValue::fromString($timeValue);
Functions::setReturnDateType($saveReturnDateType);
return $timeValue;
}
public static function adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0)
/**
* Adjust date by given months.
*
* @param mixed $dateValue
*/
public static function adjustDateByMonths($dateValue = 0, float $adjustmentMonths = 0): DateTime
{
// Execute function
$PHPDateObject = Date::excelToDateTimeObject($dateValue);
$PHPDateObject = SharedDateHelper::excelToDateTimeObject($dateValue);
$oMonth = (int) $PHPDateObject->format('m');
$oYear = (int) $PHPDateObject->format('Y');
@ -144,7 +149,7 @@ class Helpers
);
}
$excelDateValue =
Date::formattedPHPToExcel(
SharedDateHelper::formattedPHPToExcel(
$dateArray['year'],
$dateArray['month'],
$dateArray['day'],
@ -157,7 +162,7 @@ class Helpers
}
// RETURNDATE_UNIX_TIMESTAMP)
return (int) Date::excelToTimestamp($excelDateValue);
return (int) SharedDateHelper::excelToTimestamp($excelDateValue);
}
/**
@ -172,11 +177,11 @@ class Helpers
return $excelDateValue;
}
if ($retType === Functions::RETURNDATE_UNIX_TIMESTAMP) {
return (int) Date::excelToTimestamp($excelDateValue);
return (int) SharedDateHelper::excelToTimestamp($excelDateValue);
}
// RETURNDATE_PHP_DATETIME_OBJECT
return Date::excelToDateTimeObject($excelDateValue);
return SharedDateHelper::excelToDateTimeObject($excelDateValue);
}
/**
@ -191,11 +196,13 @@ class Helpers
return $PHPDateObject;
}
if ($retType === Functions::RETURNDATE_EXCEL) {
return (float) Date::PHPToExcel($PHPDateObject);
return (float) SharedDateHelper::PHPToExcel($PHPDateObject);
}
// RETURNDATE_UNIX_TIMESTAMP
$stamp = SharedDateHelper::PHPToExcel($PHPDateObject);
$stamp = is_bool($stamp) ? ((int) $stamp) : $stamp;
return (int) Date::excelToTimestamp(Date::PHPToExcel($PHPDateObject));
return (int) SharedDateHelper::excelToTimestamp($stamp);
}
private static function baseDate(): int
@ -203,7 +210,7 @@ class Helpers
if (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE) {
return 0;
}
if (Date::getExcelCalendar() === Date::CALENDAR_MAC_1904) {
if (SharedDateHelper::getExcelCalendar() === SharedDateHelper::CALENDAR_MAC_1904) {
return 0;
}
@ -239,9 +246,12 @@ class Helpers
if ($number === null) {
return 0;
}
if (is_numeric($number)) {
if (is_int($number)) {
return $number;
}
if (is_numeric($number)) {
return (float) $number;
}
throw new Exception(Functions::VALUE());
}

View File

@ -1,44 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class Hour
{
/**
* HOUROFDAY.
*
* Returns the hour of a time value.
* The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).
*
* Excel Function:
* HOUR(timeValue)
*
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string
*
* @return int|string Hour
*/
public static function funcHour($timeValue)
{
try {
$timeValue = Functions::flattenSingleValue($timeValue);
Helpers::nullFalseTrueToNumber($timeValue);
if (!is_numeric($timeValue)) {
$timeValue = Helpers::getTimeValue($timeValue);
}
Helpers::validateNotNegative($timeValue);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$timeValue = fmod($timeValue, 1);
$timeValue = Date::excelToDateTimeObject($timeValue);
return (int) $timeValue->format('H');
}
}

View File

@ -1,55 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class IsoWeekNum
{
/**
* ISOWEEKNUM.
*
* Returns the ISO 8601 week number of the year for a specified date.
*
* Excel Function:
* ISOWEEKNUM(dateValue)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
* @return int|string Week Number
*/
public static function funcIsoWeekNum($dateValue)
{
if (self::apparentBug($dateValue)) {
return 52;
}
try {
$dateValue = Helpers::getDateValue($dateValue);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$PHPDateObject = Date::excelToDateTimeObject($dateValue);
Helpers::silly1900($PHPDateObject);
return (int) $PHPDateObject->format('W');
}
private static function apparentBug($dateValue): bool
{
if (Date::getExcelCalendar() !== DATE::CALENDAR_MAC_1904) {
if (is_bool($dateValue)) {
return true;
}
if (is_numeric($dateValue) && !((int) $dateValue)) {
return true;
}
}
return false;
}
}

View File

@ -1,44 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class Minute
{
/**
* MINUTE.
*
* Returns the minutes of a time value.
* The minute is given as an integer, ranging from 0 to 59.
*
* Excel Function:
* MINUTE(timeValue)
*
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string
*
* @return int|string Minute
*/
public static function funcMinute($timeValue)
{
try {
$timeValue = Functions::flattenSingleValue($timeValue);
Helpers::nullFalseTrueToNumber($timeValue);
if (!is_numeric($timeValue)) {
$timeValue = Helpers::getTimeValue($timeValue);
}
Helpers::validateNotNegative($timeValue);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$timeValue = fmod($timeValue, 1);
$timeValue = Date::excelToDateTimeObject($timeValue);
return (int) $timeValue->format('i');
}
}

View File

@ -2,39 +2,81 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
class Month
{
/**
* MONTHOFYEAR.
* EDATE.
*
* Returns the month of a date represented by a serial number.
* The month is given as an integer, ranging from 1 (January) to 12 (December).
* Returns the serial number that represents the date that is the indicated number of months
* before or after a specified date (the start_date).
* Use EDATE to calculate maturity dates or due dates that fall on the same day of the month
* as the date of issue.
*
* Excel Function:
* MONTH(dateValue)
* EDATE(dateValue,adjustmentMonths)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* PHP DateTime object, or a standard date string
* @param int $adjustmentMonths The number of months before or after start_date.
* A positive value for months yields a future date;
* a negative value yields a past date.
*
* @return int|string Month of the year
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function funcMonth($dateValue)
public static function adjust($dateValue, $adjustmentMonths)
{
try {
$dateValue = Helpers::getDateValue($dateValue);
$dateValue = Helpers::getDateValue($dateValue, false);
$adjustmentMonths = Helpers::validateNumericNull($adjustmentMonths);
} catch (Exception $e) {
return $e->getMessage();
}
if ($dateValue < 1 && Date::getExcelCalendar() === DATE::CALENDAR_WINDOWS_1900) {
return 1;
}
$adjustmentMonths = floor($adjustmentMonths);
// Execute function
$PHPDateObject = Date::excelToDateTimeObject($dateValue);
$PHPDateObject = Helpers::adjustDateByMonths($dateValue, $adjustmentMonths);
return (int) $PHPDateObject->format('n');
return Helpers::returnIn3FormatsObject($PHPDateObject);
}
/**
* EOMONTH.
*
* Returns the date value for the last day of the month that is the indicated number of months
* before or after start_date.
* Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month.
*
* Excel Function:
* EOMONTH(dateValue,adjustmentMonths)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $adjustmentMonths The number of months before or after start_date.
* A positive value for months yields a future date;
* a negative value yields a past date.
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function lastDay($dateValue, $adjustmentMonths)
{
try {
$dateValue = Helpers::getDateValue($dateValue, false);
$adjustmentMonths = Helpers::validateNumericNull($adjustmentMonths);
} catch (Exception $e) {
return $e->getMessage();
}
$adjustmentMonths = floor($adjustmentMonths);
// Execute function
$PHPDateObject = Helpers::adjustDateByMonths($dateValue, $adjustmentMonths + 1);
$adjustDays = (int) $PHPDateObject->format('d');
$adjustDaysString = '-' . $adjustDays . ' days';
$PHPDateObject->modify($adjustDaysString);
return Helpers::returnIn3FormatsObject($PHPDateObject);
}
}

View File

@ -2,9 +2,8 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class NetworkDays
{
@ -23,10 +22,11 @@ class NetworkDays
* PHP DateTime object, or a standard date string
* @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param mixed $dateArgs
*
* @return int|string Interval between the dates
*/
public static function funcNetworkDays($startDate, $endDate, ...$dateArgs)
public static function count($startDate, $endDate, ...$dateArgs)
{
try {
// Retrieve the mandatory start and end date that are referenced in the function definition
@ -55,7 +55,7 @@ class NetworkDays
$holidayCountedArray = [];
foreach ($holidayArray as $holidayDate) {
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
if ((WeekDay::funcWeekDay($holidayDate, 2) < 6) && (!in_array($holidayDate, $holidayCountedArray))) {
if ((Week::day($holidayDate, 2) < 6) && (!in_array($holidayDate, $holidayCountedArray))) {
--$partWeekDays;
$holidayCountedArray[] = $holidayDate;
}
@ -67,7 +67,7 @@ class NetworkDays
private static function calcStartDow(float $startDate): int
{
$startDow = 6 - (int) WeekDay::funcWeekDay($startDate, 2);
$startDow = 6 - (int) Week::day($startDate, 2);
if ($startDow < 0) {
$startDow = 5;
}
@ -77,7 +77,7 @@ class NetworkDays
private static function calcEndDow(float $endDate): int
{
$endDow = (int) WeekDay::funcWeekDay($endDate, 2);
$endDow = (int) Week::day($endDate, 2);
if ($endDow >= 6) {
$endDow = 0;
}
@ -95,7 +95,7 @@ class NetworkDays
return $partWeekDays;
}
private static function applySign(int $result, float $sDate, float $eDate)
private static function applySign(int $result, float $sDate, float $eDate): int
{
return ($sDate > $eDate) ? -$result : $result;
}

View File

@ -1,44 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class Second
{
/**
* MINUTE.
*
* Returns the minutes of a time value.
* The minute is given as an integer, ranging from 0 to 59.
*
* Excel Function:
* MINUTE(timeValue)
*
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string
*
* @return int|string Minute
*/
public static function funcSecond($timeValue)
{
try {
$timeValue = Functions::flattenSingleValue($timeValue);
Helpers::nullFalseTrueToNumber($timeValue);
if (!is_numeric($timeValue)) {
$timeValue = Helpers::getTimeValue($timeValue);
}
Helpers::validateNotNegative($timeValue);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$timeValue = fmod($timeValue, 1);
$timeValue = Date::excelToDateTimeObject($timeValue);
return (int) $timeValue->format('s');
}
}

View File

@ -5,7 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class Time
{
@ -20,14 +20,14 @@ class Time
* Excel Function:
* TIME(hour,minute,second)
*
* @param int $hour A number from 0 (zero) to 32767 representing the hour.
* @param mixed $hour A number from 0 (zero) to 32767 representing the hour.
* Any value greater than 23 will be divided by 24 and the remainder
* will be treated as the hour value. For example, TIME(27,0,0) =
* TIME(3,0,0) = .125 or 3:00 AM.
* @param int $minute A number from 0 to 32767 representing the minute.
* @param mixed $minute A number from 0 to 32767 representing the minute.
* Any value greater than 59 will be converted to hours and minutes.
* For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM.
* @param int $second A number from 0 to 32767 representing the second.
* @param mixed $second A number from 0 to 32767 representing the second.
* Any value greater than 59 will be converted to hours, minutes,
* and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148
* or 12:33:20 AM
@ -35,7 +35,7 @@ class Time
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function funcTime($hour, $minute, $second)
public static function fromHMS($hour, $minute, $second)
{
try {
$hour = self::toIntWithNullBool($hour);
@ -57,13 +57,13 @@ class Time
// Execute function
$retType = Functions::getReturnDateType();
if ($retType === Functions::RETURNDATE_EXCEL) {
$calendar = Date::getExcelCalendar();
$date = (int) ($calendar !== Date::CALENDAR_WINDOWS_1900);
$calendar = SharedDateHelper::getExcelCalendar();
$date = (int) ($calendar !== SharedDateHelper::CALENDAR_WINDOWS_1900);
return (float) Date::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
return (float) SharedDateHelper::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
}
if ($retType === Functions::RETURNDATE_UNIX_TIMESTAMP) {
return (int) Date::excelToTimestamp(Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600
return (int) SharedDateHelper::excelToTimestamp(SharedDateHelper::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600
}
// RETURNDATE_PHP_DATETIME_OBJECT
// Hour has already been normalized (0-23) above
@ -100,6 +100,9 @@ class Time
}
}
/**
* @param mixed $value expect int
*/
private static function toIntWithNullBool($value): int
{
$value = Functions::flattenSingleValue($value);

View File

@ -0,0 +1,112 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class TimeParts
{
/**
* HOUROFDAY.
*
* Returns the hour of a time value.
* The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).
*
* Excel Function:
* HOUR(timeValue)
*
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string
*
* @return int|string Hour
*/
public static function hour($timeValue)
{
try {
$timeValue = Functions::flattenSingleValue($timeValue);
Helpers::nullFalseTrueToNumber($timeValue);
if (!is_numeric($timeValue)) {
$timeValue = Helpers::getTimeValue($timeValue);
}
Helpers::validateNotNegative($timeValue);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$timeValue = fmod($timeValue, 1);
$timeValue = SharedDateHelper::excelToDateTimeObject($timeValue);
return (int) $timeValue->format('H');
}
/**
* MINUTE.
*
* Returns the minutes of a time value.
* The minute is given as an integer, ranging from 0 to 59.
*
* Excel Function:
* MINUTE(timeValue)
*
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string
*
* @return int|string Minute
*/
public static function minute($timeValue)
{
try {
$timeValue = Functions::flattenSingleValue($timeValue);
Helpers::nullFalseTrueToNumber($timeValue);
if (!is_numeric($timeValue)) {
$timeValue = Helpers::getTimeValue($timeValue);
}
Helpers::validateNotNegative($timeValue);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$timeValue = fmod($timeValue, 1);
$timeValue = SharedDateHelper::excelToDateTimeObject($timeValue);
return (int) $timeValue->format('i');
}
/**
* SECOND.
*
* Returns the seconds of a time value.
* The minute is given as an integer, ranging from 0 to 59.
*
* Excel Function:
* SECOND(timeValue)
*
* @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard time string
*
* @return int|string Second
*/
public static function second($timeValue)
{
try {
$timeValue = Functions::flattenSingleValue($timeValue);
Helpers::nullFalseTrueToNumber($timeValue);
if (!is_numeric($timeValue)) {
$timeValue = Helpers::getTimeValue($timeValue);
}
Helpers::validateNotNegative($timeValue);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$timeValue = fmod($timeValue, 1);
$timeValue = SharedDateHelper::excelToDateTimeObject($timeValue);
return (int) $timeValue->format('s');
}
}

View File

@ -4,7 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Datetime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class TimeValue
{
@ -29,12 +29,12 @@ class TimeValue
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function funcTimeValue($timeValue)
public static function fromString($timeValue)
{
$timeValue = trim(Functions::flattenSingleValue($timeValue), '"');
$timeValue = str_replace(['/', '.'], '-', $timeValue);
$arraySplit = preg_split('/[\/:\-\s]/', $timeValue);
$arraySplit = preg_split('/[\/:\-\s]/', $timeValue) ?: [];
if ((count($arraySplit) == 2 || count($arraySplit) == 3) && $arraySplit[0] > 24) {
$arraySplit[0] = ($arraySplit[0] % 24);
$timeValue = implode(':', $arraySplit);
@ -44,13 +44,13 @@ class TimeValue
$retValue = Functions::VALUE();
if (($PHPDateArray !== false) && ($PHPDateArray['error_count'] == 0)) {
// OpenOffice-specific code removed - it works just like Excel
$excelDateValue = Date::formattedPHPToExcel(1900, 1, 1, $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second']) - 1;
$excelDateValue = SharedDateHelper::formattedPHPToExcel(1900, 1, 1, $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second']) - 1;
$retType = Functions::getReturnDateType();
if ($retType === Functions::RETURNDATE_EXCEL) {
$retValue = (float) $excelDateValue;
} elseif ($retType === Functions::RETURNDATE_UNIX_TIMESTAMP) {
$retValue = (int) $phpDateValue = Date::excelToTimestamp($excelDateValue + 25569) - 3600;
$retValue = (int) $phpDateValue = SharedDateHelper::excelToTimestamp($excelDateValue + 25569) - 3600;
} else {
$retValue = new DateTime('1900-01-01 ' . $PHPDateArray['hour'] . ':' . $PHPDateArray['minute'] . ':' . $PHPDateArray['second']);
}

View File

@ -1,34 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use DateTimeImmutable;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Today
{
/**
* DATENOW.
*
* Returns the current date.
* The NOW function is useful when you need to display the current date and time on a worksheet or
* calculate a value based on the current date and time, and have that value updated each time you
* open the worksheet.
*
* NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
* and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
*
* Excel Function:
* TODAY()
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function funcToday()
{
$dti = new DateTimeImmutable();
$dateArray = date_parse($dti->format('c'));
return is_array($dateArray) ? Helpers::returnIn3FormatsArray($dateArray, true) : Functions::VALUE();
}
}

View File

@ -0,0 +1,254 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class Week
{
/**
* WEEKNUM.
*
* Returns the week of the year for a specified date.
* The WEEKNUM function considers the week containing January 1 to be the first week of the year.
* However, there is a European standard that defines the first week as the one with the majority
* of days (four or more) falling in the new year. This means that for years in which there are
* three days or less in the first week of January, the WEEKNUM function returns week numbers
* that are incorrect according to the European standard.
*
* Excel Function:
* WEEKNUM(dateValue[,style])
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $method Week begins on Sunday or Monday
* 1 or omitted Week begins on Sunday.
* 2 Week begins on Monday.
* 11 Week begins on Monday.
* 12 Week begins on Tuesday.
* 13 Week begins on Wednesday.
* 14 Week begins on Thursday.
* 15 Week begins on Friday.
* 16 Week begins on Saturday.
* 17 Week begins on Sunday.
* 21 ISO (Jan. 4 is week 1, begins on Monday).
*
* @return int|string Week Number
*/
public static function number($dateValue, $method = Constants::STARTWEEK_SUNDAY)
{
$origDateValueNull = empty($dateValue);
try {
$method = self::validateMethod($method);
if ($dateValue === null) { // boolean not allowed
$dateValue = (SharedDateHelper::getExcelCalendar() === SharedDateHelper::CALENDAR_MAC_1904 || $method === Constants::DOW_SUNDAY) ? 0 : 1;
}
$dateValue = self::validateDateValue($dateValue);
if (!$dateValue && self::buggyWeekNum1900($method)) {
// This seems to be an additional Excel bug.
return 0;
}
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$PHPDateObject = SharedDateHelper::excelToDateTimeObject($dateValue);
if ($method == Constants::STARTWEEK_MONDAY_ISO) {
Helpers::silly1900($PHPDateObject);
return (int) $PHPDateObject->format('W');
}
if (self::buggyWeekNum1904($method, $origDateValueNull, $PHPDateObject)) {
return 0;
}
Helpers::silly1900($PHPDateObject, '+ 5 years'); // 1905 calendar matches
$dayOfYear = (int) $PHPDateObject->format('z');
$PHPDateObject->modify('-' . $dayOfYear . ' days');
$firstDayOfFirstWeek = (int) $PHPDateObject->format('w');
$daysInFirstWeek = (6 - $firstDayOfFirstWeek + $method) % 7;
$daysInFirstWeek += 7 * !$daysInFirstWeek;
$endFirstWeek = $daysInFirstWeek - 1;
$weekOfYear = floor(($dayOfYear - $endFirstWeek + 13) / 7);
return (int) $weekOfYear;
}
/**
* ISOWEEKNUM.
*
* Returns the ISO 8601 week number of the year for a specified date.
*
* Excel Function:
* ISOWEEKNUM(dateValue)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
* @return int|string Week Number
*/
public static function isoWeekNumber($dateValue)
{
if (self::apparentBug($dateValue)) {
return 52;
}
try {
$dateValue = Helpers::getDateValue($dateValue);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$PHPDateObject = SharedDateHelper::excelToDateTimeObject($dateValue);
Helpers::silly1900($PHPDateObject);
return (int) $PHPDateObject->format('W');
}
/**
* WEEKDAY.
*
* Returns the day of the week for a specified date. The day is given as an integer
* ranging from 0 to 7 (dependent on the requested style).
*
* Excel Function:
* WEEKDAY(dateValue[,style])
*
* @param null|float|int|string $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param mixed $style A number that determines the type of return value
* 1 or omitted Numbers 1 (Sunday) through 7 (Saturday).
* 2 Numbers 1 (Monday) through 7 (Sunday).
* 3 Numbers 0 (Monday) through 6 (Sunday).
*
* @return int|string Day of the week value
*/
public static function day($dateValue, $style = 1)
{
try {
$dateValue = Helpers::getDateValue($dateValue);
$style = self::validateStyle($style);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$PHPDateObject = SharedDateHelper::excelToDateTimeObject($dateValue);
Helpers::silly1900($PHPDateObject);
$DoW = (int) $PHPDateObject->format('w');
switch ($style) {
case 1:
++$DoW;
break;
case 2:
$DoW = self::dow0Becomes7($DoW);
break;
case 3:
$DoW = self::dow0Becomes7($DoW) - 1;
break;
}
return $DoW;
}
/**
* @param mixed $style expect int
*/
private static function validateStyle($style): int
{
$style = Functions::flattenSingleValue($style);
if (!is_numeric($style)) {
throw new Exception(Functions::VALUE());
}
$style = (int) $style;
if (($style < 1) || ($style > 3)) {
throw new Exception(Functions::NAN());
}
return $style;
}
private static function dow0Becomes7(int $DoW): int
{
return ($DoW === 0) ? 7 : $DoW;
}
/**
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*/
private static function apparentBug($dateValue): bool
{
if (SharedDateHelper::getExcelCalendar() !== SharedDateHelper::CALENDAR_MAC_1904) {
if (is_bool($dateValue)) {
return true;
}
if (is_numeric($dateValue) && !((int) $dateValue)) {
return true;
}
}
return false;
}
/**
* Validate dateValue parameter.
*
* @param mixed $dateValue
*/
private static function validateDateValue($dateValue): float
{
if (is_bool($dateValue)) {
throw new Exception(Functions::VALUE());
}
return Helpers::getDateValue($dateValue);
}
/**
* Validate method parameter.
*
* @param mixed $method
*/
private static function validateMethod($method): int
{
if ($method === null) {
$method = Constants::STARTWEEK_SUNDAY;
}
$method = Functions::flattenSingleValue($method);
if (!is_numeric($method)) {
throw new Exception(Functions::VALUE());
}
$method = (int) $method;
if (!array_key_exists($method, Constants::METHODARR)) {
throw new Exception(Functions::NAN());
}
$method = Constants::METHODARR[$method];
return $method;
}
private static function buggyWeekNum1900(int $method): bool
{
return $method === Constants::DOW_SUNDAY && SharedDateHelper::getExcelCalendar() === SharedDateHelper::CALENDAR_WINDOWS_1900;
}
private static function buggyWeekNum1904(int $method, bool $origNull, DateTime $dateObject): bool
{
// This appears to be another Excel bug.
return $method === Constants::DOW_SUNDAY && SharedDateHelper::getExcelCalendar() === SharedDateHelper::CALENDAR_MAC_1904 &&
!$origNull && $dateObject->format('Y-m-d') === '1904-01-01';
}
}

View File

@ -1,80 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class WeekDay
{
/**
* WEEKDAY.
*
* Returns the day of the week for a specified date. The day is given as an integer
* ranging from 0 to 7 (dependent on the requested style).
*
* Excel Function:
* WEEKDAY(dateValue[,style])
*
* @param null|float|int|string $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $style A number that determines the type of return value
* 1 or omitted Numbers 1 (Sunday) through 7 (Saturday).
* 2 Numbers 1 (Monday) through 7 (Sunday).
* 3 Numbers 0 (Monday) through 6 (Sunday).
*
* @return int|string Day of the week value
*/
public static function funcWeekDay($dateValue, $style = 1)
{
try {
$dateValue = Helpers::getDateValue($dateValue);
$style = self::validateStyle($style);
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$PHPDateObject = Date::excelToDateTimeObject($dateValue);
Helpers::silly1900($PHPDateObject);
$DoW = (int) $PHPDateObject->format('w');
switch ($style) {
case 1:
++$DoW;
break;
case 2:
$DoW = self::dow0Becomes7($DoW);
break;
case 3:
$DoW = self::dow0Becomes7($DoW) - 1;
break;
}
return $DoW;
}
private static function validateStyle($style): int
{
$style = Functions::flattenSingleValue($style);
if (!is_numeric($style)) {
throw new Exception(Functions::VALUE());
}
$style = (int) $style;
if (($style < 1) || ($style > 3)) {
throw new Exception(Functions::NAN());
}
return $style;
}
private static function dow0Becomes7(int $DoW): int
{
return ($DoW === 0) ? 7 : $DoW;
}
}

View File

@ -1,130 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use DateTime;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class WeekNum
{
/**
* WEEKNUM.
*
* Returns the week of the year for a specified date.
* The WEEKNUM function considers the week containing January 1 to be the first week of the year.
* However, there is a European standard that defines the first week as the one with the majority
* of days (four or more) falling in the new year. This means that for years in which there are
* three days or less in the first week of January, the WEEKNUM function returns week numbers
* that are incorrect according to the European standard.
*
* Excel Function:
* WEEKNUM(dateValue[,style])
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
* @param int $method Week begins on Sunday or Monday
* 1 or omitted Week begins on Sunday.
* 2 Week begins on Monday.
* 11 Week begins on Monday.
* 12 Week begins on Tuesday.
* 13 Week begins on Wednesday.
* 14 Week begins on Thursday.
* 15 Week begins on Friday.
* 16 Week begins on Saturday.
* 17 Week begins on Sunday.
* 21 ISO (Jan. 4 is week 1, begins on Monday).
*
* @return int|string Week Number
*/
public static function funcWeekNum($dateValue, $method = Constants::STARTWEEK_SUNDAY)
{
$origDateValueNull = empty($dateValue);
try {
$method = self::validateMethod($method);
if ($dateValue === null) { // boolean not allowed
$dateValue = (Date::getExcelCalendar() === DATE::CALENDAR_MAC_1904 || $method === Constants::DOW_SUNDAY) ? 0 : 1;
}
$dateValue = self::validateDateValue($dateValue);
if (!$dateValue && self::buggyWeekNum1900($method)) {
// This seems to be an additional Excel bug.
return 0;
}
} catch (Exception $e) {
return $e->getMessage();
}
// Execute function
$PHPDateObject = Date::excelToDateTimeObject($dateValue);
if ($method == Constants::STARTWEEK_MONDAY_ISO) {
Helpers::silly1900($PHPDateObject);
return (int) $PHPDateObject->format('W');
}
if (self::buggyWeekNum1904($method, $origDateValueNull, $PHPDateObject)) {
return 0;
}
Helpers::silly1900($PHPDateObject, '+ 5 years'); // 1905 calendar matches
$dayOfYear = (int) $PHPDateObject->format('z');
$PHPDateObject->modify('-' . $dayOfYear . ' days');
$firstDayOfFirstWeek = (int) $PHPDateObject->format('w');
$daysInFirstWeek = (6 - $firstDayOfFirstWeek + $method) % 7;
$daysInFirstWeek += 7 * !$daysInFirstWeek;
$endFirstWeek = $daysInFirstWeek - 1;
$weekOfYear = floor(($dayOfYear - $endFirstWeek + 13) / 7);
return (int) $weekOfYear;
}
/**
* Validate dateValue parameter.
*
* @param mixed $dateValue
*/
private static function validateDateValue($dateValue): float
{
if (is_bool($dateValue)) {
throw new Exception(Functions::VALUE());
}
return Helpers::getDateValue($dateValue);
}
/**
* Validate method parameter.
*
* @param mixed $method
*/
private static function validateMethod($method): int
{
if ($method === null) {
$method = Constants::STARTWEEK_SUNDAY;
}
$method = Functions::flattenSingleValue($method);
if (!is_numeric($method)) {
throw new Exception(Functions::VALUE());
}
$method = (int) $method;
if (!array_key_exists($method, Constants::METHODARR)) {
throw new Exception(Functions::NAN());
}
$method = Constants::METHODARR[$method];
return $method;
}
private static function buggyWeekNum1900(int $method): bool
{
return $method === Constants::DOW_SUNDAY && Date::getExcelCalendar() === Date::CALENDAR_WINDOWS_1900;
}
private static function buggyWeekNum1904(int $method, bool $origNull, DateTime $dateObject): bool
{
// This appears to be another Excel bug.
return $method === Constants::DOW_SUNDAY && Date::getExcelCalendar() === Date::CALENDAR_MAC_1904 && !$origNull && $dateObject->format('Y-m-d') === '1904-01-01';
}
}

View File

@ -2,9 +2,8 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class WorkDay
{
@ -24,11 +23,12 @@ class WorkDay
* @param int $endDays The number of nonweekend and nonholiday days before or after
* startDate. A positive value for days yields a future date; a
* negative value yields a past date.
* @param mixed $dateArgs
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function funcWorkDay($startDate, $endDays, ...$dateArgs)
public static function date($startDate, $endDays, ...$dateArgs)
{
// Retrieve the mandatory start date and days that are referenced in the function definition
try {
@ -65,8 +65,8 @@ class WorkDay
{
// Adjust the start date if it falls over a weekend
$startDoW = WeekDay::funcWeekDay($startDate, 3);
if (WeekDay::funcWeekDay($startDate, 3) >= 5) {
$startDoW = self::getWeekDay($startDate, 3);
if (self::getWeekDay($startDate, 3) >= 5) {
$startDate += 7 - $startDoW;
--$endDays;
}
@ -77,7 +77,7 @@ class WorkDay
while ($endDays > 0) {
++$endDate;
// Adjust the calculated end date if it falls over a weekend
$endDow = WeekDay::funcWeekDay($endDate, 3);
$endDow = self::getWeekDay($endDate, 3);
if ($endDow >= 5) {
$endDate += 7 - $endDow;
}
@ -96,7 +96,7 @@ class WorkDay
{
$holidayCountedArray = $holidayDates = [];
foreach ($holidayArray as $holidayDate) {
if (WeekDay::funcWeekDay($holidayDate, 3) < 5) {
if (self::getWeekDay($holidayDate, 3) < 5) {
$holidayDates[] = $holidayDate;
}
}
@ -109,7 +109,7 @@ class WorkDay
}
}
// Adjust the calculated end date if it falls over a weekend
$endDoW = WeekDay::funcWeekDay($endDate, 3);
$endDoW = self::getWeekDay($endDate, 3);
if ($endDoW >= 5) {
$endDate += 7 - $endDoW;
}
@ -127,9 +127,8 @@ class WorkDay
{
// Adjust the start date if it falls over a weekend
$startDoW = WeekDay::funcWeekDay($startDate, 3);
if (WeekDay::funcWeekDay($startDate, 3) >= 5) {
// @phpstan-ignore-next-line
$startDoW = self::getWeekDay($startDate, 3);
if (self::getWeekDay($startDate, 3) >= 5) {
$startDate += -$startDoW + 4;
++$endDays;
}
@ -140,7 +139,7 @@ class WorkDay
while ($endDays < 0) {
--$endDate;
// Adjust the calculated end date if it falls over a weekend
$endDow = WeekDay::funcWeekDay($endDate, 3);
$endDow = self::getWeekDay($endDate, 3);
if ($endDow >= 5) {
$endDate += 4 - $endDow;
}
@ -159,7 +158,7 @@ class WorkDay
{
$holidayCountedArray = $holidayDates = [];
foreach ($holidayArray as $holidayDate) {
if (WeekDay::funcWeekDay($holidayDate, 3) < 5) {
if (self::getWeekDay($holidayDate, 3) < 5) {
$holidayDates[] = $holidayDate;
}
}
@ -172,13 +171,19 @@ class WorkDay
}
}
// Adjust the calculated end date if it falls over a weekend
$endDoW = WeekDay::funcWeekDay($endDate, 3);
$endDoW = self::getWeekDay($endDate, 3);
if ($endDoW >= 5) {
// @phpstan-ignore-next-line
$endDate += -$endDoW + 4;
}
}
return $endDate;
}
private static function getWeekDay(float $date, int $wd): int
{
$result = Week::day($date, $wd);
return is_string($result) ? -1 : $result;
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class Year
{
/**
* YEAR.
*
* Returns the year corresponding to a date.
* The year is returned as an integer in the range 1900-9999.
*
* Excel Function:
* YEAR(dateValue)
*
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
* PHP DateTime object, or a standard date string
*
* @return int|string Year
*/
public static function funcYear($dateValue)
{
try {
$dateValue = Helpers::getDateValue($dateValue);
} catch (Exception $e) {
return $e->getMessage();
}
if ($dateValue < 1 && Date::getExcelCalendar() === DATE::CALENDAR_WINDOWS_1900) {
return 1900;
}
// Execute function
$PHPDateObject = Date::excelToDateTimeObject($dateValue);
return (int) $PHPDateObject->format('Y');
}
}

View File

@ -2,9 +2,9 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
class YearFrac
{
@ -34,7 +34,7 @@ class YearFrac
*
* @return float|string fraction of the year, or a string containing an error
*/
public static function funcYearFrac($startDate, $endDate, $method = 0)
public static function fraction($startDate, $endDate, $method = 0)
{
try {
$method = (int) Helpers::validateNumericNull($method);
@ -50,15 +50,15 @@ class YearFrac
switch ($method) {
case 0:
return Days360::funcDays360($startDate, $endDate) / 360;
return Days360::between($startDate, $endDate) / 360;
case 1:
return self::method1($startDate, $endDate);
case 2:
return DateDif::funcDateDif($startDate, $endDate) / 360;
return Difference::interval($startDate, $endDate) / 360;
case 3:
return DateDif::funcDateDif($startDate, $endDate) / 365;
return Difference::interval($startDate, $endDate) / 365;
case 4:
return Days360::funcDays360($startDate, $endDate, true) / 360;
return Days360::between($startDate, $endDate, true) / 360;
}
return Functions::NAN();
@ -72,9 +72,9 @@ class YearFrac
*/
private static function excelBug(float $sDate, $startDate, $endDate, int $method): float
{
if (Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_OPENOFFICE && Date::getExcelCalendar() !== Date::CALENDAR_MAC_1904) {
if (Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_OPENOFFICE && SharedDateHelper::getExcelCalendar() !== SharedDateHelper::CALENDAR_MAC_1904) {
if ($endDate === null && $startDate !== null) {
if (Month::funcMonth($sDate) == 12 && Day::funcDay($sDate) === 31 && $method === 0) {
if (DateParts::month($sDate) == 12 && DateParts::day($sDate) === 31 && $method === 0) {
$sDate += 2;
} else {
++$sDate;
@ -87,14 +87,14 @@ class YearFrac
private static function method1(float $startDate, float $endDate): float
{
$days = DateDif::funcDateDif($startDate, $endDate);
$startYear = Year::funcYear($startDate);
$endYear = Year::funcYear($endDate);
$days = Difference::interval($startDate, $endDate);
$startYear = (int) DateParts::year($startDate);
$endYear = (int) DateParts::year($endDate);
$years = $endYear - $startYear + 1;
$startMonth = Month::funcMonth($startDate);
$startDay = Day::funcDay($startDate);
$endMonth = Month::funcMonth($endDate);
$endDay = Day::funcDay($endDate);
$startMonth = (int) DateParts::month($startDate);
$startDay = (int) DateParts::day($startDate);
$endMonth = (int) DateParts::month($endDate);
$endDay = (int) DateParts::day($endDate);
$startMonthDay = 100 * $startMonth + $startDay;
$endMonthDay = 100 * $endMonth + $endDay;
if ($years == 1) {

View File

@ -70,7 +70,7 @@ class Amortization
return $e->getMessage();
}
$yearFrac = DateTimeExcel\YearFrac::funcYearFrac($purchased, $firstPeriod, $basis);
$yearFrac = DateTimeExcel\YearFrac::fraction($purchased, $firstPeriod, $basis);
if (is_string($yearFrac)) {
return $yearFrac;
}
@ -160,8 +160,8 @@ class Amortization
$fOneRate = $cost * $rate;
$fCostDelta = $cost - $salvage;
// Note, quirky variation for leap years on the YEARFRAC for this function
$purchasedYear = DateTimeExcel\Year::funcYear($purchased);
$yearFrac = DateTimeExcel\YearFrac::funcYearFrac($purchased, $firstPeriod, $basis);
$purchasedYear = DateTimeExcel\DateParts::year($purchased);
$yearFrac = DateTimeExcel\YearFrac::fraction($purchased, $firstPeriod, $basis);
if (is_string($yearFrac)) {
return $yearFrac;
}

View File

@ -196,10 +196,9 @@ class NonPeriodic
return $e->getMessage();
}
if ($date0 > $datei) {
/** @phpstan-ignore-next-line */
$dif = $ordered ? Functions::NAN() : -DateTimeExcel\DateDif::funcDateDif($datei, $date0, 'd');
$dif = $ordered ? Functions::NAN() : -((int) DateTimeExcel\Difference::interval($datei, $date0, 'd'));
} else {
$dif = DateTimeExcel\DateDif::funcDateDif($date0, $datei, 'd');
$dif = DateTimeExcel\Difference::interval($date0, $datei, 'd');
}
if (!is_numeric($dif)) {
return $dif;

View File

@ -63,17 +63,17 @@ class Coupons
return $e->getMessage();
}
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
if (is_string($daysPerYear)) {
return Functions::VALUE();
}
$prev = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_PREVIOUS);
if ($basis === FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL) {
return abs(DateTimeExcel\Days::funcDays($prev, $settlement));
return abs((float) DateTimeExcel\Days::between($prev, $settlement));
}
return DateTimeExcel\YearFrac::funcYearFrac($prev, $settlement, $basis) * $daysPerYear;
return DateTimeExcel\YearFrac::fraction($prev, $settlement, $basis) * $daysPerYear;
}
/**
@ -133,7 +133,7 @@ class Coupons
case FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL:
// Actual/actual
if ($frequency == FinancialConstants::FREQUENCY_ANNUAL) {
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
return $daysPerYear / $frequency;
}
@ -197,7 +197,7 @@ class Coupons
return $e->getMessage();
}
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
$next = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_NEXT);
if ($basis === FinancialConstants::BASIS_DAYS_PER_YEAR_NASD) {
@ -208,7 +208,7 @@ class Coupons
}
}
return DateTimeExcel\YearFrac::funcYearFrac($settlement, $next, $basis) * $daysPerYear;
return DateTimeExcel\YearFrac::fraction($settlement, $next, $basis) * $daysPerYear;
}
/**
@ -316,7 +316,7 @@ class Coupons
return $e->getMessage();
}
$yearsBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac(
$yearsBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction(
$settlement,
$maturity,
FinancialConstants::BASIS_DAYS_PER_YEAR_NASD

View File

@ -78,12 +78,12 @@ class AccruedInterest
return $e->getMessage();
}
$daysBetweenIssueAndSettlement = YearFrac::funcYearFrac($issue, $settlement, $basis);
$daysBetweenIssueAndSettlement = YearFrac::fraction($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error
return $daysBetweenIssueAndSettlement;
}
$daysBetweenFirstInterestAndSettlement = YearFrac::funcYearFrac($firstInterest, $settlement, $basis);
$daysBetweenFirstInterestAndSettlement = YearFrac::fraction($firstInterest, $settlement, $basis);
if (!is_numeric($daysBetweenFirstInterestAndSettlement)) {
// return date error
return $daysBetweenFirstInterestAndSettlement;
@ -140,7 +140,7 @@ class AccruedInterest
return $e->getMessage();
}
$daysBetweenIssueAndSettlement = YearFrac::funcYearFrac($issue, $settlement, $basis);
$daysBetweenIssueAndSettlement = YearFrac::fraction($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error
return $daysBetweenIssueAndSettlement;

View File

@ -134,7 +134,7 @@ class Price
return $e->getMessage();
}
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
@ -194,23 +194,23 @@ class Price
return $e->getMessage();
}
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::funcYearFrac($issue, $settlement, $basis);
$daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::fraction($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error
return $daysBetweenIssueAndSettlement;
}
$daysBetweenIssueAndSettlement *= $daysPerYear;
$daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($issue, $maturity, $basis);
$daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::fraction($issue, $maturity, $basis);
if (!is_numeric($daysBetweenIssueAndMaturity)) {
// return date error
return $daysBetweenIssueAndMaturity;
}
$daysBetweenIssueAndMaturity *= $daysPerYear;
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
@ -272,7 +272,7 @@ class Price
if ($investment <= 0) {
return Functions::NAN();
}
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;

View File

@ -63,7 +63,7 @@ class Rates
return Functions::NAN();
}
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
@ -126,7 +126,7 @@ class Rates
return Functions::NAN();
}
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;

View File

@ -57,11 +57,11 @@ class Yields
return $e->getMessage();
}
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
@ -122,23 +122,23 @@ class Yields
return $e->getMessage();
}
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::funcYearFrac($issue, $settlement, $basis);
$daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::fraction($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error
return $daysBetweenIssueAndSettlement;
}
$daysBetweenIssueAndSettlement *= $daysPerYear;
$daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($issue, $maturity, $basis);
$daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::fraction($issue, $maturity, $basis);
if (!is_numeric($daysBetweenIssueAndMaturity)) {
// return date error
return $daysBetweenIssueAndMaturity;
}
$daysBetweenIssueAndMaturity *= $daysPerYear;
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;

View File

@ -43,7 +43,7 @@ class TreasuryBill
$daysBetweenSettlementAndMaturity = $maturity - $settlement;
$daysPerYear = Helpers::daysPerYear(
DateTimeExcel\Year::funcYear($maturity),
DateTimeExcel\DateParts::year($maturity),
FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL
);
@ -88,7 +88,7 @@ class TreasuryBill
$daysBetweenSettlementAndMaturity = $maturity - $settlement;
$daysPerYear = Helpers::daysPerYear(
DateTimeExcel\Year::funcYear($maturity),
DateTimeExcel\DateParts::year($maturity),
FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL
);
@ -134,7 +134,7 @@ class TreasuryBill
$daysBetweenSettlementAndMaturity = $maturity - $settlement;
$daysPerYear = Helpers::daysPerYear(
DateTimeExcel\Year::funcYear($maturity),
DateTimeExcel\DateParts::year($maturity),
FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL
);

View File

@ -13,6 +13,9 @@ use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\VLookup;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
/**
* @deprecated 1.18.0
*/
class LookupRef
{
/**
@ -25,7 +28,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the cell() method in the LookupRef\Address class instead
* @see LookupRef\Address::cell()
* Use the cell() method in the LookupRef\Address class instead
*
* @param mixed $row Row number to use in the cell reference
* @param mixed $column Column number to use in the cell reference
@ -61,11 +65,12 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the COLUMN() method in the LookupRef\RowColumnInformation class instead
* @see LookupRef\RowColumnInformation::COLUMN()
* Use the COLUMN() method in the LookupRef\RowColumnInformation class instead
*
* @param null|array|string $cellAddress A reference to a range of cells for which you want the column numbers
*
* @return int|int[]
* @return int|int[]|string
*/
public static function COLUMN($cellAddress = null, ?Cell $cell = null)
{
@ -82,7 +87,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the COLUMNS() method in the LookupRef\RowColumnInformation class instead
* @see LookupRef\RowColumnInformation::COLUMNS()
* Use the COLUMNS() method in the LookupRef\RowColumnInformation class instead
*
* @param null|array|string $cellAddress An array or array formula, or a reference to a range of cells
* for which you want the number of columns
@ -109,7 +115,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the ROW() method in the LookupRef\RowColumnInformation class instead
* @see LookupRef\RowColumnInformation::ROW()
* Use the ROW() method in the LookupRef\RowColumnInformation class instead
*
* @param null|array|string $cellAddress A reference to a range of cells for which you want the row numbers
*
@ -130,7 +137,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the ROWS() method in the LookupRef\RowColumnInformation class instead
* @see LookupRef\RowColumnInformation::ROWS()
* Use the ROWS() method in the LookupRef\RowColumnInformation class instead
*
* @param null|array|string $cellAddress An array or array formula, or a reference to a range of cells
* for which you want the number of rows
@ -148,29 +156,20 @@ class LookupRef
* Excel Function:
* =HYPERLINK(linkURL,displayName)
*
* @Deprecated 1.18.0
*
* @see LookupRef\Hyperlink::set()
* Use the set() method in the LookupRef\Hyperlink class instead
*
* @param mixed $linkURL Expect string. Value to check, is also the value returned when no error
* @param mixed $displayName Expect string. Value to return when testValue is an error condition
* @param Cell $pCell The cell to set the hyperlink in
*
* @return mixed The value of $displayName (or $linkURL if $displayName was blank)
* @return string The value of $displayName (or $linkURL if $displayName was blank)
*/
public static function HYPERLINK($linkURL = '', $displayName = null, ?Cell $pCell = null)
{
$linkURL = ($linkURL === null) ? '' : Functions::flattenSingleValue($linkURL);
$displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName);
if ((!is_object($pCell)) || (trim($linkURL) == '')) {
return Functions::REF();
}
if ((is_object($displayName)) || trim($displayName) == '') {
$displayName = $linkURL;
}
$pCell->getHyperlink()->setUrl($linkURL);
$pCell->getHyperlink()->setTooltip($displayName);
return $displayName;
return LookupRef\Hyperlink::set($linkURL, $displayName, $pCell);
}
/**
@ -184,7 +183,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the INDIRECT() method in the LookupRef\Indirect class instead
* @see LookupRef\Indirect::INDIRECT()
* Use the INDIRECT() method in the LookupRef\Indirect class instead
*
* NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010
*
@ -192,8 +192,6 @@ class LookupRef
* @param Cell $pCell The current cell (containing this formula)
*
* @return array|string An array containing a cell or range of cells, or a string on error
*
* @TODO Support for the optional a1 parameter introduced in Excel 2010
*/
public static function INDIRECT($cellAddress, Cell $pCell)
{
@ -212,7 +210,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the OFFSET() method in the LookupRef\Offset class instead
* @see LookupRef\Offset::OFFSET()
* Use the OFFSET() method in the LookupRef\Offset class instead
*
* @param null|string $cellAddress The reference from which you want to base the offset.
* Reference must refer to a cell or range of adjacent cells;
@ -248,31 +247,16 @@ class LookupRef
* Excel Function:
* =CHOOSE(index_num, value1, [value2], ...)
*
* @Deprecated 1.18.0
*
* @see LookupRef\Selection::choose()
* Use the choose() method in the LookupRef\Selection class instead
*
* @return mixed The selected value
*/
public static function CHOOSE(...$chooseArgs)
{
$chosenEntry = Functions::flattenArray(array_shift($chooseArgs));
$entryCount = count($chooseArgs) - 1;
if (is_array($chosenEntry)) {
$chosenEntry = array_shift($chosenEntry);
}
if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) {
--$chosenEntry;
} else {
return Functions::VALUE();
}
$chosenEntry = floor($chosenEntry);
if (($chosenEntry < 0) || ($chosenEntry > $entryCount)) {
return Functions::VALUE();
}
if (is_array($chooseArgs[$chosenEntry])) {
return Functions::flattenArray($chooseArgs[$chosenEntry]);
}
return $chooseArgs[$chosenEntry];
return LookupRef\Selection::choose(...$chooseArgs);
}
/**
@ -285,7 +269,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the MATCH() method in the LookupRef\ExcelMatch class instead
* @see LookupRef\ExcelMatch::MATCH()
* Use the MATCH() method in the LookupRef\ExcelMatch class instead
*
* @param mixed $lookupValue The value that you want to match in lookup_array
* @param mixed $lookupArray The range of cells being searched
@ -309,7 +294,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the index() method in the LookupRef\Matrix class instead
* @see LookupRef\Matrix::index()
* Use the index() method in the LookupRef\Matrix class instead
*
* @param mixed $rowNum The row in the array or range from which to return a value.
* If row_num is omitted, column_num is required.
@ -329,7 +315,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the transpose() method in the LookupRef\Matrix class instead
* @see LookupRef\Matrix::transpose()
* Use the transpose() method in the LookupRef\Matrix class instead
*
* @param array $matrixData A matrix of values
*
@ -350,7 +337,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the lookup() method in the LookupRef\VLookup class instead
* @see LookupRef\VLookup::lookup()
* Use the lookup() method in the LookupRef\VLookup class instead
*
* @param mixed $lookup_value The value that you want to match in lookup_array
* @param mixed $lookup_array The range of cells being searched
@ -372,7 +360,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the lookup() method in the LookupRef\HLookup class instead
* @see LookupRef\HLookup::lookup()
* Use the lookup() method in the LookupRef\HLookup class instead
*
* @param mixed $lookup_value The value that you want to match in lookup_array
* @param mixed $lookup_array The range of cells being searched
@ -393,7 +382,8 @@ class LookupRef
*
* @Deprecated 1.18.0
*
* @see Use the lookup() method in the LookupRef\Lookup class instead
* @see LookupRef\Lookup::lookup()
* Use the lookup() method in the LookupRef\Lookup class instead
*
* @param mixed $lookup_value The value that you want to match in lookup_array
* @param mixed $lookup_vector The range of cells being searched
@ -409,6 +399,11 @@ class LookupRef
/**
* FORMULATEXT.
*
* @Deprecated 1.18.0
*
* @see LookupRef\Formula::text()
* Use the text() method in the LookupRef\Formula class instead
*
* @param mixed $cellReference The cell to check
* @param Cell $pCell The current cell (containing this formula)
*
@ -416,22 +411,6 @@ class LookupRef
*/
public static function FORMULATEXT($cellReference = '', ?Cell $pCell = null)
{
if ($pCell === null) {
return Functions::REF();
}
preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellReference, $matches);
$cellReference = $matches[6] . $matches[7];
$worksheetName = trim($matches[3], "'");
$worksheet = (!empty($worksheetName))
? $pCell->getWorksheet()->getParent()->getSheetByName($worksheetName)
: $pCell->getWorksheet();
if (!$worksheet->getCell($cellReference)->isFormula()) {
return Functions::NA();
}
return $worksheet->getCell($cellReference)->getValue();
return LookupRef\Formula::text($cellReference, $pCell);
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
class Formula
{
/**
* FORMULATEXT.
*
* @param mixed $cellReference The cell to check
* @param Cell $pCell The current cell (containing this formula)
*
* @return string
*/
public static function text($cellReference = '', ?Cell $pCell = null)
{
if ($pCell === null) {
return Functions::REF();
}
preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellReference, $matches);
$cellReference = $matches[6] . $matches[7];
$worksheetName = trim($matches[3], "'");
$worksheet = (!empty($worksheetName))
? $pCell->getWorksheet()->getParent()->getSheetByName($worksheetName)
: $pCell->getWorksheet();
if (
$worksheet === null ||
!$worksheet->cellExists($cellReference) ||
!$worksheet->getCell($cellReference)->isFormula()
) {
return Functions::NA();
}
return $worksheet->getCell($cellReference)->getValue();
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
class Hyperlink
{
/**
* HYPERLINK.
*
* Excel Function:
* =HYPERLINK(linkURL, [displayName])
*
* @param mixed $linkURL Expect string. Value to check, is also the value returned when no error
* @param mixed $displayName Expect string. Value to return when testValue is an error condition
* @param Cell $pCell The cell to set the hyperlink in
*
* @return mixed The value of $displayName (or $linkURL if $displayName was blank)
*/
public static function set($linkURL = '', $displayName = null, ?Cell $pCell = null)
{
$linkURL = ($linkURL === null) ? '' : Functions::flattenSingleValue($linkURL);
$displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName);
if ((!is_object($pCell)) || (trim($linkURL) == '')) {
return Functions::REF();
}
if ((is_object($displayName)) || trim($displayName) == '') {
$displayName = $linkURL;
}
$pCell->getHyperlink()->setUrl($linkURL);
$pCell->getHyperlink()->setTooltip($displayName);
return $displayName;
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class LookupRefValidations
{
/**
* @param mixed $value
*/
public static function validateInt($value): int
{
if (!is_numeric($value)) {
if (Functions::isError($value)) {
throw new Exception($value);
}
throw new Exception(Functions::VALUE());
}
return (int) floor((float) $value);
}
/**
* @param mixed $value
*/
public static function validatePositiveInt($value, bool $allowZero = true): int
{
$value = self::validateInt($value);
if (($allowZero === false && $value <= 0) || $value < 0) {
throw new Exception(Functions::VALUE());
}
return $value;
}
}

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Matrix
@ -39,7 +40,7 @@ class Matrix
* Uses an index to choose a value from a reference or array
*
* Excel Function:
* =INDEX(range_array, row_num, [column_num])
* =INDEX(range_array, row_num, [column_num], [area_num])
*
* @param mixed $matrix A range of cells or an array constant
* @param mixed $rowNum The row in the array or range from which to return a value.
@ -47,15 +48,20 @@ class Matrix
* @param mixed $columnNum The column in the array or range from which to return a value.
* If column_num is omitted, row_num is required.
*
* TODO Provide support for area_num, currently not supported
*
* @return mixed the value of a specified cell or array of cells
*/
public static function index($matrix, $rowNum = 0, $columnNum = 0)
{
$rowNum = Functions::flattenSingleValue($rowNum);
$columnNum = Functions::flattenSingleValue($columnNum);
$rowNum = ($rowNum === null) ? 0 : Functions::flattenSingleValue($rowNum);
$columnNum = ($columnNum === null) ? 0 : Functions::flattenSingleValue($columnNum);
if (!is_numeric($rowNum) || !is_numeric($columnNum) || ($rowNum < 0) || ($columnNum < 0)) {
return Functions::VALUE();
try {
$rowNum = LookupRefValidations::validatePositiveInt($rowNum);
$columnNum = LookupRefValidations::validatePositiveInt($columnNum);
} catch (Exception $e) {
return $e->getMessage();
}
if (!is_array($matrix) || ($rowNum > count($matrix))) {
@ -69,12 +75,12 @@ class Matrix
return Functions::REF();
}
if ($columnNum == 0) {
if ($columnNum === 0) {
return self::extractRowValue($matrix, $rowKeys, $rowNum);
}
$columnNum = $columnKeys[--$columnNum];
if ($rowNum == 0) {
if ($rowNum === 0) {
return array_map(
function ($value) {
return [$value];
@ -89,7 +95,7 @@ class Matrix
private static function extractRowValue(array $matrix, array $rowKeys, int $rowNum)
{
if ($rowNum == 0) {
if ($rowNum === 0) {
return $matrix;
}

View File

@ -0,0 +1,46 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Selection
{
/**
* CHOOSE.
*
* Uses lookup_value to return a value from the list of value arguments.
* Use CHOOSE to select one of up to 254 values based on the lookup_value.
*
* Excel Function:
* =CHOOSE(index_num, value1, [value2], ...)
*
* @param mixed ...$chooseArgs Data values
*
* @return mixed The selected value
*/
public static function choose(...$chooseArgs)
{
$chosenEntry = Functions::flattenArray(array_shift($chooseArgs));
$entryCount = count($chooseArgs) - 1;
if (is_array($chosenEntry)) {
$chosenEntry = array_shift($chosenEntry);
}
if (is_numeric($chosenEntry)) {
--$chosenEntry;
} else {
return Functions::VALUE();
}
$chosenEntry = floor($chosenEntry);
if (($chosenEntry < 0) || ($chosenEntry > $entryCount)) {
return Functions::VALUE();
}
if (is_array($chooseArgs[$chosenEntry])) {
return Functions::flattenArray($chooseArgs[$chosenEntry]);
}
return $chooseArgs[$chosenEntry];
}
}

View File

@ -2,6 +2,9 @@
namespace PhpOffice\PhpSpreadsheet\Calculation;
/**
* @deprecated 1.18.0
*/
class MathTrig
{
/**
@ -44,8 +47,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Atan2::evaluate()
* Use the evaluate method in the MathTrig\Atan2 class instead
* @See MathTrig\Trig\Tangent::atan2()
* Use the atan2 method in the MathTrig\Trig\Tangent class instead
*
* @param float $xCoordinate the x-coordinate of the point
* @param float $yCoordinate the y-coordinate of the point
@ -54,7 +57,7 @@ class MathTrig
*/
public static function ATAN2($xCoordinate = null, $yCoordinate = null)
{
return MathTrig\Atan2::evaluate($xCoordinate, $yCoordinate);
return MathTrig\Trig\Tangent::atan2($xCoordinate, $yCoordinate);
}
/**
@ -94,17 +97,17 @@ class MathTrig
*
* @Deprecated 1.17.0
*
* @see MathTrig\Ceiling::evaluate()
* Use the evaluate() method in the MathTrig\Ceiling class instead
*
* @param float $number the number you want to round
* @param float $significance the multiple to which you want to round
*
* @return float|string Rounded Number, or a string containing an error
*
* @see MathTrig\Ceiling::ceiling()
* Use the ceiling() method in the MathTrig\Ceiling class instead
*/
public static function CEILING($number, $significance = null)
{
return MathTrig\Ceiling::evaluate($number, $significance);
return MathTrig\Ceiling::ceiling($number, $significance);
}
/**
@ -124,7 +127,7 @@ class MathTrig
* @param int $numObjs Number of different objects
* @param int $numInSet Number of objects in each combination
*
* @return int|string Number of combinations, or a string containing an error
* @return float|int|string Number of combinations, or a string containing an error
*/
public static function COMBIN($numObjs, $numInSet)
{
@ -145,16 +148,16 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @see MathTrig\Even::evaluate()
* Use the evaluate() method in the MathTrig\Even class instead
* @see MathTrig\Round::even()
* Use the even() method in the MathTrig\Round class instead
*
* @param float $number Number to round
*
* @return int|string Rounded Number, or a string containing an error
* @return float|int|string Rounded Number, or a string containing an error
*/
public static function EVEN($number)
{
return MathTrig\Even::evaluate($number);
return MathTrig\Round::even($number);
}
/**
@ -181,16 +184,16 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @see MathTrig\Fact::evaluate()
* Use the evaluate() method in the MathTrig\Fact class instead
*
* @param float $factVal Factorial Value
*
* @return int|string Factorial, or a string containing an error
* @return float|int|string Factorial, or a string containing an error
*
*@see MathTrig\Factorial::fact()
* Use the fact() method in the MathTrig\Factorial class instead
*/
public static function FACT($factVal)
{
return MathTrig\Fact::evaluate($factVal);
return MathTrig\Factorial::fact($factVal);
}
/**
@ -203,16 +206,16 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @see MathTrig\FactDouble::evaluate()
* Use the evaluate() method in the MathTrig\FactDouble class instead
*
* @param float $factVal Factorial Value
*
* @return int|string Double Factorial, or a string containing an error
* @return float|int|string Double Factorial, or a string containing an error
*
*@see MathTrig\Factorial::factDouble()
* Use the factDouble() method in the MathTrig\Factorial class instead
*/
public static function FACTDOUBLE($factVal)
{
return MathTrig\FactDouble::evaluate($factVal);
return MathTrig\Factorial::factDouble($factVal);
}
/**
@ -225,17 +228,17 @@ class MathTrig
*
* @Deprecated 1.17.0
*
* @see MathTrig\Floor::evaluate()
* Use the evaluate() method in the MathTrig\Floor class instead
*
* @param float $number Number to round
* @param float $significance Significance
*
* @return float|string Rounded Number, or a string containing an error
*
*@see MathTrig\Floor::floor()
* Use the floor() method in the MathTrig\Floor class instead
*/
public static function FLOOR($number, $significance = null)
{
return MathTrig\Floor::evaluate($number, $significance);
return MathTrig\Floor::floor($number, $significance);
}
/**
@ -248,18 +251,18 @@ class MathTrig
*
* @Deprecated 1.17.0
*
* @see MathTrig\FloorMath::evaluate()
* Use the evaluate() method in the MathTrig\FloorMath class instead
*
* @param float $number Number to round
* @param float $significance Significance
* @param int $mode direction to round negative numbers
*
* @return float|string Rounded Number, or a string containing an error
*
*@see MathTrig\Floor::math()
* Use the math() method in the MathTrig\Floor class instead
*/
public static function FLOORMATH($number, $significance = null, $mode = 0)
{
return MathTrig\FloorMath::evaluate($number, $significance, $mode);
return MathTrig\Floor::math($number, $significance, $mode);
}
/**
@ -272,17 +275,17 @@ class MathTrig
*
* @Deprecated 1.17.0
*
* @see MathTrig\FloorPrecise::evaluate()
* Use the evaluate() method in the MathTrig\FloorPrecise class instead
*
* @param float $number Number to round
* @param float $significance Significance
*
* @return float|string Rounded Number, or a string containing an error
*
*@see MathTrig\Floor::precise()
* Use the precise() method in the MathTrig\Floor class instead
*/
public static function FLOORPRECISE($number, $significance = 1)
{
return MathTrig\FloorPrecise::evaluate($number, $significance);
return MathTrig\Floor::precise($number, $significance);
}
/**
@ -446,17 +449,17 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @see MathTrig\Mod::evaluate()
* Use the evaluate() method in the MathTrig\Mod class instead
* @see MathTrig\Operations::mod()
* Use the mod() method in the MathTrig\Operations class instead
*
* @param int $a Dividend
* @param int $b Divisor
*
* @return int|string Remainder, or a string containing an error
* @return float|int|string Remainder, or a string containing an error
*/
public static function MOD($a = 1, $b = 1)
{
return MathTrig\Mod::evaluate($a, $b);
return MathTrig\Operations::mod($a, $b);
}
/**
@ -466,17 +469,17 @@ class MathTrig
*
* @Deprecated 1.17.0
*
* @see MathTrig\Mround::evaluate()
* Use the evaluate() method in the MathTrig\Mround class instead
*
* @param float $number Number to round
* @param int $multiple Multiple to which you want to round $number
*
* @return float|string Rounded Number, or a string containing an error
*
*@see MathTrig\Round::multiple()
* Use the multiple() method in the MathTrig\Mround class instead
*/
public static function MROUND($number, $multiple)
{
return MathTrig\Mround::evaluate($number, $multiple);
return MathTrig\Round::multiple($number, $multiple);
}
/**
@ -486,8 +489,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Multinomial::evaluate()
* Use the evaluate method in the MathTrig\Multinomial class instead
* @See MathTrig\Factorial::multinomial()
* Use the multinomial method in the MathTrig\Factorial class instead
*
* @param mixed[] $args An array of mixed values for the Data Series
*
@ -495,7 +498,7 @@ class MathTrig
*/
public static function MULTINOMIAL(...$args)
{
return MathTrig\Multinomial::evaluate(...$args);
return MathTrig\Factorial::multinomial(...$args);
}
/**
@ -505,16 +508,16 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Odd::evaluate()
* Use the evaluate method in the MathTrig\Odd class instead
* @See MathTrig\Round::odd()
* Use the odd method in the MathTrig\Round class instead
*
* @param float $number Number to round
*
* @return int|string Rounded Number, or a string containing an error
* @return float|int|string Rounded Number, or a string containing an error
*/
public static function ODD($number)
{
return MathTrig\Odd::evaluate($number);
return MathTrig\Round::odd($number);
}
/**
@ -524,7 +527,7 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Power::evaluate()
* @See MathTrig\Operations::power()
* Use the evaluate method in the MathTrig\Power class instead
*
* @param float $x
@ -534,7 +537,7 @@ class MathTrig
*/
public static function POWER($x = 0, $y = 2)
{
return MathTrig\Power::evaluate($x, $y);
return MathTrig\Operations::power($x, $y);
}
/**
@ -544,8 +547,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Product::evaluate()
* Use the evaluate method in the MathTrig\Product class instead
* @See MathTrig\Operations::product()
* Use the product method in the MathTrig\Operations class instead
*
* Excel Function:
* PRODUCT(value1[,value2[, ...]])
@ -556,7 +559,7 @@ class MathTrig
*/
public static function PRODUCT(...$args)
{
return MathTrig\Product::evaluate(...$args);
return MathTrig\Operations::product(...$args);
}
/**
@ -567,8 +570,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Quotient::evaluate()
* Use the evaluate method in the MathTrig\Quotient class instead
* @See MathTrig\Operations::quotient()
* Use the quotient method in the MathTrig\Operations class instead
*
* Excel Function:
* QUOTIENT(value1[,value2[, ...]])
@ -580,7 +583,7 @@ class MathTrig
*/
public static function QUOTIENT($numerator, $denominator)
{
return MathTrig\Quotient::evaluate($numerator, $denominator);
return MathTrig\Operations::quotient($numerator, $denominator);
}
/**
@ -628,8 +631,8 @@ class MathTrig
*
* @Deprecated 1.17.0
*
* @See MathTrig\RoundUp::evaluate()
* Use the evaluate() method in the MathTrig\RoundUp class instead
* @See MathTrig\Round::up()
* Use the up() method in the MathTrig\Round class instead
*
* @param float $number Number to round
* @param int $digits Number of digits to which you want to round $number
@ -638,7 +641,7 @@ class MathTrig
*/
public static function ROUNDUP($number, $digits)
{
return MathTrig\RoundUp::evaluate($number, $digits);
return MathTrig\Round::up($number, $digits);
}
/**
@ -648,8 +651,8 @@ class MathTrig
*
* @Deprecated 1.17.0
*
* @See MathTrig\RoundDown::evaluate()
* Use the evaluate() method in the MathTrig\RoundDown class instead
* @See MathTrig\Round::down()
* Use the down() method in the MathTrig\Round class instead
*
* @param float $number Number to round
* @param int $digits Number of digits to which you want to round $number
@ -658,7 +661,7 @@ class MathTrig
*/
public static function ROUNDDOWN($number, $digits)
{
return MathTrig\RoundDown::evaluate($number, $digits);
return MathTrig\Round::down($number, $digits);
}
/**
@ -723,8 +726,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\SqrtPi::evaluate()
* Use the evaluate method in the MathTrig\SqrtPi class instead
* @See MathTrig\Sqrt::sqrt()
* Use the pi method in the MathTrig\Sqrt class instead
*
* @param float $number Number
*
@ -732,7 +735,7 @@ class MathTrig
*/
public static function SQRTPI($number)
{
return MathTrig\SqrtPi::evaluate($number);
return MathTrig\Sqrt::pi($number);
}
/**
@ -768,8 +771,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Sum::funcSumNoStrings()
* Use the funcSumNoStrings method in the MathTrig\Sum class instead
* @See MathTrig\Sum::sumErroringStrings()
* Use the sumErroringStrings method in the MathTrig\Sum class instead
*
* Excel Function:
* SUM(value1[,value2[, ...]])
@ -780,7 +783,7 @@ class MathTrig
*/
public static function SUM(...$args)
{
return MathTrig\Sum::funcSum(...$args);
return MathTrig\Sum::sumIgnoringStrings(...$args);
}
/**
@ -822,7 +825,7 @@ class MathTrig
*
* @param mixed $args Data values
*
* @return float|string
* @return null|float|string
*/
public static function SUMIFS(...$args)
{
@ -837,8 +840,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\SumProduct::evaluate()
* Use the evaluate method in the MathTrig\SumProduct class instead
* @See MathTrig\Sum::product()
* Use the product method in the MathTrig\Sum class instead
*
* @param mixed ...$args Data values
*
@ -846,7 +849,7 @@ class MathTrig
*/
public static function SUMPRODUCT(...$args)
{
return MathTrig\SumProduct::evaluate(...$args);
return MathTrig\Sum::product(...$args);
}
/**
@ -952,8 +955,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Sec::evaluate()
* Use the evaluate method in the MathTrig\Sec class instead
* @See MathTrig\Trig\Secant::sec()
* Use the sec method in the MathTrig\Trig\Secant class instead
*
* @param float $angle Number
*
@ -961,7 +964,7 @@ class MathTrig
*/
public static function SEC($angle)
{
return MathTrig\Sec::evaluate($angle);
return MathTrig\Trig\Secant::sec($angle);
}
/**
@ -971,8 +974,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\SecH::evaluate()
* Use the evaluate method in the MathTrig\Sech class instead
* @See MathTrig\Trig\Secant::sech()
* Use the sech method in the MathTrig\Trig\Secant class instead
*
* @param float $angle Number
*
@ -980,7 +983,7 @@ class MathTrig
*/
public static function SECH($angle)
{
return MathTrig\Sech::evaluate($angle);
return MathTrig\Trig\Secant::sech($angle);
}
/**
@ -990,8 +993,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Csc::evaluate()
* Use the evaluate method in the MathTrig\Csc class instead
* @See MathTrig\Trig\Cosecant::csc()
* Use the csc method in the MathTrig\Trig\Cosecant class instead
*
* @param float $angle Number
*
@ -999,7 +1002,7 @@ class MathTrig
*/
public static function CSC($angle)
{
return MathTrig\Csc::evaluate($angle);
return MathTrig\Trig\Cosecant::csc($angle);
}
/**
@ -1009,8 +1012,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Csch::evaluate()
* Use the evaluate method in the MathTrig\Csch class instead
* @See MathTrig\Trig\Cosecant::csch()
* Use the csch method in the MathTrig\Trig\Cosecant class instead
*
* @param float $angle Number
*
@ -1018,7 +1021,7 @@ class MathTrig
*/
public static function CSCH($angle)
{
return MathTrig\Csch::evaluate($angle);
return MathTrig\Trig\Cosecant::csch($angle);
}
/**
@ -1028,8 +1031,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Cot::evaluate()
* Use the evaluate method in the MathTrig\Cot class instead
* @See MathTrig\Trig\Cotangent::cot()
* Use the cot method in the MathTrig\Trig\Cotangent class instead
*
* @param float $angle Number
*
@ -1037,7 +1040,7 @@ class MathTrig
*/
public static function COT($angle)
{
return MathTrig\Cot::evaluate($angle);
return MathTrig\Trig\Cotangent::cot($angle);
}
/**
@ -1047,8 +1050,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Coth::evaluate()
* Use the evaluate method in the MathTrig\Coth class instead
* @See MathTrig\Trig\Cotangent::coth()
* Use the coth method in the MathTrig\Trig\Cotangent class instead
*
* @param float $angle Number
*
@ -1056,7 +1059,7 @@ class MathTrig
*/
public static function COTH($angle)
{
return MathTrig\Coth::evaluate($angle);
return MathTrig\Trig\Cotangent::coth($angle);
}
/**
@ -1066,8 +1069,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Acot::evaluate()
* Use the evaluate method in the MathTrig\Acot class instead
* @See MathTrig\Trig\Cotangent::acot()
* Use the acot method in the MathTrig\Trig\Cotangent class instead
*
* @param float $number Number
*
@ -1075,7 +1078,7 @@ class MathTrig
*/
public static function ACOT($number)
{
return MathTrig\Acot::evaluate($number);
return MathTrig\Trig\Cotangent::acot($number);
}
/**
@ -1102,8 +1105,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Acoth::evaluate()
* Use the evaluate method in the MathTrig\Acoth class instead
* @See MathTrig\Trig\Cotangent::acoth()
* Use the acoth method in the MathTrig\Trig\Cotangent class instead
*
* @param float $number Number
*
@ -1111,7 +1114,7 @@ class MathTrig
*/
public static function ACOTH($number)
{
return MathTrig\Acoth::evaluate($number);
return MathTrig\Trig\Cotangent::acoth($number);
}
/**
@ -1121,8 +1124,8 @@ class MathTrig
*
* @Deprecated 1.17.0
*
* @See MathTrig\Round::evaluate()
* Use the evaluate() method in the MathTrig\Round class instead
* @See MathTrig\Round::round()
* Use the round() method in the MathTrig\Round class instead
*
* @param mixed $number Should be numeric
* @param mixed $precision Should be int
@ -1131,7 +1134,7 @@ class MathTrig
*/
public static function builtinROUND($number, $precision)
{
return MathTrig\Round::evaluate($number, $precision);
return MathTrig\Round::round($number, $precision);
}
/**
@ -1158,8 +1161,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Acos::evaluate()
* Use the evaluate method in the MathTrig\Acos class instead
* @See MathTrig\Trig\Cosine::acos()
* Use the acos method in the MathTrig\Trig\Cosine class instead
*
* Returns the result of builtin function acos after validating args.
*
@ -1169,7 +1172,7 @@ class MathTrig
*/
public static function builtinACOS($number)
{
return MathTrig\Acos::evaluate($number);
return MathTrig\Trig\Cosine::acos($number);
}
/**
@ -1179,8 +1182,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Acosh::evaluate()
* Use the evaluate method in the MathTrig\Acosh class instead
* @See MathTrig\Trig\Cosine::acosh()
* Use the acosh method in the MathTrig\Trig\Cosine class instead
*
* @param mixed $number Should be numeric
*
@ -1188,7 +1191,7 @@ class MathTrig
*/
public static function builtinACOSH($number)
{
return MathTrig\Acosh::evaluate($number);
return MathTrig\Trig\Cosine::acosh($number);
}
/**
@ -1198,8 +1201,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Asin::evaluate()
* Use the evaluate method in the MathTrig\Asin class instead
* @See MathTrig\Trig\Sine::asin()
* Use the asin method in the MathTrig\Trig\Sine class instead
*
* @param mixed $number Should be numeric
*
@ -1207,7 +1210,7 @@ class MathTrig
*/
public static function builtinASIN($number)
{
return MathTrig\Asin::evaluate($number);
return MathTrig\Trig\Sine::asin($number);
}
/**
@ -1217,8 +1220,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Asinh::evaluate()
* Use the evaluate method in the MathTrig\Asinh class instead
* @See MathTrig\Trig\Sine::asinh()
* Use the asinh method in the MathTrig\Trig\Sine class instead
*
* @param mixed $number Should be numeric
*
@ -1226,7 +1229,7 @@ class MathTrig
*/
public static function builtinASINH($number)
{
return MathTrig\Asinh::evaluate($number);
return MathTrig\Trig\Sine::asinh($number);
}
/**
@ -1236,8 +1239,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Atan::evaluate()
* Use the evaluate method in the MathTrig\Atan class instead
* @See MathTrig\Trig\Tangent::atan()
* Use the atan method in the MathTrig\Trig\Tangent class instead
*
* @param mixed $number Should be numeric
*
@ -1245,7 +1248,7 @@ class MathTrig
*/
public static function builtinATAN($number)
{
return MathTrig\Atan::evaluate($number);
return MathTrig\Trig\Tangent::atan($number);
}
/**
@ -1255,8 +1258,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Atanh::evaluate()
* Use the evaluate method in the MathTrig\Atanh class instead
* @See MathTrig\Trig\Tangent::atanh()
* Use the atanh method in the MathTrig\Trig\Tangent class instead
*
* @param mixed $number Should be numeric
*
@ -1264,7 +1267,7 @@ class MathTrig
*/
public static function builtinATANH($number)
{
return MathTrig\Atanh::evaluate($number);
return MathTrig\Trig\Tangent::atanh($number);
}
/**
@ -1274,8 +1277,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Cos::evaluate()
* Use the evaluate method in the MathTrig\Cos class instead
* @See MathTrig\Trig\Cosine::cos()
* Use the cos method in the MathTrig\Trig\Cosine class instead
*
* @param mixed $number Should be numeric
*
@ -1283,7 +1286,7 @@ class MathTrig
*/
public static function builtinCOS($number)
{
return MathTrig\Cos::evaluate($number);
return MathTrig\Trig\Cosine::cos($number);
}
/**
@ -1293,8 +1296,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Cosh::evaluate()
* Use the evaluate method in the MathTrig\Cosh class instead
* @See MathTrig\Trig\Cosine::cosh()
* Use the cosh method in the MathTrig\Trig\Cosine class instead
*
* @param mixed $number Should be numeric
*
@ -1302,7 +1305,7 @@ class MathTrig
*/
public static function builtinCOSH($number)
{
return MathTrig\Cosh::evaluate($number);
return MathTrig\Trig\Cosine::cosh($number);
}
/**
@ -1312,8 +1315,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Degrees::evaluate()
* Use the evaluate method in the MathTrig\Degrees class instead
* @See MathTrig\Angle::toDegrees()
* Use the toDegrees method in the MathTrig\Angle class instead
*
* @param mixed $number Should be numeric
*
@ -1321,7 +1324,7 @@ class MathTrig
*/
public static function builtinDEGREES($number)
{
return MathTrig\Degrees::evaluate($number);
return MathTrig\Angle::toDegrees($number);
}
/**
@ -1388,8 +1391,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Radians::evaluate()
* Use the evaluate method in the MathTrig\Radians class instead
* @See MathTrig\Angle::toRadians()
* Use the toRadians method in the MathTrig\Angle class instead
*
* @param mixed $number Should be numeric
*
@ -1397,7 +1400,7 @@ class MathTrig
*/
public static function builtinRADIANS($number)
{
return MathTrig\Radians::evaluate($number);
return MathTrig\Angle::toRadians($number);
}
/**
@ -1407,16 +1410,16 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Sin::evaluate()
* Use the evaluate method in the MathTrig\Sin class instead
* @See MathTrig\Trig\Sine::evaluate()
* Use the sin method in the MathTrig\Trig\Sine class instead
*
* @param mixed $number Should be numeric
*
* @return float|string Rounded number
* @return float|string sine
*/
public static function builtinSIN($number)
{
return MathTrig\Sin::evaluate($number);
return MathTrig\Trig\Sine::sin($number);
}
/**
@ -1426,8 +1429,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Sinh::evaluate()
* Use the evaluate method in the MathTrig\Sinh class instead
* @See MathTrig\Trig\Sine::sinh()
* Use the sinh method in the MathTrig\Trig\Sine class instead
*
* @param mixed $number Should be numeric
*
@ -1435,7 +1438,7 @@ class MathTrig
*/
public static function builtinSINH($number)
{
return MathTrig\Sinh::evaluate($number);
return MathTrig\Trig\Sine::sinh($number);
}
/**
@ -1445,8 +1448,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Sqrt::evaluate()
* Use the evaluate method in the MathTrig\Sqrt class instead
* @See MathTrig\Sqrt::sqrt()
* Use the sqrt method in the MathTrig\Sqrt class instead
*
* @param mixed $number Should be numeric
*
@ -1454,7 +1457,7 @@ class MathTrig
*/
public static function builtinSQRT($number)
{
return MathTrig\Sqrt::evaluate($number);
return MathTrig\Sqrt::sqrt($number);
}
/**
@ -1464,8 +1467,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Tan::evaluate()
* Use the evaluate method in the MathTrig\Tan class instead
* @See MathTrig\Trig\Tangent::tan()
* Use the tan method in the MathTrig\Trig\Tangent class instead
*
* @param mixed $number Should be numeric
*
@ -1473,7 +1476,7 @@ class MathTrig
*/
public static function builtinTAN($number)
{
return MathTrig\Tan::evaluate($number);
return MathTrig\Trig\Tangent::tan($number);
}
/**
@ -1483,8 +1486,8 @@ class MathTrig
*
* @Deprecated 1.18.0
*
* @See MathTrig\Tan::evaluate()
* Use the evaluate method in the MathTrig\Tanh class instead
* @See MathTrig\Trig\Tangent::tanh()
* Use the tanh method in the MathTrig\Trig\Tangent class instead
*
* @param mixed $number Should be numeric
*
@ -1492,7 +1495,7 @@ class MathTrig
*/
public static function builtinTANH($number)
{
return MathTrig\Tanh::evaluate($number);
return MathTrig\Trig\Tangent::tanh($number);
}
/**

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
class Absolute
{

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Acos
{
/**
* ACOS.
*
* Returns the arccosine of a number.
*
* @param float $number Number
*
* @return float|string The arccosine of the number
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::numberOrNan(acos($number));
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Acosh
{
/**
* ACOSH.
*
* Returns the arc hyperbolic cosine of a number.
*
* @param float $number Number
*
* @return float|string The arccosine of the number, or an error string
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::numberOrNan(acosh($number));
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Acot
{
/**
* ACOT.
*
* Returns the arccotangent of a number.
*
* @param float $number Number
*
* @return float|string The arccotangent of the number
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return (M_PI / 2) - atan($number);
}
}

View File

@ -1,30 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Acoth
{
/**
* ACOTH.
*
* Returns the hyperbolic arccotangent of a number.
*
* @param float $number Number
*
* @return float|string The hyperbolic arccotangent of the number
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
$result = ($number === 1) ? NAN : (log(($number + 1) / ($number - 1)) / 2);
return Helpers::numberOrNan($result);
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
class Angle
{
/**
* DEGREES.
*
* Returns the result of builtin function rad2deg after validating args.
*
* @param mixed $number Should be numeric
*
* @return float|string Rounded number
*/
public static function toDegrees($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return rad2deg($number);
}
/**
* RADIANS.
*
* Returns the result of builtin function deg2rad after validating args.
*
* @param mixed $number Should be numeric
*
* @return float|string Rounded number
*/
public static function toRadians($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return deg2rad($number);
}
}

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Arabic
@ -47,11 +47,19 @@ class Arabic
return $sum;
}
/**
* @param mixed $value
*/
private static function mollifyScrutinizer($value): array
{
return is_array($value) ? $value : [];
}
private static function strSplit(string $roman): array
{
$rslt = str_split($roman);
return is_array($rslt) ? $rslt : [];
return self::mollifyScrutinizer($rslt);
}
/**

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Asin
{
/**
* ASIN.
*
* Returns the arcsine of a number.
*
* @param float $number Number
*
* @return float|string The arcsine of the number
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::numberOrNan(asin($number));
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Asinh
{
/**
* ASINH.
*
* Returns the arc hyperbolic sine of a number.
*
* @param float $number Number
*
* @return float|string The arc hyperbolic sine of the number
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::numberOrNan(asinh($number));
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Atan
{
/**
* ATAN.
*
* Returns the arctangent of a number.
*
* @param float $number Number
*
* @return float|string The arctangent of the number
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::numberOrNan(atan($number));
}
}

View File

@ -1,46 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Atan2
{
/**
* ATAN2.
*
* This function calculates the arc tangent of the two variables x and y. It is similar to
* calculating the arc tangent of y ÷ x, except that the signs of both arguments are used
* to determine the quadrant of the result.
* The arctangent is the angle from the x-axis to a line containing the origin (0, 0) and a
* point with coordinates (xCoordinate, yCoordinate). The angle is given in radians between
* -pi and pi, excluding -pi.
*
* Note that the Excel ATAN2() function accepts its arguments in the reverse order to the standard
* PHP atan2() function, so we need to reverse them here before calling the PHP atan() function.
*
* Excel Function:
* ATAN2(xCoordinate,yCoordinate)
*
* @param mixed $xCoordinate should be float, the x-coordinate of the point
* @param mixed $yCoordinate should be float, the y-coordinate of the point
*
* @return float|string the inverse tangent of the specified x- and y-coordinates, or a string containing an error
*/
public static function evaluate($xCoordinate, $yCoordinate)
{
try {
$xCoordinate = Helpers::validateNumericNullBool($xCoordinate);
$yCoordinate = Helpers::validateNumericNullBool($yCoordinate);
} catch (Exception $e) {
return $e->getMessage();
}
if (($xCoordinate == 0) && ($yCoordinate == 0)) {
return Functions::DIV0();
}
return atan2($yCoordinate, $xCoordinate);
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Atanh
{
/**
* ATANH.
*
* Returns the arc hyperbolic tangent of a number.
*
* @param float $number Number
*
* @return float|string The arc hyperbolic tangent of the number
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::numberOrNan(atanh($number));
}
}

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Base
@ -36,7 +36,7 @@ class Base
return Functions::NAN(); // Numeric range constraints
}
$outcome = strtoupper((string) base_convert($number, 10, $radix));
$outcome = strtoupper((string) base_convert((string) $number, 10, $radix));
if ($minLength !== null) {
$outcome = str_pad($outcome, (int) $minLength, '0', STR_PAD_LEFT); // String padding
}

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Ceiling
@ -23,7 +23,7 @@ class Ceiling
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function evaluate($number, $significance = null)
public static function ceiling($number, $significance = null)
{
if ($significance === null) {
self::floorCheck1Arg();
@ -39,6 +39,78 @@ class Ceiling
return self::argumentsOk((float) $number, (float) $significance);
}
/**
* CEILING.MATH.
*
* Round a number down to the nearest integer or to the nearest multiple of significance.
*
* Excel Function:
* CEILING.MATH(number[,significance[,mode]])
*
* @param mixed $number Number to round
* @param mixed $significance Significance
* @param int $mode direction to round negative numbers
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function math($number, $significance = null, $mode = 0)
{
try {
$number = Helpers::validateNumericNullBool($number);
$significance = Helpers::validateNumericNullSubstitution($significance, ($number < 0) ? -1 : 1);
$mode = Helpers::validateNumericNullSubstitution($mode, null);
} catch (Exception $e) {
return $e->getMessage();
}
if (empty($significance * $number)) {
return 0.0;
}
if (self::ceilingMathTest((float) $significance, (float) $number, (int) $mode)) {
return floor($number / $significance) * $significance;
}
return ceil($number / $significance) * $significance;
}
/**
* CEILING.PRECISE.
*
* Rounds number up, away from zero, to the nearest multiple of significance.
*
* Excel Function:
* CEILING.PRECISE(number[,significance])
*
* @param mixed $number the number you want to round
* @param float $significance the multiple to which you want to round
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function precise($number, $significance = 1)
{
try {
$number = Helpers::validateNumericNullBool($number);
$significance = Helpers::validateNumericNullSubstitution($significance, null);
} catch (Exception $e) {
return $e->getMessage();
}
if (!$significance) {
return 0.0;
}
$result = $number / abs($significance);
return ceil($result) * $significance * (($significance < 0) ? -1 : 1);
}
/**
* Let CEILINGMATH complexity pass Scrutinizer.
*/
private static function ceilingMathTest(float $significance, float $number, int $mode): bool
{
return ((float) $significance < 0) || ((float) $number < 0 && !empty($mode));
}
/**
* Avoid Scrutinizer problems concerning complexity.
*

View File

@ -1,50 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class CeilingMath
{
/**
* CEILING.MATH.
*
* Round a number down to the nearest integer or to the nearest multiple of significance.
*
* Excel Function:
* CEILING.MATH(number[,significance[,mode]])
*
* @param mixed $number Number to round
* @param mixed $significance Significance
* @param int $mode direction to round negative numbers
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function evaluate($number, $significance = null, $mode = 0)
{
try {
$number = Helpers::validateNumericNullBool($number);
$significance = Helpers::validateNumericNullSubstitution($significance, ($number < 0) ? -1 : 1);
$mode = Helpers::validateNumericNullSubstitution($mode, null);
} catch (Exception $e) {
return $e->getMessage();
}
if (empty($significance * $number)) {
return 0.0;
}
if (self::ceilingMathTest((float) $significance, (float) $number, (int) $mode)) {
return floor($number / $significance) * $significance;
}
return ceil($number / $significance) * $significance;
}
/**
* Let CEILINGMATH complexity pass Scrutinizer.
*/
private static function ceilingMathTest(float $significance, float $number, int $mode): bool
{
return ((float) $significance < 0) || ((float) $number < 0 && !empty($mode));
}
}

View File

@ -1,38 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class CeilingPrecise
{
/**
* CEILING.PRECISE.
*
* Rounds number up, away from zero, to the nearest multiple of significance.
*
* Excel Function:
* CEILING.PRECISE(number[,significance])
*
* @param mixed $number the number you want to round
* @param float $significance the multiple to which you want to round
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function evaluate($number, $significance = 1)
{
try {
$number = Helpers::validateNumericNullBool($number);
$significance = Helpers::validateNumericNullSubstitution($significance, null);
} catch (Exception $e) {
return $e->getMessage();
}
if (!$significance) {
return 0.0;
}
$result = $number / abs($significance);
return ceil($result) * $significance * (($significance < 0) ? -1 : 1);
}
}

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
class Combinations
{
@ -31,7 +31,7 @@ class Combinations
return $e->getMessage();
}
return round(Fact::evaluate($numObjs) / Fact::evaluate($numObjs - $numInSet)) / Fact::evaluate($numInSet);
return round(Factorial::fact($numObjs) / Factorial::fact($numObjs - $numInSet)) / Factorial::fact($numInSet);
}
/**
@ -69,6 +69,6 @@ class Combinations
return $e->getMessage();
}
return round(Fact::evaluate($numObjs + $numInSet - 1) / Fact::evaluate($numObjs - 1)) / Fact::evaluate($numInSet);
return round(Factorial::fact($numObjs + $numInSet - 1) / Factorial::fact($numObjs - 1)) / Factorial::fact($numInSet);
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Cos
{
/**
* COS.
*
* Returns the result of builtin function cos after validating args.
*
* @param mixed $number Should be numeric
*
* @return float|string cosine
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return cos($number);
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Cosh
{
/**
* COSH.
*
* Returns the result of builtin function cosh after validating args.
*
* @param mixed $number Should be numeric
*
* @return float|string cosine
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return cosh($number);
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Cot
{
/**
* COT.
*
* Returns the cotangent of an angle.
*
* @param float $angle Number
*
* @return float|string The cotangent of the angle
*/
public static function evaluate($angle)
{
try {
$angle = Helpers::validateNumericNullBool($angle);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::verySmallDenominator(cos($angle), sin($angle));
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Coth
{
/**
* COTH.
*
* Returns the hyperbolic cotangent of an angle.
*
* @param float $angle Number
*
* @return float|string The hyperbolic cotangent of the angle
*/
public static function evaluate($angle)
{
try {
$angle = Helpers::validateNumericNullBool($angle);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::verySmallDenominator(1.0, tanh($angle));
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Csc
{
/**
* CSC.
*
* Returns the cosecant of an angle.
*
* @param float $angle Number
*
* @return float|string The cosecant of the angle
*/
public static function evaluate($angle)
{
try {
$angle = Helpers::validateNumericNullBool($angle);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::verySmallDenominator(1.0, sin($angle));
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Csch
{
/**
* CSCH.
*
* Returns the hyperbolic cosecant of an angle.
*
* @param float $angle Number
*
* @return float|string The hyperbolic cosecant of the angle
*/
public static function evaluate($angle)
{
try {
$angle = Helpers::validateNumericNullBool($angle);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::verySmallDenominator(1.0, sinh($angle));
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Degrees
{
/**
* DEGREES.
*
* Returns the result of builtin function rad2deg after validating args.
*
* @param mixed $number Should be numeric
*
* @return float|string Rounded number
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return rad2deg($number);
}
}

View File

@ -1,35 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Even
{
/**
* EVEN.
*
* Returns number rounded up to the nearest even integer.
* You can use this function for processing items that come in twos. For example,
* a packing crate accepts rows of one or two items. The crate is full when
* the number of items, rounded up to the nearest two, matches the crate's
* capacity.
*
* Excel Function:
* EVEN(number)
*
* @param float $number Number to round
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
return Helpers::getEven($number);
}
}

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
class Exp
{

View File

@ -1,47 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
class Fact
{
/**
* FACT.
*
* Returns the factorial of a number.
* The factorial of a number is equal to 1*2*3*...* number.
*
* Excel Function:
* FACT(factVal)
*
* @param float $factVal Factorial Value
*
* @return float|int|string Factorial, or a string containing an error
*/
public static function evaluate($factVal)
{
try {
$factVal = Helpers::validateNumericNullBool($factVal);
Helpers::validateNotNegative($factVal);
} catch (Exception $e) {
return $e->getMessage();
}
$factLoop = floor($factVal);
if ($factVal > $factLoop) {
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
return Statistical\Distributions\Gamma::gammaValue($factVal + 1);
}
}
$factorial = 1;
while ($factLoop > 1) {
$factorial *= $factLoop--;
}
return $factorial;
}
}

View File

@ -1,39 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class FactDouble
{
/**
* FACTDOUBLE.
*
* Returns the double factorial of a number.
*
* Excel Function:
* FACTDOUBLE(factVal)
*
* @param float $factVal Factorial Value
*
* @return float|int|string Double Factorial, or a string containing an error
*/
public static function evaluate($factVal)
{
try {
$factVal = Helpers::validateNumericNullSubstitution($factVal, 0);
Helpers::validateNotNegative($factVal);
} catch (Exception $e) {
return $e->getMessage();
}
$factLoop = floor($factVal);
$factorial = 1;
while ($factLoop > 1) {
$factorial *= $factLoop;
$factLoop -= 2;
}
return $factorial;
}
}

View File

@ -0,0 +1,110 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
class Factorial
{
/**
* FACT.
*
* Returns the factorial of a number.
* The factorial of a number is equal to 1*2*3*...* number.
*
* Excel Function:
* FACT(factVal)
*
* @param float $factVal Factorial Value
*
* @return float|int|string Factorial, or a string containing an error
*/
public static function fact($factVal)
{
try {
$factVal = Helpers::validateNumericNullBool($factVal);
Helpers::validateNotNegative($factVal);
} catch (Exception $e) {
return $e->getMessage();
}
$factLoop = floor($factVal);
if ($factVal > $factLoop) {
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
return Statistical\Distributions\Gamma::gammaValue($factVal + 1);
}
}
$factorial = 1;
while ($factLoop > 1) {
$factorial *= $factLoop--;
}
return $factorial;
}
/**
* FACTDOUBLE.
*
* Returns the double factorial of a number.
*
* Excel Function:
* FACTDOUBLE(factVal)
*
* @param float $factVal Factorial Value
*
* @return float|int|string Double Factorial, or a string containing an error
*/
public static function factDouble($factVal)
{
try {
$factVal = Helpers::validateNumericNullSubstitution($factVal, 0);
Helpers::validateNotNegative($factVal);
} catch (Exception $e) {
return $e->getMessage();
}
$factLoop = floor($factVal);
$factorial = 1;
while ($factLoop > 1) {
$factorial *= $factLoop;
$factLoop -= 2;
}
return $factorial;
}
/**
* MULTINOMIAL.
*
* Returns the ratio of the factorial of a sum of values to the product of factorials.
*
* @param mixed[] $args An array of mixed values for the Data Series
*
* @return float|string The result, or a string containing an error
*/
public static function multinomial(...$args)
{
$summer = 0;
$divisor = 1;
try {
// Loop through arguments
foreach (Functions::flattenArray($args) as $argx) {
$arg = Helpers::validateNumericNullSubstitution($argx, null);
Helpers::validateNotNegative($arg);
$arg = (int) $arg;
$summer += $arg;
$divisor *= self::fact($arg);
}
} catch (Exception $e) {
return $e->getMessage();
}
$summer = self::fact($summer);
return $summer / $divisor;
}
}

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Floor
@ -28,7 +28,7 @@ class Floor
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function evaluate($number, $significance = null)
public static function floor($number, $significance = null)
{
if ($significance === null) {
self::floorCheck1Arg();
@ -44,6 +44,103 @@ class Floor
return self::argumentsOk((float) $number, (float) $significance);
}
/**
* FLOOR.MATH.
*
* Round a number down to the nearest integer or to the nearest multiple of significance.
*
* Excel Function:
* FLOOR.MATH(number[,significance[,mode]])
*
* @param mixed $number Number to round
* @param mixed $significance Significance
* @param mixed $mode direction to round negative numbers
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function math($number, $significance = null, $mode = 0)
{
try {
$number = Helpers::validateNumericNullBool($number);
$significance = Helpers::validateNumericNullSubstitution($significance, ($number < 0) ? -1 : 1);
$mode = Helpers::validateNumericNullSubstitution($mode, null);
} catch (Exception $e) {
return $e->getMessage();
}
return self::argsOk((float) $number, (float) $significance, (int) $mode);
}
/**
* FLOOR.PRECISE.
*
* Rounds number down, toward zero, to the nearest multiple of significance.
*
* Excel Function:
* FLOOR.PRECISE(number[,significance])
*
* @param float $number Number to round
* @param float $significance Significance
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function precise($number, $significance = 1)
{
try {
$number = Helpers::validateNumericNullBool($number);
$significance = Helpers::validateNumericNullSubstitution($significance, null);
} catch (Exception $e) {
return $e->getMessage();
}
return self::argumentsOkPrecise((float) $number, (float) $significance);
}
/**
* Avoid Scrutinizer problems concerning complexity.
*
* @return float|string
*/
private static function argumentsOkPrecise(float $number, float $significance)
{
if ($significance == 0.0) {
return Functions::DIV0();
}
if ($number == 0.0) {
return 0.0;
}
return floor($number / abs($significance)) * abs($significance);
}
/**
* Avoid Scrutinizer complexity problems.
*
* @return float|string Rounded Number, or a string containing an error
*/
private static function argsOk(float $number, float $significance, int $mode)
{
if (!$significance) {
return Functions::DIV0();
}
if (!$number) {
return 0.0;
}
if (self::floorMathTest($number, $significance, $mode)) {
return ceil($number / $significance) * $significance;
}
return floor($number / $significance) * $significance;
}
/**
* Let FLOORMATH complexity pass Scrutinizer.
*/
private static function floorMathTest(float $number, float $significance, int $mode): bool
{
return Helpers::returnSign($significance) == -1 || (Helpers::returnSign($number) == -1 && !empty($mode));
}
/**
* Avoid Scrutinizer problems concerning complexity.
*

View File

@ -1,64 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class FloorMath
{
/**
* FLOOR.MATH.
*
* Round a number down to the nearest integer or to the nearest multiple of significance.
*
* Excel Function:
* FLOOR.MATH(number[,significance[,mode]])
*
* @param mixed $number Number to round
* @param mixed $significance Significance
* @param mixed $mode direction to round negative numbers
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function evaluate($number, $significance = null, $mode = 0)
{
try {
$number = Helpers::validateNumericNullBool($number);
$significance = Helpers::validateNumericNullSubstitution($significance, ($number < 0) ? -1 : 1);
$mode = Helpers::validateNumericNullSubstitution($mode, null);
} catch (Exception $e) {
return $e->getMessage();
}
return self::argsOk((float) $number, (float) $significance, (int) $mode);
}
/**
* Avoid Scrutinizer complexity problems.
*
* @return float|string Rounded Number, or a string containing an error
*/
private static function argsOk(float $number, float $significance, int $mode)
{
if (!$significance) {
return Functions::DIV0();
}
if (!$number) {
return 0.0;
}
if (self::floorMathTest($number, $significance, $mode)) {
return ceil($number / $significance) * $significance;
}
return floor($number / $significance) * $significance;
}
/**
* Let FLOORMATH complexity pass Scrutinizer.
*/
private static function floorMathTest(float $number, float $significance, int $mode): bool
{
return Helpers::returnSign($significance) == -1 || (Helpers::returnSign($number) == -1 && !empty($mode));
}
}

View File

@ -1,51 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class FloorPrecise
{
/**
* FLOOR.PRECISE.
*
* Rounds number down, toward zero, to the nearest multiple of significance.
*
* Excel Function:
* FLOOR.PRECISE(number[,significance])
*
* @param float $number Number to round
* @param float $significance Significance
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function evaluate($number, $significance = 1)
{
try {
$number = Helpers::validateNumericNullBool($number);
$significance = Helpers::validateNumericNullSubstitution($significance, null);
} catch (Exception $e) {
return $e->getMessage();
}
return self::argumentsOk((float) $number, (float) $significance);
}
/**
* Avoid Scrutinizer problems concerning complexity.
*
* @return float|string
*/
private static function argumentsOk(float $number, float $significance)
{
if ($significance == 0.0) {
return Functions::DIV0();
}
if ($number == 0.0) {
return 0.0;
}
return floor($number / abs($significance)) * abs($significance);
}
}

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Gcd

View File

@ -34,7 +34,7 @@ class Helpers
return (int) $number;
}
if (is_numeric($number)) {
return $number;
return 0 + $number;
}
throw new Exception(Functions::VALUE());
@ -55,7 +55,7 @@ class Helpers
return $substitute;
}
if (is_numeric($number)) {
return $number;
return 0 + $number;
}
throw new Exception(Functions::VALUE());

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
class IntClass
{

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Lcm
@ -10,7 +10,7 @@ class Lcm
//
// Private method to return an array of the factors of the input value
//
private static function factors($value)
private static function factors(float $value): array
{
$startVal = floor(sqrt($value));

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
class Logarithms
{

View File

@ -2,10 +2,10 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use Matrix\Builder;
use Matrix\Exception as MatrixException;
use Matrix\Matrix;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class MatrixFunctions

View File

@ -1,36 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Mod
{
/**
* MOD.
*
* @param mixed $dividend Dividend
* @param mixed $divisor Divisor
*
* @return float|int|string Remainder, or a string containing an error
*/
public static function evaluate($dividend, $divisor)
{
try {
$dividend = Helpers::validateNumericNullBool($dividend);
$divisor = Helpers::validateNumericNullBool($divisor);
Helpers::validateNotZero($divisor);
} catch (Exception $e) {
return $e->getMessage();
}
if (($dividend < 0.0) && ($divisor > 0.0)) {
return $divisor - fmod(abs($dividend), $divisor);
}
if (($dividend > 0.0) && ($divisor < 0.0)) {
return $divisor + fmod($dividend, abs($divisor));
}
return fmod($dividend, $divisor);
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Mround
{
/**
* MROUND.
*
* Rounds a number to the nearest multiple of a specified value
*
* @param mixed $number Expect float. Number to round.
* @param mixed $multiple Expect int. Multiple to which you want to round.
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function evaluate($number, $multiple)
{
try {
$number = Helpers::validateNumericNullSubstitution($number, 0);
$multiple = Helpers::validateNumericNullSubstitution($multiple, null);
} catch (Exception $e) {
return $e->getMessage();
}
if ($number == 0 || $multiple == 0) {
return 0;
}
if ((Helpers::returnSign($number)) == (Helpers::returnSign($multiple))) {
$multiplier = 1 / $multiple;
return round($number * $multiplier) / $multiplier;
}
return Functions::NAN();
}
}

View File

@ -1,41 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Multinomial
{
/**
* MULTINOMIAL.
*
* Returns the ratio of the factorial of a sum of values to the product of factorials.
*
* @param mixed[] $args An array of mixed values for the Data Series
*
* @return float|string The result, or a string containing an error
*/
public static function evaluate(...$args)
{
$summer = 0;
$divisor = 1;
try {
// Loop through arguments
foreach (Functions::flattenArray($args) as $argx) {
$arg = Helpers::validateNumericNullSubstitution($argx, null);
Helpers::validateNotNegative($arg);
$arg = (int) $arg;
$summer += $arg;
$divisor *= Fact::evaluate($arg);
}
} catch (Exception $e) {
return $e->getMessage();
}
$summer = Fact::evaluate($summer);
return $summer / $divisor;
}
}

View File

@ -1,38 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use Exception;
class Odd
{
/**
* ODD.
*
* Returns number rounded up to the nearest odd integer.
*
* @param float $number Number to round
*
* @return float|string Rounded Number, or a string containing an error
*/
public static function evaluate($number)
{
try {
$number = Helpers::validateNumericNullBool($number);
} catch (Exception $e) {
return $e->getMessage();
}
$significance = Helpers::returnSign($number);
if ($significance == 0) {
return 1;
}
$result = ceil($number / $significance) * $significance;
if ($result == Helpers::getEven($result)) {
$result += $significance;
}
return $result;
}
}

View File

@ -0,0 +1,136 @@
<?php
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Operations
{
/**
* MOD.
*
* @param mixed $dividend Dividend
* @param mixed $divisor Divisor
*
* @return float|int|string Remainder, or a string containing an error
*/
public static function mod($dividend, $divisor)
{
try {
$dividend = Helpers::validateNumericNullBool($dividend);
$divisor = Helpers::validateNumericNullBool($divisor);
Helpers::validateNotZero($divisor);
} catch (Exception $e) {
return $e->getMessage();
}
if (($dividend < 0.0) && ($divisor > 0.0)) {
return $divisor - fmod(abs($dividend), $divisor);
}
if (($dividend > 0.0) && ($divisor < 0.0)) {
return $divisor + fmod($dividend, abs($divisor));
}
return fmod($dividend, $divisor);
}
/**
* POWER.
*
* Computes x raised to the power y.
*
* @param float|int $x
* @param float|int $y
*
* @return float|int|string The result, or a string containing an error
*/
public static function power($x, $y)
{
try {
$x = Helpers::validateNumericNullBool($x);
$y = Helpers::validateNumericNullBool($y);
} catch (Exception $e) {
return $e->getMessage();
}
// Validate parameters
if (!$x && !$y) {
return Functions::NAN();
}
if (!$x && $y < 0.0) {
return Functions::DIV0();
}
// Return
$result = $x ** $y;
return Helpers::numberOrNan($result);
}
/**
* PRODUCT.
*
* PRODUCT returns the product of all the values and cells referenced in the argument list.
*
* Excel Function:
* PRODUCT(value1[,value2[, ...]])
*
* @param mixed ...$args Data values
*
* @return float|string
*/
public static function product(...$args)
{
// Return value
$returnValue = null;
// Loop through arguments
foreach (Functions::flattenArray($args) as $arg) {
// Is it a numeric value?
if (is_numeric($arg)) {
if ($returnValue === null) {
$returnValue = $arg;
} else {
$returnValue *= $arg;
}
} else {
return Functions::VALUE();
}
}
// Return
if ($returnValue === null) {
return 0;
}
return $returnValue;
}
/**
* QUOTIENT.
*
* QUOTIENT function returns the integer portion of a division. Numerator is the divided number
* and denominator is the divisor.
*
* Excel Function:
* QUOTIENT(value1,value2)
*
* @param mixed $numerator Expect float|int
* @param mixed $denominator Expect float|int
*
* @return int|string
*/
public static function quotient($numerator, $denominator)
{
try {
$numerator = Helpers::validateNumericNullSubstitution($numerator, 0);
$denominator = Helpers::validateNumericNullSubstitution($denominator, 0);
Helpers::validateNotZero($denominator);
} catch (Exception $e) {
return $e->getMessage();
}
return (int) ($numerator / $denominator);
}
}

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