Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Various Missing Features in HTML Writer #2343

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1af6c6b
Add Support for Various Missing Features in HTML Writer
oleibman Dec 1, 2022
39b81f0
Fix Regex Test for Php7.1/7.2
oleibman Dec 1, 2022
04bcd34
Php8 Changed Zip Exception to Error
oleibman Dec 1, 2022
403554b
Scrutinizer
oleibman Dec 1, 2022
21b7ee1
Merge branch 'master' into htmlchanges_rebased
oleibman Dec 30, 2022
be3f579
Merge branch 'master' into htmlchanges_rebased
oleibman Jan 16, 2023
5cb7362
Minor Changes for Mpdf
oleibman Apr 12, 2023
e5ec5e4
PhpUnit 10 Problems
oleibman Apr 12, 2023
8c5a381
Change DocBlock Signature in MPDF
oleibman Apr 12, 2023
6a43dcb
Merge branch 'master' into htmlchanges_rebased
oleibman Jun 4, 2023
691eecd
PhpStan
oleibman Jun 5, 2023
f04fc0b
Minor Fix
oleibman Jun 5, 2023
bf56fa1
Refactoring Some Tests
oleibman Jun 6, 2023
3995763
Scrutinizer
oleibman Jun 6, 2023
7cc98b5
Rectify Composer Lock/Json Sync
oleibman Jun 6, 2023
35c8f67
Experiment with Php8.2, Nightly
oleibman Jun 9, 2023
5c4eb3d
PhpUnit 10 Compatibility
oleibman Jun 11, 2023
2583fcf
More PhpUnit 10
oleibman Jun 12, 2023
4e63ba2
If at First ...
oleibman Jun 12, 2023
4747a6f
Tcpdf Changes
oleibman Jun 13, 2023
249896f
TCPDF Vertical Spacing
oleibman Jun 25, 2023
225851d
TCPDF Extend Prior Change
oleibman Jun 26, 2023
2f8c4f9
TCPDF - Use text-indent as Imperfect Surrogate for margin-left
oleibman Jul 3, 2023
688f2e6
Phpstan Problem with Prior Push
oleibman Jul 3, 2023
a83d88d
Php 7.1/2/3 Problem in Prior Push
oleibman Jul 3, 2023
46a661e
Separate HTML and RTF AbstractStyle
oleibman Jul 4, 2023
d6210d4
Final Separation of Writer Rtf from Writer Html
oleibman Jul 4, 2023
fdd4829
Minor PDF Change
oleibman Jul 10, 2023
13dc720
Add Html Callback
oleibman Jul 12, 2023
81dd311
Minor MPDF Improvement
oleibman Jul 15, 2023
2c44e60
Improve Html RTL Support
oleibman Jul 28, 2023
9a854b6
More RTL Support
oleibman Jul 28, 2023
bba396a
Scrutinizer
oleibman Jul 28, 2023
fb95705
More Bidi Fixes
oleibman Aug 2, 2023
f2241b1
Momentary Glitch with CI
oleibman Aug 2, 2023
2f02ff4
Merge branch 'master' into htmlchanges_rebased
oleibman Aug 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
experimental:
- false
php-version:
- "7.1.3"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"

include:
- php-version: 'nightly'
experimental: true

name: PHP ${{ matrix.php-version }}

Expand Down Expand Up @@ -55,7 +62,9 @@ jobs:
- name: Configure matchers
uses: mheap/phpunit-matcher-action@v1

- name: Test with PHPUnit
- name: "Test with PHPUnit (Experimental: ${{ matrix.experimental }})"
env:
FAILURE_ACTION: "${{ matrix.experimental == true }}"
run: ./vendor/bin/phpunit --no-coverage

