Merge branch 'master' into CSV-Reader-Dataype-casting-improvements

# Conflicts:
#	src/PhpSpreadsheet/Reader/Csv.php
This commit is contained in:
MarkBaker 2022-03-02 12:43:19 +01:00
commit aad91f1d25
8 changed files with 247 additions and 220 deletions

147
composer.lock generated
View File

@ -1100,23 +1100,23 @@
}, },
{ {
"name": "dompdf/dompdf", "name": "dompdf/dompdf",
"version": "v1.1.1", "version": "v1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/dompdf/dompdf.git", "url": "https://github.com/dompdf/dompdf.git",
"reference": "de4aad040737a89fae2129cdeb0f79c45513128d" "reference": "60b704331479a69e9bcdb3496da2315b5c4f94fd"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/dompdf/dompdf/zipball/de4aad040737a89fae2129cdeb0f79c45513128d", "url": "https://api.github.com/repos/dompdf/dompdf/zipball/60b704331479a69e9bcdb3496da2315b5c4f94fd",
"reference": "de4aad040737a89fae2129cdeb0f79c45513128d", "reference": "60b704331479a69e9bcdb3496da2315b5c4f94fd",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-dom": "*", "ext-dom": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"phenx/php-font-lib": "^0.5.2", "phenx/php-font-lib": "^0.5.4",
"phenx/php-svg-lib": "^0.3.3", "phenx/php-svg-lib": "^0.3.3 || ^0.4.0",
"php": "^7.1 || ^8.0" "php": "^7.1 || ^8.0"
}, },
"require-dev": { "require-dev": {
@ -1161,9 +1161,9 @@
"homepage": "https://github.com/dompdf/dompdf", "homepage": "https://github.com/dompdf/dompdf",
"support": { "support": {
"issues": "https://github.com/dompdf/dompdf/issues", "issues": "https://github.com/dompdf/dompdf/issues",
"source": "https://github.com/dompdf/dompdf/tree/v1.1.1" "source": "https://github.com/dompdf/dompdf/tree/v1.2.0"
}, },
"time": "2021-11-24T00:45:04+00:00" "time": "2022-02-07T13:02:10+00:00"
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
@ -1398,12 +1398,12 @@
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
},
"files": [ "files": [
"src/DeepCopy/deep_copy.php" "src/DeepCopy/deep_copy.php"
] ],
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -1597,16 +1597,16 @@
}, },
{ {
"name": "phar-io/version", "name": "phar-io/version",
"version": "3.1.0", "version": "3.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phar-io/version.git", "url": "https://github.com/phar-io/version.git",
"reference": "bae7c545bef187884426f042434e561ab1ddb182" "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
"reference": "bae7c545bef187884426f042434e561ab1ddb182", "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1642,26 +1642,29 @@
"description": "Library for handling version information and constraints", "description": "Library for handling version information and constraints",
"support": { "support": {
"issues": "https://github.com/phar-io/version/issues", "issues": "https://github.com/phar-io/version/issues",
"source": "https://github.com/phar-io/version/tree/3.1.0" "source": "https://github.com/phar-io/version/tree/3.2.1"
}, },
"time": "2021-02-23T14:00:09+00:00" "time": "2022-02-21T01:04:05+00:00"
}, },
{ {
"name": "phenx/php-font-lib", "name": "phenx/php-font-lib",
"version": "0.5.2", "version": "0.5.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PhenX/php-font-lib.git", "url": "https://github.com/dompdf/php-font-lib.git",
"reference": "ca6ad461f032145fff5971b5985e5af9e7fa88d8" "reference": "dd448ad1ce34c63d09baccd05415e361300c35b4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PhenX/php-font-lib/zipball/ca6ad461f032145fff5971b5985e5af9e7fa88d8", "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/dd448ad1ce34c63d09baccd05415e361300c35b4",
"reference": "ca6ad461f032145fff5971b5985e5af9e7fa88d8", "reference": "dd448ad1ce34c63d09baccd05415e361300c35b4",
"shasum": "" "shasum": ""
}, },
"require": {
"ext-mbstring": "*"
},
"require-dev": { "require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5 || ^6 || ^7" "symfony/phpunit-bridge": "^3 || ^4 || ^5"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -1682,10 +1685,10 @@
"description": "A library to read, parse, export and make subsets of different types of font files.", "description": "A library to read, parse, export and make subsets of different types of font files.",
"homepage": "https://github.com/PhenX/php-font-lib", "homepage": "https://github.com/PhenX/php-font-lib",
"support": { "support": {
"issues": "https://github.com/PhenX/php-font-lib/issues", "issues": "https://github.com/dompdf/php-font-lib/issues",
"source": "https://github.com/PhenX/php-font-lib/tree/0.5.2" "source": "https://github.com/dompdf/php-font-lib/tree/0.5.4"
}, },
"time": "2020-03-08T15:31:32+00:00" "time": "2021-12-17T19:44:54+00:00"
}, },
{ {
"name": "phenx/php-svg-lib", "name": "phenx/php-svg-lib",
@ -2074,16 +2077,16 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.4.5", "version": "1.4.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "150d1fbd82fb71ff76b3bd7f6ea6006d89c5f0c3" "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/150d1fbd82fb71ff76b3bd7f6ea6006d89c5f0c3", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8a7761f1c520e0dad6e04d862fdc697445457cfe",
"reference": "150d1fbd82fb71ff76b3bd7f6ea6006d89c5f0c3", "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2114,7 +2117,7 @@
"description": "PHPStan - PHP Static Analysis Tool", "description": "PHPStan - PHP Static Analysis Tool",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan/issues", "issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.4.5" "source": "https://github.com/phpstan/phpstan/tree/1.4.6"
}, },
"funding": [ "funding": [
{ {
@ -2134,7 +2137,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-02-02T19:35:10+00:00" "time": "2022-02-06T12:56:13+00:00"
}, },
{ {
"name": "phpstan/phpstan-phpunit", "name": "phpstan/phpstan-phpunit",
@ -2193,16 +2196,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "9.2.10", "version": "9.2.14",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "d5850aaf931743067f4bfc1ae4cbd06468400687" "reference": "9f4d60b6afe5546421462b76cd4e633ebc364ab4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f4d60b6afe5546421462b76cd4e633ebc364ab4",
"reference": "d5850aaf931743067f4bfc1ae4cbd06468400687", "reference": "9f4d60b6afe5546421462b76cd4e633ebc364ab4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2258,7 +2261,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10" "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.14"
}, },
"funding": [ "funding": [
{ {
@ -2266,7 +2269,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-12-05T09:12:13+00:00" "time": "2022-02-28T12:38:02+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@ -2511,16 +2514,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "9.5.13", "version": "9.5.16",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "597cb647654ede35e43b137926dfdfef0fb11743" "reference": "5ff8c545a50226c569310a35f4fa89d79f1ddfdc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/597cb647654ede35e43b137926dfdfef0fb11743", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5ff8c545a50226c569310a35f4fa89d79f1ddfdc",
"reference": "597cb647654ede35e43b137926dfdfef0fb11743", "reference": "5ff8c545a50226c569310a35f4fa89d79f1ddfdc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2536,7 +2539,7 @@
"phar-io/version": "^3.0.2", "phar-io/version": "^3.0.2",
"php": ">=7.3", "php": ">=7.3",
"phpspec/prophecy": "^1.12.1", "phpspec/prophecy": "^1.12.1",
"phpunit/php-code-coverage": "^9.2.7", "phpunit/php-code-coverage": "^9.2.13",
"phpunit/php-file-iterator": "^3.0.5", "phpunit/php-file-iterator": "^3.0.5",
"phpunit/php-invoker": "^3.1.1", "phpunit/php-invoker": "^3.1.1",
"phpunit/php-text-template": "^2.0.3", "phpunit/php-text-template": "^2.0.3",
@ -2571,11 +2574,11 @@
} }
}, },
"autoload": { "autoload": {
"classmap": [
"src/"
],
"files": [ "files": [
"src/Framework/Assert/Functions.php" "src/Framework/Assert/Functions.php"
],
"classmap": [
"src/"
] ]
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -2598,7 +2601,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.13" "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.16"
}, },
"funding": [ "funding": [
{ {
@ -2610,7 +2613,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-01-24T07:33:35+00:00" "time": "2022-02-23T17:10:58+00:00"
}, },
{ {
"name": "psr/cache", "name": "psr/cache",
@ -2811,29 +2814,33 @@
}, },
{ {
"name": "sabberworm/php-css-parser", "name": "sabberworm/php-css-parser",
"version": "8.3.1", "version": "8.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sabberworm/PHP-CSS-Parser.git", "url": "https://github.com/sabberworm/PHP-CSS-Parser.git",
"reference": "d217848e1396ef962fb1997cf3e2421acba7f796" "reference": "e41d2140031d533348b2192a83f02d8dd8a71d30"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sabberworm/PHP-CSS-Parser/zipball/d217848e1396ef962fb1997cf3e2421acba7f796", "url": "https://api.github.com/repos/sabberworm/PHP-CSS-Parser/zipball/e41d2140031d533348b2192a83f02d8dd8a71d30",
"reference": "d217848e1396ef962fb1997cf3e2421acba7f796", "reference": "e41d2140031d533348b2192a83f02d8dd8a71d30",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.2" "ext-iconv": "*",
"php": ">=5.6.20"
}, },
"require-dev": { "require-dev": {
"codacy/coverage": "^1.4", "codacy/coverage": "^1.4",
"phpunit/phpunit": "~4.8" "phpunit/phpunit": "^4.8.36"
},
"suggest": {
"ext-mbstring": "for parsing UTF-8 CSS"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Sabberworm\\CSS": "lib/" "Sabberworm\\CSS\\": "src/"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -2846,7 +2853,7 @@
} }
], ],
"description": "Parser for CSS Files written in PHP", "description": "Parser for CSS Files written in PHP",
"homepage": "http://www.sabberworm.com/blog/2010/6/10/php-css-parser", "homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser",
"keywords": [ "keywords": [
"css", "css",
"parser", "parser",
@ -2854,9 +2861,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/sabberworm/PHP-CSS-Parser/issues", "issues": "https://github.com/sabberworm/PHP-CSS-Parser/issues",
"source": "https://github.com/sabberworm/PHP-CSS-Parser/tree/8.3.1" "source": "https://github.com/sabberworm/PHP-CSS-Parser/tree/8.4.0"
}, },
"time": "2020-06-01T09:10:00+00:00" "time": "2021-12-11T13:40:54+00:00"
}, },
{ {
"name": "sebastian/cli-parser", "name": "sebastian/cli-parser",
@ -3364,16 +3371,16 @@
}, },
{ {
"name": "sebastian/global-state", "name": "sebastian/global-state",
"version": "5.0.3", "version": "5.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git", "url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2",
"reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3416,7 +3423,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues", "issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5"
}, },
"funding": [ "funding": [
{ {
@ -3424,7 +3431,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-06-11T13:31:12+00:00" "time": "2022-02-14T08:28:10+00:00"
}, },
{ {
"name": "sebastian/lines-of-code", "name": "sebastian/lines-of-code",
@ -4510,12 +4517,12 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
] ],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [

View File

@ -544,6 +544,25 @@ $reader->setSheetIndex(5);
$reader->loadIntoExisting("05featuredemo.csv", $spreadsheet); $reader->loadIntoExisting("05featuredemo.csv", $spreadsheet);
``` ```
#### Line endings
Line endings for Unix (`\n`) and Windows (`\r\n`) are supported.
Mac line endings (`\r`) are supported as long as PHP itself
supports them, which it does through release 8.0.
Support for Mac line endings is deprecated for 8.1,
and is scheduled to remain deprecated for all later PHP8 releases;
PhpSpreadsheet will continue to support them for 8.*.
Support is scheduled to be dropped with release 9;
PhpSpreadsheet will then no longer handle CSV files
with Mac line endings correctly.
You can suppress testing for Mac line endings as follows:
```php
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
$reader->setTestAutoDetect(false);
```
### \PhpOffice\PhpSpreadsheet\Writer\Csv ### \PhpOffice\PhpSpreadsheet\Writer\Csv
#### Writing a CSV file #### Writing a CSV file

View File

@ -146,12 +146,12 @@ parameters:
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, int\\|string given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, int\\|string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, null given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, null given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
@ -361,12 +361,12 @@ parameters:
path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php
- -
message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\<0, 281474976710655\\>\\|string given\\.$#" message: "#^Parameter \\#1 \\$num(ber)? of function floor expects float(.int)?, float\\|int\\<0, 281474976710655\\>\\|string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php
- -
message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" message: "#^Parameter \\#1 \\$num(ber)? of function floor expects float(.int)?, float\\|int\\|string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php
@ -821,12 +821,12 @@ parameters:
path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php
- -
message: "#^Parameter \\#1 \\$low of function range expects float\\|int\\|string, string\\|null given\\.$#" message: "#^Parameter \\#1 \\$(low|start) of function range expects float\\|int\\|string, string\\|null given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php
- -
message: "#^Parameter \\#2 \\$high of function range expects float\\|int\\|string, string\\|null given\\.$#" message: "#^Parameter \\#2 \\$(high|end) of function range expects float\\|int\\|string, string\\|null given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php
@ -1256,12 +1256,12 @@ parameters:
path: src/PhpSpreadsheet/Cell/Coordinate.php path: src/PhpSpreadsheet/Cell/Coordinate.php
- -
message: "#^Parameter \\#1 \\$input of function array_chunk expects array, array\\<int, string\\>\\|false given\\.$#" message: "#^Parameter \\#1 \\$(input|array) of function array_chunk expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Cell/Coordinate.php path: src/PhpSpreadsheet/Cell/Coordinate.php
- -
message: "#^Parameter \\#2 \\$str of function explode expects string, array\\<int, string\\>\\|string given\\.$#" message: "#^Parameter \\#2 \\$str(ing)? of function explode expects string, array\\<int, string\\>\\|string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Cell/Coordinate.php path: src/PhpSpreadsheet/Cell/Coordinate.php
@ -1946,7 +1946,7 @@ parameters:
path: src/PhpSpreadsheet/Helper/Html.php path: src/PhpSpreadsheet/Helper/Html.php
- -
message: "#^Parameter \\#1 \\$function of function call_user_func expects callable\\(\\)\\: mixed, array\\{\\$this\\(PhpOffice\\\\PhpSpreadsheet\\\\Helper\\\\Html\\), mixed\\} given\\.$#" message: "#^Parameter \\#1 \\$(function|callback) of function call_user_func expects callable\\(\\)\\: mixed, array\\{\\$this\\(PhpOffice\\\\PhpSpreadsheet\\\\Helper\\\\Html\\), mixed\\} given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Helper/Html.php path: src/PhpSpreadsheet/Helper/Html.php
@ -2521,7 +2521,7 @@ parameters:
path: src/PhpSpreadsheet/Reader/Xls/MD5.php path: src/PhpSpreadsheet/Reader/Xls/MD5.php
- -
message: "#^Parameter \\#1 \\$input of function array_values expects array, array\\|false given\\.$#" message: "#^Parameter \\#1 \\$(input|array) of function array_values expects array, array\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Reader/Xls/MD5.php path: src/PhpSpreadsheet/Reader/Xls/MD5.php
@ -3336,37 +3336,37 @@ parameters:
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Drawing\\:\\:imagecreatefrombmp\\(\\) should return GdImage\\|resource but returns resource\\|false\\.$#" message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Drawing\\:\\:imagecreatefrombmp\\(\\) should return GdImage\\|resource but returns (GdImage|resource)\\|false\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#1 \\$fp of function feof expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$(fp|stream) of function feof expects resource, resource\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#1 \\$fp of function fread expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$(fp|stream) of function fread expects resource, resource\\|false given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagecolorallocate expects (GdImage|resource), (GdImage|resource)\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#1 \\$im of function imagesetpixel expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagesetpixel expects (GdImage|resource), (GdImage|resource)\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#1 \\$x_size of function imagecreatetruecolor expects int, float\\|int given\\.$#" message: "#^Parameter \\#1 \\$(x_size|width) of function imagecreatetruecolor expects int, float\\|int given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#2 \\$data of function unpack expects string, string\\|false given\\.$#" message: "#^Parameter \\#2 \\$(data|string) of function unpack expects string, string\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
@ -3376,7 +3376,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#2 \\$y_size of function imagecreatetruecolor expects int, float\\|int given\\.$#" message: "#^Parameter \\#2 \\$(y_size|height) of function imagecreatetruecolor expects int, float\\|int given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
@ -3396,7 +3396,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#4 \\$col of function imagesetpixel expects int, int\\|false given\\.$#" message: "#^Parameter \\#4 \\$col(or)? of function imagesetpixel expects int, int\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
@ -3596,7 +3596,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/JAMA/Matrix.php path: src/PhpSpreadsheet/Shared/JAMA/Matrix.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, float\\|int given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, float\\|int given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/JAMA/Matrix.php path: src/PhpSpreadsheet/Shared/JAMA/Matrix.php
@ -3676,7 +3676,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/OLE.php path: src/PhpSpreadsheet/Shared/OLE.php
- -
message: "#^Parameter \\#2 \\$data of function unpack expects string, string\\|false given\\.$#" message: "#^Parameter \\#2 \\$(data|string) of function unpack expects string, string\\|false given\\.$#"
count: 3 count: 3
path: src/PhpSpreadsheet/Shared/OLE.php path: src/PhpSpreadsheet/Shared/OLE.php
@ -3716,7 +3716,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/OLE.php path: src/PhpSpreadsheet/Shared/OLE.php
- -
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, string given\\.$#" message: "#^Parameter \\#1 \\$(var|value) of function count expects array\\|Countable, string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php path: src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php
@ -4061,7 +4061,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php path: src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php
- -
message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, float given\\.$#" message: "#^Parameter \\#2 \\.\\.\\.\\$(args|arrays) of function array_merge expects array, float given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php path: src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php
@ -4361,7 +4361,7 @@ parameters:
path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
- -
message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|null given\\.$#" message: "#^Parameter \\#2 \\$str(ing)? of function explode expects string, string\\|null given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
@ -4486,7 +4486,7 @@ parameters:
path: src/PhpSpreadsheet/Worksheet/PageSetup.php path: src/PhpSpreadsheet/Worksheet/PageSetup.php
- -
message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|null given\\.$#" message: "#^Parameter \\#2 \\$str(ing)? of function explode expects string, string\\|null given\\.$#"
count: 5 count: 5
path: src/PhpSpreadsheet/Worksheet/PageSetup.php path: src/PhpSpreadsheet/Worksheet/PageSetup.php
@ -4581,7 +4581,7 @@ parameters:
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
- -
message: "#^Parameter \\#1 \\$input of function array_splice expects array, ArrayObject\\<int, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\> given\\.$#" message: "#^Parameter \\#1 \\$(input|array) of function array_splice expects array, ArrayObject\\<int, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\> given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
@ -4606,7 +4606,7 @@ parameters:
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
- -
message: "#^Parameter \\#2 \\$start of function substr expects int, int\\<0, max\\>\\|false given\\.$#" message: "#^Parameter \\#2 \\$(start|offset) of function substr expects int, int(\\<0, max\\>)?\\|false given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
@ -4931,12 +4931,12 @@ parameters:
path: src/PhpSpreadsheet/Writer/Html.php path: src/PhpSpreadsheet/Writer/Html.php
- -
message: "#^Parameter \\#1 \\$im of function imagepng expects resource, GdImage\\|resource given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagepng expects (GdImage|resource), GdImage\\|resource given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Html.php path: src/PhpSpreadsheet/Writer/Html.php
- -
message: "#^Parameter \\#1 \\$str of function base64_encode expects string, string\\|false given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function base64_encode expects string, string\\|false given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Writer/Html.php path: src/PhpSpreadsheet/Writer/Html.php
@ -5066,12 +5066,12 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xls.php path: src/PhpSpreadsheet/Writer/Xls.php
- -
message: "#^Parameter \\#1 \\$im of function imagepng expects resource, GdImage\\|resource given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagepng expects (GdImage|resource), GdImage\\|resource given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls.php path: src/PhpSpreadsheet/Writer/Xls.php
- -
message: "#^Parameter \\#1 \\$im of function imagepng expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagepng expects (GdImage|resource), (GdImage|resource)\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls.php path: src/PhpSpreadsheet/Writer/Xls.php
@ -5256,7 +5256,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
- -
message: "#^Parameter \\#1 \\$im of function imagecolorat expects resource, GdImage\\|resource given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagecolorat expects (GdImage|resource), GdImage\\|resource given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
@ -5271,12 +5271,12 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
- -
message: "#^Parameter \\#2 \\$col of function imagecolorsforindex expects int, int\\|false given\\.$#" message: "#^Parameter \\#2 \\$col(or)? of function imagecolorsforindex expects int, int\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
- -
message: "#^Parameter \\#2 \\$data of function unpack expects string, string\\|false given\\.$#" message: "#^Parameter \\#2 \\$(data|string) of function unpack expects string, string\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
@ -5286,7 +5286,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
- -
message: "#^Parameter \\#2 \\$pieces of function implode expects array, array\\<int, string\\>\\|false given\\.$#" message: "#^Parameter \\#2 \\$(pieces|array) of function implode expects array(\\|null)?, array\\<int, string\\>\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
@ -5371,7 +5371,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xlsx.php path: src/PhpSpreadsheet/Writer/Xlsx.php
- -
message: "#^Parameter \\#1 \\$function of function call_user_func expects callable\\(\\)\\: mixed, string given\\.$#" message: "#^Parameter \\#1 \\$(function|callback) of function call_user_func expects callable\\(\\)\\: mixed, string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xlsx.php path: src/PhpSpreadsheet/Writer/Xlsx.php
@ -5850,51 +5850,11 @@ parameters:
count: 2 count: 2
path: tests/PhpSpreadsheetTests/Functional/ConditionalStopIfTrueTest.php path: tests/PhpSpreadsheetTests/Functional/ConditionalStopIfTrueTest.php
-
message: "#^Cannot call method getUrl\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Hyperlink\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
-
message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
-
message: "#^Parameter \\#1 \\$im of function imagestring expects resource, resource\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
-
message: "#^Parameter \\#1 \\$value of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\MemoryDrawing\\:\\:setImageResource\\(\\) expects GdImage\\|resource, resource\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
-
message: "#^Parameter \\#6 \\$col of function imagestring expects int, int\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
- -
message: "#^Cannot call method getPageSetup\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\|null\\.$#" message: "#^Cannot call method getPageSetup\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\|null\\.$#"
count: 5 count: 5
path: tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php path: tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php
-
message: "#^Cannot access offset 'size' on array\\{0\\: int, 1\\: int, 2\\: int, 3\\: int, 4\\: int, 5\\: int, 6\\: int, 7\\: int, \\.\\.\\.\\}\\|false\\.$#"
count: 2
path: tests/PhpSpreadsheetTests/Functional/StreamTest.php
-
message: "#^Parameter \\#1 \\$filename of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\IWriter\\:\\:save\\(\\) expects resource\\|string, resource\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Functional/StreamTest.php
-
message: "#^Parameter \\#1 \\$fp of function fstat expects resource, resource\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Functional/StreamTest.php
- -
message: "#^Parameter \\#1 \\$expected of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) expects class\\-string\\<object\\>, string given\\.$#" message: "#^Parameter \\#1 \\$expected of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) expects class\\-string\\<object\\>, string given\\.$#"
count: 3 count: 3
@ -6050,26 +6010,6 @@ parameters:
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php path: tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php
-
message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php
-
message: "#^Parameter \\#1 \\$im of function imagestring expects resource, resource\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php
-
message: "#^Parameter \\#1 \\$value of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\MemoryDrawing\\:\\:setImageResource\\(\\) expects GdImage\\|resource, resource\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php
-
message: "#^Parameter \\#6 \\$col of function imagestring expects int, int\\|false given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php
- -
message: "#^Parameter \\#2 \\$rowIndex of class PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowCellIterator constructor expects int, string given\\.$#" message: "#^Parameter \\#2 \\$rowIndex of class PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowCellIterator constructor expects int, string given\\.$#"
count: 1 count: 1

View File

@ -86,6 +86,13 @@ class Csv extends BaseReader
*/ */
private static $constructorCallback; private static $constructorCallback;
/**
* Attempt autodetect line endings (deprecated after PHP8.1)?
*
* @var bool
*/
private $testAutodetect = true;
/** /**
* @var bool * @var bool
*/ */
@ -281,10 +288,15 @@ class Csv extends BaseReader
} }
} }
private static function setAutoDetect(?string $value): ?string public function setTestAutoDetect(bool $value): void
{
$this->testAutodetect = $value;
}
private function setAutoDetect(?string $value): ?string
{ {
$retVal = null; $retVal = null;
if ($value !== null) { if ($value !== null && $this->testAutodetect) {
$retVal2 = @ini_set('auto_detect_line_endings', $value); $retVal2 = @ini_set('auto_detect_line_endings', $value);
if (is_string($retVal2)) { if (is_string($retVal2)) {
$retVal = $retVal2; $retVal = $retVal2;
@ -308,7 +320,7 @@ class Csv extends BaseReader
public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Spreadsheet public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Spreadsheet
{ {
// Deprecated in Php8.1 // Deprecated in Php8.1
$iniset = self::setAutoDetect('1'); $iniset = $this->setAutoDetect('1');
// Open file // Open file
$this->openFileOrMemory($filename); $this->openFileOrMemory($filename);
@ -364,7 +376,7 @@ class Csv extends BaseReader
// Close file // Close file
fclose($fileHandle); fclose($fileHandle);
self::setAutoDetect($iniset); $this->setAutoDetect($iniset);
// Return // Return
return $spreadsheet; return $spreadsheet;

View File

@ -10,13 +10,15 @@ class DrawingImageHyperlinkTest extends AbstractFunctional
{ {
public function testDrawingImageHyperlinkTest(): void public function testDrawingImageHyperlinkTest(): void
{ {
$gdImage = @imagecreatetruecolor(120, 20);
$textColor = ($gdImage === false) ? false : imagecolorallocate($gdImage, 255, 255, 255);
if ($gdImage === false || $textColor === false) {
self::fail('imagecreatetruecolor or imagecolorallocate failed');
} else {
$baseUrl = 'https://github.com/PHPOffice/PhpSpreadsheet'; $baseUrl = 'https://github.com/PHPOffice/PhpSpreadsheet';
$spreadsheet = new Spreadsheet(); $spreadsheet = new Spreadsheet();
$aSheet = $spreadsheet->getActiveSheet(); $aSheet = $spreadsheet->getActiveSheet();
$gdImage = @imagecreatetruecolor(120, 20);
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor); imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor);
$drawing = new MemoryDrawing(); $drawing = new MemoryDrawing();
@ -34,9 +36,17 @@ class DrawingImageHyperlinkTest extends AbstractFunctional
$drawing->setWorksheet($aSheet); $drawing->setWorksheet($aSheet);
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx'); $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx');
$spreadsheet->disconnectWorksheets();
foreach ($reloadedSpreadsheet->getActiveSheet()->getDrawingCollection() as $pDrawing) { foreach ($reloadedSpreadsheet->getActiveSheet()->getDrawingCollection() as $pDrawing) {
self::assertEquals('https://github.com/PHPOffice/PhpSpreadsheet', $pDrawing->getHyperlink()->getUrl(), 'functional test drawing hyperlink'); $getHyperlink = $pDrawing->getHyperlink();
if ($getHyperlink === null) {
self::fail('getHyperlink returned null');
} else {
self::assertEquals('https://github.com/PHPOffice/PhpSpreadsheet', $getHyperlink->getUrl(), 'functional test drawing hyperlink');
}
}
$reloadedSpreadsheet->disconnectWorksheets();
} }
} }
} }

View File

@ -39,12 +39,22 @@ class StreamTest extends TestCase
$writer = IOFactory::createWriter($spreadsheet, $format); $writer = IOFactory::createWriter($spreadsheet, $format);
$stream = fopen('php://memory', 'wb+'); $stream = fopen('php://memory', 'wb+');
self::assertSame(0, fstat($stream)['size']); $stat = ($stream === false) ? false : fstat($stream);
if ($stream === false || $stat === false) {
self::fail('fopen or fstat failed');
} else {
self::assertSame(0, $stat['size']);
$writer->save($stream); $writer->save($stream);
self::assertIsResource($stream, 'should not close the stream for further usage out of PhpSpreadsheet'); self::assertIsResource($stream, 'should not close the stream for further usage out of PhpSpreadsheet');
self::assertGreaterThan(0, fstat($stream)['size'], 'something should have been written to the stream'); $stat = fstat($stream);
if ($stat === false) {
self::fail('fstat failed');
} else {
self::assertGreaterThan(0, $stat['size'], 'something should have been written to the stream');
}
self::assertGreaterThan(0, ftell($stream), 'should not be rewinded, because not all streams support it'); self::assertGreaterThan(0, ftell($stream), 'should not be rewinded, because not all streams support it');
} }
} }
}

View File

@ -36,6 +36,31 @@ class CsvLineEndingTest extends TestCase
$spreadsheet->disconnectWorksheets(); $spreadsheet->disconnectWorksheets();
} }
/**
* @dataProvider providerEndings
*/
public function testEndingsNoDetect(string $ending): void
{
$this->tempFile = $filename = File::temporaryFilename();
$data = ['123', '456', '789'];
file_put_contents($filename, implode($ending, $data));
$reader = new Csv();
$reader->setTestAutoDetect(false);
$spreadsheet = $reader->load($filename);
$sheet = $spreadsheet->getActiveSheet();
if ($ending === "\r") {
// Can't handle Mac line endings without autoDetect
self::assertEquals(implode("\n", $data), $sheet->getCell('A1')->getValue());
self::assertNull($sheet->getCell('A2')->getValue());
self::assertNull($sheet->getCell('A3')->getValue());
} else {
self::assertEquals($data[0], $sheet->getCell('A1')->getValue());
self::assertEquals($data[1], $sheet->getCell('A2')->getValue());
self::assertEquals($data[2], $sheet->getCell('A3')->getValue());
}
$spreadsheet->disconnectWorksheets();
}
public function providerEndings(): array public function providerEndings(): array
{ {
return [ return [

View File

@ -10,11 +10,13 @@ class DrawingTest extends TestCase
{ {
public function testCloningWorksheetWithImages(): void public function testCloningWorksheetWithImages(): void
{ {
$gdImage = @imagecreatetruecolor(120, 20);
$textColor = ($gdImage === false) ? false : imagecolorallocate($gdImage, 255, 255, 255);
if ($gdImage === false || $textColor === false) {
self::fail('imagecreatetruecolor or imagecolorallocate failed');
} else {
$spreadsheet = new Spreadsheet(); $spreadsheet = new Spreadsheet();
$aSheet = $spreadsheet->getActiveSheet(); $aSheet = $spreadsheet->getActiveSheet();
$gdImage = @imagecreatetruecolor(120, 20);
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor); imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor);
$drawing = new MemoryDrawing(); $drawing = new MemoryDrawing();
@ -36,5 +38,7 @@ class DrawingTest extends TestCase
self::assertEquals($originDrawingCount, $clonedDrawingCount); self::assertEquals($originDrawingCount, $clonedDrawingCount);
self::assertNotSame($aSheet, $clonedWorksheet); self::assertNotSame($aSheet, $clonedWorksheet);
self::assertNotSame($aSheet->getDrawingCollection(), $clonedWorksheet->getDrawingCollection()); self::assertNotSame($aSheet->getDrawingCollection(), $clonedWorksheet->getDrawingCollection());
$spreadsheet->disconnectWorksheets();
}
} }
} }