Commit Graph

4267 Commits

Author SHA1 Message Date
oleibman 1282f3d67c Performance Improvements for Csv Reader (#3769)
* Performance Improvements for Csv Reader

Investigating issue #381, a means was suggested to duplicated a problem, but no problem occurred ... except for performance. This involved a spreadsheet with a large number of cells, definitely not PhpSpreadsheet's strong point; even so, the program (entirely available in the issue) took a disastrous two or so hours to complete on my system. Looking at the Csv Reader code, several opportunities to cache results and avoid function calls jumped out, none of which seem to materially add to the maintenance burden of the program. Testing these changes resulted in a run time of about 20 minutes, still hardly a thing of beauty, but a huge improvement over the original and therefore worth proceeding with.

* Redo CsvIssue2232Test

Test cases included duplicates, and didn't account for some things (e.g. French locale will treat both 'vrai' and 'true' as true).

* Additional Optimization
2023-10-18 14:02:44 -07:00
oleibman bc9ca28deb Use DateTime::format Rather than cal_days_in_month in Sample (#3764)
Fix #3760. That problem actually was easily fixed, by enabling calendar extension in user's environment. Astonishingly, however, this is the only use of calendar in the entire project. Since the same functionality is available in DateTime, which is used throughout the project, use that instead to eliminate the dependency on calendar.
2023-10-13 23:41:08 -07:00
oleibman db35a4127d Upgrades in Advance of Dependabot (#3757)
More convenient to handle it today than tomorrow. Phpstan flags 1 new statement, but it is incorrect - annotate it.
2023-09-30 13:16:06 -07:00
oleibman d0fae3f57a Eliminate Some Phpstan Annotations (#3746)
* Eliminate Some Phpstan Annotations

Some changes are possible due to Php8+ features like null-safe operators and Stringable.

* Possible Uninitialized Variable

Scrutinizer might be technically correct.

* CellAddress Static -> Self

I don't understand the use case for extending it, which would be the reason for using static rather than self.

* Update Worksheet.php
2023-09-30 08:48:02 -07:00
oleibman e53e44d8cc Allow Users to Support Additional Tags in Helper/Html (#3752)
* Allow Users to Support Additional Tags in Helper/Html

Fix #3751. User wants to add bullets for list items, and possibly handle table rows and other currently unsupported tags where one size might not fit all.

* Update CHANGELOG.md
2023-09-30 07:46:28 -07:00
redtailmatt a713e153aa Added Conditional Formatting: ColorScale for Xlsx (#3738)
* Added Conditional Formatting: ColorScale for Xlsx

* Add Reader Support, Tests, Sample

Also correct Phpstan and phpcs problems.

* Update cond08_colorscale.php

* Improve Coverage

* More Coverage Improvements

* Use StyleReader for Colors for ColorScale and DataBar

The implementation of DataBar looks for an rgb attribute, but the color may be provided via theme attribute instead. The initial implementation for ColorScale did the same. Change both to use the existing code in Reader\Xlsx\Styles to parse the color.

* Change Some Doc Blocks to Type Declarations

---------

Co-authored-by: oleibman <10341515+oleibman@users.noreply.github.com>
2023-09-30 07:23:42 -07:00
Adrien Crivelli 7328e1ed61 Drop dead code 2023-09-26 16:14:56 +08:00
Adrien Crivelli 2da85155bd Fix PHPStan errors 2023-09-21 11:14:48 +08:00
Adrien Crivelli 7079e58054 Declare our minimum PHP version
So that composer will not update our dependencies to something that
would not work with PHP 8.0. And so that PHPStan analyzes assuming we
are running 8.0
2023-09-21 11:14:47 +08:00
Adrien Crivelli cbffcbcbbc Drop some tricks used for Scrutinizer false positives 2023-09-21 11:14:47 +08:00
Adrien Crivelli 2a0a53cd6a Drop all Scrutinizer annotations
Because they tend to clutter our code a lot and unfortunately, there are
lots of false positives. Instead, it would probably be better to deal
with false positives out of band, via the Scrutinizer web UI.
2023-09-21 11:14:47 +08:00
oleibman 07c60bac4a Clear Output Buffering Only When It's Been Started (#3741)
Fix #3739. User is seeing an intermittent notice when running samples using a web browser. The notice is comming from ob_clean, complaining that there is no buffer to delete. I frankly do not understand what the ob_clean is supposed to be paired with, nor why I cannot duplicate this result. Possibly, a better solution would be to eliminate the ob_clean; but using ob_get_length beforehand to see if there is anything to clean up seems safer, and I can't think of a downside.

The code in question is never executed when a sample is run from the command line. Consequently, no formal unit test is possible. The user reporting the problem was asked to test the change, and confirmed that the problem went away; no new problem arose on my system.
2023-09-20 15:42:37 -07:00
Adrien Crivelli 23b95e24c7 Stronger typing for ranges 2023-09-20 17:49:22 +08:00
jenasnic b2d572c8bb Fix missing font index with some XLS files (#3734)
* Fix missing font index with some XLS files

* Add test case

* Improve Test

---------

Co-authored-by: JC <jcopin@nodevo.com>
Co-authored-by: jenasnic
2023-09-18 01:33:33 -07:00
oleibman 7872602136 Properly Document Breaking Change from 1.28.0 (#3737)
See issue #3736.
2023-09-15 02:17:08 -07:00
Progi1984 f085c85339 Writer ODS : Writer Border Style for cells (#3693)
* Writer ODS : Write Border Style for cells

* Writer ODS : Write Border Style for cells (Replaced protected by private && Added Unit Test)

---------
2023-09-14 06:29:04 -07:00
Kevin Verschaeve 6fbf474642 fix: Load tables when flag IReader::READ_DATA_ONLY is used (#3726)
* fix: Load tables when flag IReader::READ_DATA_ONLY is used

* Add test for table read when IReader:::READ_DATA_ONLY is used

---------

Co-authored-by: Kevin Verschaeve <kevin.verschaeve@exotec.com>
2023-09-14 05:58:52 -07:00
oleibman 1b01b7d1ec Scrutinizer Samples/Tests (#3733)
* Scrutinizer Samples/Tests

A great many statements recently flagged. Attend to those in Samples and Tests.

* Missed a Few

* Update XlsTest.php
2023-09-13 22:45:06 -07:00
oleibman c74255cfa6 Update Changelog 2023-09-13 (#3731)
* Update Changelog 2023-09-13

* Update XssVulnerabilityTest.php
2023-09-13 00:51:17 -07:00
dmytromikhieiev1985 4e54ed389b Replace ezyang/htmlpurifier with voku/anti-xss (#3724)
* Replace ezyang/htmlpurifier with voku/anti-xss

* Update XssVulnerabilityTest
2023-09-13 00:29:01 -07:00
oleibman f17e16653d Break Some More Circular References (#3716)
* Break Some More Circular References

After identifying a circular reference between Worksheet and Table, which could lead to memory leaks, I identified several other similar relationships. I have added a destructor, or added added code to an existing destructor, for those possibilities. This didn't actually lead to any lowering of the memory usage of the unit test suite, so maybe there's no practical benefit, but it does seem like it should be theoretically useful. I am not aware of any practical way to unit test a destructor, although the added code will be exercised many times in most of our unit tests.

The only change here not involving a destructor is to `Worksheet::addChart` (it came to my attention because Worksheet and Chart have a circular reference). It is currently defined with two arguments, the second allowing you to place the chart in a specific location in the containing ArrayObject. However, as Phpstan and Scrutinizer both warn, the code to support this option will fail if it is ever executed (can't use array_splice on an ArrayObject); needless to say, this possibility is not exercised when executing the test suite. It could be made to work, but I really can't see any kind of use case to support this parameter. So I'm removing the second parameter. In theory, this is a breaking change, but, since the code can never work, in practice it won't be.

* Update Worksheet.php

* Update Worksheet.php
2023-09-12 22:56:15 -07:00
oleibman 72b77020e4 Add iterateOnlyExistingCells to Constructors (#3727)
* Add iterateOnlyExistingCells to Constructors

Fix #3721. That issue can already be handled, but requires several statements when one ought to suffice. Adding an extra parameter to the RowCellIterator and ColumnCellIterator constructors is useful, easy, and becomes especially practical now that our supported Php releases all support named parameters (see new test Issue3721Test).

* Update Column.php

* Update .php-cs-fixer.dist.php

* Update Row.php

* Update Column.php

* Update ByColumnAndRowTest.php
2023-09-12 22:28:09 -07:00
Adrien Crivelli 5029e8147e Update coding style 2023-09-13 10:26:51 +08:00
oleibman c5527ba534 Unexpected Namespacing in rels File (#3722)
* Unexpected Namespacing in rels File

Fix #3720. Third-party product created a spreadsheet which PhpSpreadsheet could not read because of unexpected namespacing in workbook.xml.rels.

The file which demonstrated the problem was attached to #3423, however I do not believe it was related to the original problem. Nevertheless, the original issue specifically called out Protection, so I put some Protection tests in the validation test for the fix. In doing so, I found that Style/Protection is particularly confusing. Its properties will often have the value `inherit`, which isn't all that helpful; and, even when the `locked` value is `protected`, the cell won't actually be locked unless the sheet is protected as well. The `hidden` property is even more obscure - it applies only to formulas, and refers to hiding the property on the formula bar, not in the cell. I have added methods `isLocked` and `isHiddenOnFormulaBar` to `Cell`. I corrected the docs to explain this. And, as long as I was looking at the docs, I corrected some examples to use `getHighestDataRow/Column` rather than `getHighestRow/Column`, a frequent problem for users (e.g. #3721).

As a side note, the change to Cell.php is my first use of the nullsafe operator. This is one of many new options available now that we require Php8.0+.

* Minor Simplifications

* Scrutinizer

It's being silly again. In many tests, we test a variable for non-null, then use that variable later and Scrutinizer knows it's not null. Not here. Oh well.

* Add Methods

Test if protected without allocating cell if it doesn't exist.
2023-09-12 19:13:03 -07:00
Adrien Crivelli 7712d5561b Check PHPDoc types of the PR's last commit 2023-09-13 10:06:58 +08:00
Adrien Crivelli ebda3fdda1 Drop dead code 2023-09-13 10:06:58 +08:00
Adrien Crivelli bb6ae9ce7d Prevent adding PHPDoc types instead of native types
PHPDoc types can sometimes be entirely expressed as PHP native types. It
is better because it avoids code duplication and enables type runtime
check.

This will help us slowly migrate away from PHPDoc typing to PHP native typing.
2023-09-13 10:06:58 +08:00
Adrien Crivelli 2a9f2f57b9 Rector MixedTypeRector 2023-09-13 10:06:58 +08:00
Adrien Crivelli f4c1519869 Rector ChangeSwitchToMatchRector 2023-09-13 10:06:58 +08:00
Adrien Crivelli de658b44e1 Rector RemoveUnusedVariableInCatchRector 2023-09-13 10:06:58 +08:00
Adrien Crivelli f6f1e27f98 Rector ClassOnObjectRector 2023-09-13 10:06:58 +08:00
Adrien Crivelli e65e46db43 Rector StringableForToStringRector 2023-09-13 10:06:58 +08:00
Adrien Crivelli b881309496 Rector StrContainsRector, StrStartsWithRector, StrEndsWithRector 2023-09-13 10:06:58 +08:00
Adrien Crivelli bf462986f2 Update changelog 2023-09-12 13:59:19 +08:00
Adrien Crivelli 1b27d9c95d Stronger typing for newly introduced methods 2023-09-12 11:24:02 +08:00
Adrien Crivelli 627f76a803 Merge branch 'master' into powerkiki 2023-09-12 11:07:32 +08:00
Adrien Crivelli 6160dc98a1 phpcs 2023-09-12 11:05:52 +08:00
Adrien Crivelli 8ff38e5856 Clean up FQCN 2023-09-12 10:59:18 +08:00
Adrien Crivelli 80b4ae2bbd Rector TypedPropertyFromStrictSetUpRector 2023-09-12 10:48:13 +08:00
Adrien Crivelli 0e6f413fde Rector TypedPropertyFromStrictGetterMethodReturnTypeRector 2023-09-12 10:35:30 +08:00
Adrien Crivelli b35dd8d268 Rector TypedPropertyFromStrictConstructorRector 2023-09-12 09:22:10 +08:00
Adrien Crivelli 53cd757506 Rector TypedPropertyFromStrictConstructorRector 2023-09-12 00:31:28 +08:00
Adrien Crivelli 29cddd9aa6 Rector StrictStringParamConcatRector 2023-09-11 21:53:39 +08:00
Adrien Crivelli 915bb7eb76 Rector StrictArrayParamDimFetchRector 2023-09-11 21:37:17 +08:00
Adrien Crivelli e221aa61be Rector ReturnUnionTypeRector 2023-09-11 10:21:01 +08:00
Adrien Crivelli 7cffb844c0 Rector ReturnTypeFromStrictTypedCallRector 2023-09-08 17:07:44 +08:00
Adrien Crivelli f13a8da463 Rector ReturnTypeFromStrictParamRector 2023-09-08 13:19:44 +08:00
Adrien Crivelli 129871c1cf PHP is complaining about non-existing BaseReader::listWorksheetInfo()`
But only on GitHub Actions, not in local...

This makes zero sense at all ¯\_(ツ)_/¯
2023-09-08 12:23:57 +08:00
Adrien Crivelli 619a6b4e6c Rector ReturnTypeFromStrictNewArrayRector 2023-09-08 12:08:47 +08:00
Adrien Crivelli de85aa2935 Rector ReturnTypeFromStrictNativeCallRector 2023-09-08 11:46:39 +08:00