php-cs-fixer:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ phpword.ini
/nbproject
/.php_cs.cache
/.phpunit.result.cache
/.phpunit.cache
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@
"php": "^7.1|^8.0",
"ext-dom": "*",
"ext-json": "*",
"ext-xml": "*",
"laminas/laminas-escaper": ">=2.6"
"ext-xml": "*"
},
"require-dev": {
"ext-zip": "*",
Expand All @@ -77,7 +76,7 @@
"dompdf/dompdf": "^2.0",
"mpdf/mpdf": "^8.1",
"phpmd/phpmd": "^2.13",
"phpunit/phpunit": ">=7.0",
"phpunit/phpunit": "^7.0 || ^8.5 || ^9.0",
"tecnickcom/tcpdf": "^6.5",
"symfony/process": "^4.4 || ^5.0",
"friendsofphp/php-cs-fixer": "^3.3",
Expand Down
67 changes: 2 additions & 65 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ default font by using the following two functions:
$phpWord->setDefaultFontName('Times New Roman');
$phpWord->setDefaultFontSize(12);

When generating html/pdf, you can alter the default handling of white space (normal),
and/or supply a fallback generic font as follows:

.. code-block:: php

$phpWord->setDefaultHtmlGenericFont('serif');
$phpWord->setDefaultHtmlWhiteSpace('pre-wrap');

Document settings
-----------------
Settings for the generated document can be set using ``$phpWord->getSettings()``
Expand Down
2 changes: 2 additions & 0 deletions docs/styles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Available Font style options:
See ``\PhpOffice\PhpWord\Style\Language`` class for some language codes.
- ``position``. The text position, raised or lowered, in half points
- ``hidden``. Hidden text, *true* or *false*.
- ``htmlWhiteSpace``. How white space is handled when generating html/pdf. Possible values are *pre-wrap* and *normal* (other css values for white space are accepted, but are not expected to be useful).
- ``htmlGenericFont``. Fallback generic font for html/pdf. Possible values are *sans-serif*, *serif*, and *monospace* (other css values for generic fonts are accepted).

.. _paragraph-style:

Expand Down
111 changes: 3 additions & 108 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,6 @@ parameters:

-
message: "#^Method PhpOffice\\\\PhpWord\\\\Shared\\\\XMLReader\\:\\:getElements\\(\\) should return DOMNodeList\\<DOMElement\\> but returns DOMNodeList\\<DOMNode\\>\\.$#"
count: 1
path: src/PhpWord/Shared/XMLReader.php

-
message: "#^Method PhpOffice\\\\PhpWord\\\\Shared\\\\XMLReader\\:\\:getElements\\(\\) should return DOMNodeList\\<DOMElement\\> but returns DOMNodeList\\<DOMNode\\>\\|false\\.$#"
count: 2
path: src/PhpWord/Shared/XMLReader.php

Expand Down Expand Up @@ -731,7 +726,7 @@ parameters:
path: src/PhpWord/Style/AbstractStyle.php

-
message: "#^Method PhpOffice\\\\PhpWord\\\\Style\\\\Border\\:\\:getBorderSize\\(\\) should return array\\<int\\> but returns array\\<int, float\\|int\\>\\.$#"
message: "#^Method PhpOffice\\\\PhpWord\\\\Style\\\\Border\\:\\:getBorderSize\\(\\) should return array\\<int\\> but returns array\\<int, float\\|int\\|null\\>\\.$#"
count: 1
path: src/PhpWord/Style/Border.php

Expand Down Expand Up @@ -966,7 +961,7 @@ parameters:
path: src/PhpWord/Style/Table.php

-
message: "#^Method PhpOffice\\\\PhpWord\\\\Style\\\\Table\\:\\:getBorderSize\\(\\) should return array\\<int\\> but returns array\\<int, float\\|int\\>\\.$#"
message: "#^Method PhpOffice\\\\PhpWord\\\\Style\\\\Table\\:\\:getBorderSize\\(\\) should return array\\<int\\> but returns array\\<int, float\\|int\\|null\\>\\.$#"
count: 1
path: src/PhpWord/Style/Table.php

Expand Down Expand Up @@ -1205,46 +1200,11 @@ parameters:
count: 1
path: src/PhpWord/Writer/HTML/Element/AbstractElement.php

-
message: "#^Call to an undefined method Laminas\\\\Escaper\\\\Escaper\\|PhpOffice\\\\PhpWord\\\\Escaper\\\\AbstractEscaper\\:\\:escapeHtml\\(\\)\\.$#"
count: 1
path: src/PhpWord/Writer/HTML/Element/Link.php

-
message: "#^Call to an undefined method Laminas\\\\Escaper\\\\Escaper\\|PhpOffice\\\\PhpWord\\\\Escaper\\\\AbstractEscaper\\:\\:escapeHtmlAttr\\(\\)\\.$#"
count: 1
path: src/PhpWord/Writer/HTML/Element/Link.php

-
message: "#^Call to an undefined method Laminas\\\\Escaper\\\\Escaper\\|PhpOffice\\\\PhpWord\\\\Escaper\\\\AbstractEscaper\\:\\:escapeHtml\\(\\)\\.$#"
count: 1
path: src/PhpWord/Writer/HTML/Element/ListItem.php

-
message: "#^Variable \\$row in PHPDoc tag @var does not match assigned variable \\$rowStyle\\.$#"
count: 1
path: src/PhpWord/Writer/HTML/Element/Table.php

-
message: "#^Call to an undefined method Laminas\\\\Escaper\\\\Escaper\\|PhpOffice\\\\PhpWord\\\\Escaper\\\\AbstractEscaper\\:\\:escapeHtml\\(\\)\\.$#"
count: 2
path: src/PhpWord/Writer/HTML/Element/Text.php

-
message: "#^Call to an undefined method Laminas\\\\Escaper\\\\Escaper\\|PhpOffice\\\\PhpWord\\\\Escaper\\\\AbstractEscaper\\:\\:escapeHtml\\(\\)\\.$#"
count: 1
path: src/PhpWord/Writer/HTML/Element/Title.php

-
message: "#^Method PhpOffice\\\\PhpWord\\\\Writer\\\\HTML\\\\Style\\\\AbstractStyle\\:\\:write\\(\\) has no return type specified\\.$#"
count: 1
path: src/PhpWord/Writer/HTML/Style/AbstractStyle.php

-
message: "#^Else branch is unreachable because previous condition is always true\\.$#"
count: 1
path: src/PhpWord/Writer/HTML/Style/Paragraph.php

-
message: "#^Method PhpOffice\\\\PhpWord\\\\Writer\\\\ODText\\\\Element\\\\Field\\:\\:writeDefault\\(\\) has parameter \\$type with no type specified\\.$#"
count: 1
Expand Down Expand Up @@ -1305,11 +1265,6 @@ parameters:
count: 1
path: src/PhpWord/Writer/ODText/Part/Styles.php

-
message: "#^Variable \\$indent in empty\\(\\) always exists and is not falsy\\.$#"
count: 1
path: src/PhpWord/Writer/ODText/Style/Paragraph.php

-
message: "#^Parameter \\#1 \\$callback of function call_user_func_array expects callable\\(\\)\\: mixed, array\\{PhpOffice\\\\PhpWord\\\\Writer\\\\PDF\\\\AbstractRenderer, string\\} given\\.$#"
count: 1
Expand Down Expand Up @@ -1360,11 +1315,6 @@ parameters:
count: 1
path: src/PhpWord/Writer/RTF/Element/AbstractElement.php

-
message: "#^Call to an undefined method Laminas\\\\Escaper\\\\Escaper\\|PhpOffice\\\\PhpWord\\\\Escaper\\\\AbstractEscaper\\:\\:escape\\(\\)\\.$#"
count: 1
path: src/PhpWord/Writer/RTF/Element/AbstractElement.php

-
message: "#^Parameter \\#1 \\$value of method PhpOffice\\\\PhpWord\\\\Writer\\\\RTF\\\\Style\\\\Font\\:\\:setNameIndex\\(\\) expects int, int\\|string given\\.$#"
count: 1
Expand Down Expand Up @@ -1445,21 +1395,6 @@ parameters:
count: 1
path: src/PhpWord/Writer/RTF/Style/Border.php

-
message: "#^Variable \\$spaceAfter on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: src/PhpWord/Writer/RTF/Style/Paragraph.php

-
message: "#^Variable \\$spaceBefore on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: src/PhpWord/Writer/RTF/Style/Paragraph.php

-
message: "#^Method PhpOffice\\\\PhpWord\\\\Writer\\\\RTF\\\\Style\\\\Tab\\:\\:write\\(\\) has no return type specified\\.$#"
count: 1
path: src/PhpWord/Writer/RTF/Style/Tab.php

-
message: "#^PHPDoc tag @param has invalid value \\(\\\\PhpOffice\\\\PhpWord\\\\PhpWord\\)\\: Unexpected token \"\\\\n \", expected variable at offset 86$#"
count: 1
Expand Down Expand Up @@ -1510,11 +1445,6 @@ parameters:
count: 1
path: src/PhpWord/Writer/Word2007/Element/SDT.php

-
message: "#^Parameter \\#1 \\$content of method PhpOffice\\\\PhpWord\\\\Writer\\\\Word2007\\\\Element\\\\AbstractElement\\:\\:writeText\\(\\) expects string, PhpOffice\\\\PhpWord\\\\Element\\\\TextRun\\|string given\\.$#"
count: 1
path: src/PhpWord/Writer/Word2007/Element/TOC.php

-
message: "#^Parameter \\#3 \\$indent of method PhpOffice\\\\PhpWord\\\\Writer\\\\Word2007\\\\Element\\\\TOC\\:\\:writeStyle\\(\\) expects int, float\\|int given\\.$#"
count: 1
Expand Down Expand Up @@ -1941,20 +1871,10 @@ parameters:
path: tests/PhpWordTests/TemplateProcessorTest.php

-
message: "#^Method PhpOffice\\\\PhpWordTests\\\\TemplateProcessorTest\\:\\:testTemplateCanBeSavedInTemporaryLocation\\(\\) has no return type specified\\.$#"
message: "#^Method PhpOffice\\\\PhpWordTests\\\\TemplateProcessorTest\\:\\:xtestTemplateCanBeSavedInTemporaryLocation\\(\\) has no return type specified\\.$#"
count: 1
path: tests/PhpWordTests/TemplateProcessorTest.php

-
message: "#^Parameter \\#1 \\$expectedXml of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertXmlStringEqualsXmlString\\(\\) expects DOMDocument\\|string, string\\|false given\\.$#"
count: 3
path: tests/PhpWordTests/TemplateProcessorTest.php

-
message: "#^Parameter \\#2 \\$actualXml of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertXmlStringEqualsXmlString\\(\\) expects DOMDocument\\|string, string\\|false given\\.$#"
count: 3
path: tests/PhpWordTests/TemplateProcessorTest.php

-
message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#"
count: 6
Expand Down Expand Up @@ -1995,21 +1915,6 @@ parameters:
count: 1
path: tests/PhpWordTests/TestableTemplateProcesor.php

-
message: "#^Cannot access property \\$length on DOMNodeList\\<DOMNode\\>\\|false\\.$#"
count: 6
path: tests/PhpWordTests/Writer/HTML/ElementTest.php

-
message: "#^Cannot call method item\\(\\) on DOMNodeList\\<DOMNode\\>\\|false\\.$#"
count: 8
path: tests/PhpWordTests/Writer/HTML/ElementTest.php

-
message: "#^Method PhpOffice\\\\PhpWordTests\\\\Writer\\\\HTML\\\\ElementTest\\:\\:getAsHTML\\(\\) has no return type specified\\.$#"
count: 1
path: tests/PhpWordTests/Writer/HTML/ElementTest.php

-
message: "#^Method PhpOffice\\\\PhpWordTests\\\\Writer\\\\ODText\\\\Style\\\\FontTest\\:\\:providerAllNamedColors\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -2065,16 +1970,6 @@ parameters:
count: 2
path: tests/PhpWordTests/Writer/PDF/DomPDFTest.php

-
message: "#^Call to an undefined method PhpOffice\\\\PhpWord\\\\Writer\\\\PDF\\:\\:save\\(\\)\\.$#"
count: 1
path: tests/PhpWordTests/Writer/PDF/MPDFTest.php

-
message: "#^Parameter \\#2 \\$libraryBaseDir of static method PhpOffice\\\\PhpWord\\\\Settings\\:\\:setPdfRenderer\\(\\) expects string, string\\|false given\\.$#"
count: 1
path: tests/PhpWordTests/Writer/PDF/MPDFTest.php

-
message: "#^Call to an undefined method PhpOffice\\\\PhpWord\\\\Writer\\\\PDF\\:\\:save\\(\\)\\.$#"
count: 1
Expand Down
41 changes: 19 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="PhpWord Test Suite">
<directory>./tests/PhpWordTests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
<exclude>
<directory suffix=".php">./src/PhpWordTests/Shared/PCLZip</directory>
</exclude>
</whitelist>
</filter>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="./tests/bootstrap.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" convertDeprecationsToExceptions="true">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory suffix=".php">./src/PhpWordTests/Shared/PCLZip</directory>
</exclude>
</coverage>
<php>
<ini name="error_reporting" value="E_ALL"/>
</php>
<testsuites>
<testsuite name="PhpWord Test Suite">
<directory>./tests/PhpWordTests</directory>
<exclude>./tests/PhpWordTests/AbstractWebServerEmbeddedTest.php</exclude>
</testsuite>
</testsuites>
</phpunit>
Loading