From 4bb74e296cabc1429b7d64598014cdb6ff8382b8 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 12:19:18 +0100 Subject: [PATCH 01/51] Added extractVariables method to IOFactory --- ..._44_ExtractVariablesFromReaderWord2007.php | 14 ++++ samples/Sample_Header.php | 1 + ...44_ExtractVariablesFromReaderWord2007.docx | Bin 0 -> 12981 bytes src/PhpWord/IOFactory.php | 66 ++++++++++++++++++ tests/PhpWordTests/IOFactoryTest.php | 14 ++++ .../_files/templates/extract-variable.docx | Bin 0 -> 12575 bytes 6 files changed, 95 insertions(+) create mode 100644 samples/Sample_44_ExtractVariablesFromReaderWord2007.php create mode 100644 samples/resources/Sample_44_ExtractVariablesFromReaderWord2007.docx create mode 100644 tests/PhpWordTests/_files/templates/extract-variable.docx diff --git a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php new file mode 100644 index 0000000000..f04ef0593a --- /dev/null +++ b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php @@ -0,0 +1,14 @@ +9(1d|z* z_F-_mz}24O2U?%o(ZLl}!Q$X;NGaHER@v10116W!ZQxMr+$avQ1(N*|^enmP7UzF3 z_?qBSZX`0V3J-C9wqb8=!xyghWY72*oV>0xxmSxrcr{6VCsP||CdS|7|4i}!u>Jkzrtc3YctDT|C2Y4U&C*p7|ZcePKcLaJg_{Ob^~>I%rzY zyWu;yLYyZgnzi~H_V}5)!WXZB>A&s6TPpKu{?&4P&;S6`*O%gE?_|PcVsHG>_BC$( z7O;M%O520DQ3g&BF8OdofMI&|6bMxaT=g|P7|fiy20%n{X)$pnVoN@|$&+?b%{L&a zn(7)0XA9)G+fuME$RV=`!eg~q18oL3vy}D zGf3`Cv-H8Z-=_;sMII0^XBh?wC;B#Zl2w+%jmCVZgyckL8G3BY3$3b4=BGUZT6t}G z);2H^B?bMgerX#jr$_D^x0Pg_5OGMFY8`iQr9pz8hOhRpM8{87y{K;jvFL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string $filename The name of the file + * @param string $readerName + * + * @return \PhpOffice\PhpWord\PhpWord $phpWord + */ + public static function extractVariables($filename, $readerName = 'Word2007') + { + /** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */ + $reader = self::createReader($readerName); + $document = $reader->load($filename); + $extractedVariables = []; + foreach ($document->getSections() as $section) { + // Concatenate text from all elements + $concatenatedText = ''; + + foreach ($section->getElements() as $element) { + if ($element instanceof TextRun) { + foreach ($element->getElements() as $textElement) { + if (method_exists($textElement, 'getText')) { + $text = $textElement->getText(); + // Check if $text is a string before concatenation + if (is_string($text)) { + $concatenatedText .= $text; + } else { + error_log("Expected a string, but got a different type: " . print_r($text, true)); + } + } + } + } elseif (method_exists($element, 'getText')) { + $text = $element->getText(); + // Check if $text is a string before concatenation + if (is_string($text)) { + $concatenatedText .= $text; + } else { + // Handle the case where $text is not a string + error_log("Expected a string, but got a different type: " . print_r($text, true)); + } + } + } + + // Regex to find all occurrences of text that starts with ${ + preg_match_all('/\$\{([^}]+)\}/', $concatenatedText, $matches); + + if (!empty($matches[1])) { + foreach ($matches[1] as $match) { + // Ensure $match is a string before adding to the array + $trimmedMatch = trim($match); + if (is_string($trimmedMatch)) { + $extractedVariables[] = $trimmedMatch; + } else { + // Log non-string matches for debugging + error_log("Non-string match found: " . print_r($match, true)); + } + } + } + } + + return $extractedVariables; + } /** * Check if it's a concrete class (not abstract nor interface). @@ -102,4 +167,5 @@ private static function isConcreteClass($class) return !$reflection->isAbstract() && !$reflection->isInterface(); } + } diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index ee8d7fe180..4cdf96e059 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -116,4 +116,18 @@ public function testLoad(): void IOFactory::load($file) ); } + + /** + * Test for extractVariables method. + */ + public function testExtractVariables(): void + { + $file = __DIR__ . '/_files/templates/extract-variable.docx'; + + $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); + + $expectedVariables = ['date', 'A1', 'B1']; + + $this->assertEquals($expectedVariables, $extractedVariables, "Extracted variables do not match expected variables."); + } } diff --git a/tests/PhpWordTests/_files/templates/extract-variable.docx b/tests/PhpWordTests/_files/templates/extract-variable.docx new file mode 100644 index 0000000000000000000000000000000000000000..f95ec61862f7b5bc97a8eb65f5f3ce24407dd88d GIT binary patch literal 12575 zcmeIYg;!k3);`=wAZTz4F2SL3LU4C?cXt{M65QP-xJ&Q=!QEYhy9ajy{CZ~Y+?ks@ z-}eu^_pDyE`kbm~pX%yuwd;|Wf`Y~XzyMwY000ueTK<%^CIkRL{0aa-2fT*V60)-e znb?B#l-=!3oOBr6Y^;fMp&_ZV0g&MF|GWMVuRvYGux%F*MdUW|;Z1CVis624DGg*e zZxX%Y0W8i(NY$sf{+8!9bVvmih*)@QQVN#aRTkAg|H;KPYdF+;SBfKSo+RIRT?-D{ z@AKRAKE}B3HWGlV0)y8XjO8LNEX6? zpI9vGx2>yC$*UCh)N=K(Z;^Gg(GcQm=GnY##Yu6DzdKEee z%f~n_`8yGuMd9J_rO2yA!5)K%K&%S11AU~0t_CIHm7dDl?oCzsbh1nM>sKlT6m<`a z^umk~v17|=xfSX;E154;u!WHjE!-koO9XGIW7qKjANFJeFs1n_MbC#@(DQSbLsRe? zxkas3;9||8a@=pmcNZ2j!t%!)t{^P(w)py1E3GTWEY<-`2h%<}>Ed%{A$Us|x7e}3X#Sb)?yFc2G_nvS3FaLN#M zUQf_D!%I>@3TuU%yVvd3dTen6BnGw=FuBdyZz87e-k3fOkx5Vw`G;#@hK=LF#NLIZ zjCP>!&nLPB!YcJ{z4Wxt1feU4P^fc8* z(|q0w+r{N$KPAzq)7!9no1r6c2@XvEZ6Cp7^y`^m%Rxg00KgxBtDU1Uqp_Wlvkf?I z{T8r}Q{?QHxDY!|p;ldAN9bs2M8!9X#*=6)ehG%?JR+wr4``K3)e6M9ViEh%Z7 zWasV})bv3dtpWJ~gHcxmfCSVyey}VNF(?$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}Mz?YI*oMC%Oll+f=biDSNwkl Date: Thu, 30 Nov 2023 12:25:44 +0100 Subject: [PATCH 02/51] remove var_dumps --- samples/Sample_Header.php | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index 3c8b8b6736..8d05a2a34e 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -47,7 +47,6 @@ while (false !== ($sampleFile = readdir($handle))) { $sampleFiles[] = $sampleFile; } - var_dump($sampleFiles); sort($sampleFiles); closedir($handle); From b01e2663be97bdeaee098874a9b7327993ae6078 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 12:30:56 +0100 Subject: [PATCH 03/51] remove vardump --- samples/Sample_44_ExtractVariablesFromReaderWord2007.php | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php index f04ef0593a..9994f6e2e5 100644 --- a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php +++ b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php @@ -10,5 +10,4 @@ echo date('H:i:s'), " Reading contents from `{$source}`", EOL; $phpWord = \PhpOffice\PhpWord\IOFactory::extractVariables($source); -var_dump($phpWord); From 9268ba5ee96e1189d552ee3fab4197d8988c3379 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:10:00 +0100 Subject: [PATCH 04/51] fix return and fix php stan errors and instances --- src/PhpWord/IOFactory.php | 46 ++++++++++++--------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 8557084995..85d52e0dfb 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -17,12 +17,13 @@ namespace PhpOffice\PhpWord; + +use ReflectionClass; +use PhpOffice\PhpWord\Element\Text; +use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Reader\ReaderInterface; use PhpOffice\PhpWord\Writer\WriterInterface; -/* TextRun Element */ -use PhpOffice\PhpWord\Element\TextRun; -use ReflectionClass; abstract class IOFactory { @@ -96,57 +97,38 @@ public static function load($filename, $readerName = 'Word2007') * * @param string $filename The name of the file * @param string $readerName + * @return array The extracted variables * - * @return \PhpOffice\PhpWord\PhpWord $phpWord */ - public static function extractVariables($filename, $readerName = 'Word2007') + public static function extractVariables(string $filename, $readerName = 'Word2007') { /** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */ $reader = self::createReader($readerName); $document = $reader->load($filename); $extractedVariables = []; foreach ($document->getSections() as $section) { - // Concatenate text from all elements $concatenatedText = ''; - + foreach ($section->getElements() as $element) { if ($element instanceof TextRun) { foreach ($element->getElements() as $textElement) { - if (method_exists($textElement, 'getText')) { + if ($textElement instanceof Text) { $text = $textElement->getText(); - // Check if $text is a string before concatenation - if (is_string($text)) { - $concatenatedText .= $text; - } else { - error_log("Expected a string, but got a different type: " . print_r($text, true)); - } + $concatenatedText .= $text; } } - } elseif (method_exists($element, 'getText')) { + } elseif ($element instanceof Text) { $text = $element->getText(); - // Check if $text is a string before concatenation - if (is_string($text)) { - $concatenatedText .= $text; - } else { - // Handle the case where $text is not a string - error_log("Expected a string, but got a different type: " . print_r($text, true)); - } + $concatenatedText .= $text; } } - - // Regex to find all occurrences of text that starts with ${ + preg_match_all('/\$\{([^}]+)\}/', $concatenatedText, $matches); - + if (!empty($matches[1])) { foreach ($matches[1] as $match) { - // Ensure $match is a string before adding to the array $trimmedMatch = trim($match); - if (is_string($trimmedMatch)) { - $extractedVariables[] = $trimmedMatch; - } else { - // Log non-string matches for debugging - error_log("Non-string match found: " . print_r($match, true)); - } + $extractedVariables[] = $trimmedMatch; } } } From bf69d1877cb847d9e2df796e8b2fe6e6f90dec6f Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:15:14 +0100 Subject: [PATCH 05/51] fix order and whitespace --- src/PhpWord/IOFactory.php | 3 +-- tests/PhpWordTests/IOFactoryTest.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 85d52e0dfb..95ad2cd7bc 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -17,13 +17,12 @@ namespace PhpOffice\PhpWord; - -use ReflectionClass; use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Reader\ReaderInterface; use PhpOffice\PhpWord\Writer\WriterInterface; +use ReflectionClass; abstract class IOFactory { diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index 4cdf96e059..bc6407619f 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -128,6 +128,6 @@ public function testExtractVariables(): void $expectedVariables = ['date', 'A1', 'B1']; - $this->assertEquals($expectedVariables, $extractedVariables, "Extracted variables do not match expected variables."); + self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); } } From e6ba84aa9482fe03ac1ec1224dbfe1d4effc349b Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:15:40 +0100 Subject: [PATCH 06/51] extra space --- samples/Sample_44_ExtractVariablesFromReaderWord2007.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php index 9994f6e2e5..36883c994f 100644 --- a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php +++ b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php @@ -8,6 +8,4 @@ $source = __DIR__ . "/resources/{$name}.docx"; echo date('H:i:s'), " Reading contents from `{$source}`", EOL; -$phpWord = \PhpOffice\PhpWord\IOFactory::extractVariables($source); - - +$phpWord = \PhpOffice\PhpWord\IOFactory::extractVariables($source); \ No newline at end of file From c90df91e80382cd37c292473088ba2b2c3212e74 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:21:36 +0100 Subject: [PATCH 07/51] remove new lines --- src/PhpWord/IOFactory.php | 4 ---- tests/PhpWordTests/IOFactoryTest.php | 3 --- 2 files changed, 7 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 95ad2cd7bc..38c09b21e5 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -107,7 +107,6 @@ public static function extractVariables(string $filename, $readerName = 'Word200 $extractedVariables = []; foreach ($document->getSections() as $section) { $concatenatedText = ''; - foreach ($section->getElements() as $element) { if ($element instanceof TextRun) { foreach ($element->getElements() as $textElement) { @@ -121,9 +120,7 @@ public static function extractVariables(string $filename, $readerName = 'Word200 $concatenatedText .= $text; } } - preg_match_all('/\$\{([^}]+)\}/', $concatenatedText, $matches); - if (!empty($matches[1])) { foreach ($matches[1] as $match) { $trimmedMatch = trim($match); @@ -131,7 +128,6 @@ public static function extractVariables(string $filename, $readerName = 'Word200 } } } - return $extractedVariables; } diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index bc6407619f..0d2ac1f856 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -123,11 +123,8 @@ public function testLoad(): void public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; - $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); - $expectedVariables = ['date', 'A1', 'B1']; - self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); } } From 41beb2db578855d62fc5a6abb73525c51921f7da Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:24:38 +0100 Subject: [PATCH 08/51] white space --- samples/Sample_44_ExtractVariablesFromReaderWord2007.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php index 36883c994f..8a6033c07a 100644 --- a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php +++ b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php @@ -4,8 +4,6 @@ // Read contents $name = basename(__FILE__, '.php'); - $source = __DIR__ . "/resources/{$name}.docx"; - echo date('H:i:s'), " Reading contents from `{$source}`", EOL; $phpWord = \PhpOffice\PhpWord\IOFactory::extractVariables($source); \ No newline at end of file From a08da1e2b32cb89c1e7dfe3e75bcb4c3fd640fe6 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:29:07 +0100 Subject: [PATCH 09/51] new lines --- samples/Sample_44_ExtractVariablesFromReaderWord2007.php | 2 +- src/PhpWord/IOFactory.php | 6 +++--- tests/PhpWordTests/IOFactoryTest.php | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php index 8a6033c07a..741efc1b5e 100644 --- a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php +++ b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php @@ -6,4 +6,4 @@ $name = basename(__FILE__, '.php'); $source = __DIR__ . "/resources/{$name}.docx"; echo date('H:i:s'), " Reading contents from `{$source}`", EOL; -$phpWord = \PhpOffice\PhpWord\IOFactory::extractVariables($source); \ No newline at end of file +$phpWord = \PhpOffice\PhpWord\IOFactory::extractVariables($source); diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 38c09b21e5..f48d8e2371 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -90,14 +90,14 @@ public static function load($filename, $readerName = 'Word2007') return $reader->load($filename); } - + /** * Loads PhpWord ${variable} from file. * * @param string $filename The name of the file * @param string $readerName - * @return array The extracted variables * + * @return array The extracted variables */ public static function extractVariables(string $filename, $readerName = 'Word2007') { @@ -128,6 +128,7 @@ public static function extractVariables(string $filename, $readerName = 'Word200 } } } + return $extractedVariables; } @@ -144,5 +145,4 @@ private static function isConcreteClass($class) return !$reflection->isAbstract() && !$reflection->isInterface(); } - } diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index 0d2ac1f856..fbcbf5bfe7 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -124,6 +124,7 @@ public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); + $expectedVariables = ['date', 'A1', 'B1']; self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); } From 96a4ea1e75e788c7b22abf23bcc717e158addc02 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:31:18 +0100 Subject: [PATCH 10/51] whiteline --- tests/PhpWordTests/IOFactoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index fbcbf5bfe7..6d6f763d09 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -124,8 +124,8 @@ public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); - $expectedVariables = ['date', 'A1', 'B1']; + self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); } } From 170339e52ed992cbff0ad2e288cf7376fe121a6f Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:32:29 +0100 Subject: [PATCH 11/51] new line --- tests/PhpWordTests/IOFactoryTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index 6d6f763d09..9047f468f4 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -124,6 +124,7 @@ public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); + $expectedVariables = ['date', 'A1', 'B1']; self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); From 7be3cdb8a0ca7af53bce15a10d46adcd022f775c Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:35:50 +0100 Subject: [PATCH 12/51] white space --- tests/PhpWordTests/IOFactoryTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index 9047f468f4..bccea3e699 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -124,9 +124,9 @@ public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); - - $expectedVariables = ['date', 'A1', 'B1']; - + + $expectedVariables = ['date', 'A1', 'B1']; + self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); - } + } } From 42673c9351caf700b5c567b098f6a08522f194b0 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:41:47 +0100 Subject: [PATCH 13/51] fix --- tests/PhpWordTests/IOFactoryTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index bccea3e699..79f0fd0c76 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -124,9 +124,9 @@ public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); - + $expectedVariables = ['date', 'A1', 'B1']; - + self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); - } + } } From 0b8f9f43bdd68334c70d88b430236084baf5e2aa Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 14:12:35 +0100 Subject: [PATCH 14/51] new line --- src/PhpWord/IOFactory.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index f48d8e2371..030e31a1fe 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -12,8 +12,7 @@ * * @see https://github.com/PHPOffice/PHPWord * - * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - */ + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; From 33b1d0cb9e0788e18a12535411c5a9cfbad2f88e Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 14:35:28 +0100 Subject: [PATCH 15/51] white space --- src/PhpWord/IOFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 030e31a1fe..983257a35d 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -116,6 +116,7 @@ public static function extractVariables(string $filename, $readerName = 'Word200 } } elseif ($element instanceof Text) { $text = $element->getText(); + $concatenatedText .= $text; } } From f618d673029a917610d0a5f0537fb69f050ce6a2 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 15:56:29 +0100 Subject: [PATCH 16/51] remove some unneecessary if statement --- src/PhpWord/IOFactory.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 983257a35d..f03168d174 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -114,10 +114,6 @@ public static function extractVariables(string $filename, $readerName = 'Word200 $concatenatedText .= $text; } } - } elseif ($element instanceof Text) { - $text = $element->getText(); - - $concatenatedText .= $text; } } preg_match_all('/\$\{([^}]+)\}/', $concatenatedText, $matches); From 447b3fd1f31ebf2ef6f16132bd4d597e0f545d60 Mon Sep 17 00:00:00 2001 From: oleibman <10341515+oleibman@users.noreply.github.com> Date: Sun, 17 Dec 2023 00:20:25 -0800 Subject: [PATCH 17/51] Correct Font Size Calculated by MsDoc Reader Fix #2526. Most of that issue has already been fixed. The one remaining problem was a deprecation message handling font size. The code used `dechex($operand / 2)`, and issued the deprecation message whenever `$operand` was odd because `dechex` is designed only for integer conversion. `$operand` is actually 2 times the point size, so it will be odd only when the point size is some integer plus half a point (no other fractions are allowed). At any rate, it seems that `dechex` should not be used here in the first place; font size is a numeric value, not a hex string. There are many problems with MsDoc Reader at the moment. This PR is narrowly focused on the problem at hand. Its test is, at least, more detailed than the existing MsDoc Reader test, which does nothing more than confirm that read successfully creates a PhpWord object. The new test verifies that the font size is as expected, but does not validate any other aspect of the read. --- src/PhpWord/Reader/MsDoc.php | 2 +- tests/PhpWordTests/Reader/MsDocTest.php | 16 ++++++++++++++++ .../PhpWordTests/_files/documents/word.2526.doc | Bin 0 -> 24576 bytes 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/PhpWordTests/_files/documents/word.2526.doc diff --git a/src/PhpWord/Reader/MsDoc.php b/src/PhpWord/Reader/MsDoc.php index 4cf755e3fa..2599e42350 100644 --- a/src/PhpWord/Reader/MsDoc.php +++ b/src/PhpWord/Reader/MsDoc.php @@ -1871,7 +1871,7 @@ private function readPrl($data, $pos, $cbNum) break; // sprmCHps case 0x43: - $oStylePrl->styleFont['size'] = dechex($operand / 2); + $oStylePrl->styleFont['size'] = $operand / 2; break; // sprmCIss diff --git a/tests/PhpWordTests/Reader/MsDocTest.php b/tests/PhpWordTests/Reader/MsDocTest.php index deb8b9badd..f5f75ab790 100644 --- a/tests/PhpWordTests/Reader/MsDocTest.php +++ b/tests/PhpWordTests/Reader/MsDocTest.php @@ -60,6 +60,22 @@ public function testLoad(): void self::assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $phpWord); } + public function testLoadHalfPointFont(): void + { + $filename = __DIR__ . '/../_files/documents/word.2526.doc'; + $phpWord = IOFactory::load($filename, 'MsDoc'); + $sections = $phpWord->getSections(); + self::assertCount(1, $sections); + $elements = $sections[0]->getElements(); + self::assertArrayHasKey(0, $elements); + $element0 = $elements[0]; + if (method_exists($element0, 'getFontStyle')) { + self::assertSame(19.5, $element0->getFontStyle()->getSize()); + } else { + self::fail('Unexpected no font style for first element'); + } + } + /** * Test exception on not existing file. */ diff --git a/tests/PhpWordTests/_files/documents/word.2526.doc b/tests/PhpWordTests/_files/documents/word.2526.doc new file mode 100644 index 0000000000000000000000000000000000000000..94fc5ed8fd566e4cdaa44b6f1eb8b520773454d1 GIT binary patch literal 24576 zcmeG^2V9fMvzvrOM37KKni3F|<1hrJsfSV(DFUKkIe`G7D1;bLu^p(`@D#B3a*AL% zL_F*wf+u1*u~!u9*+mXT&(pk_FMJYna_Ikm@4f$fm*qF#)|uIzo!xI|z718Ub!yh{ zFup~ULLb5+?`5qCN1>bn>96TLmym9d#-B=;~GLRza4QmcCi zCy@{V^;9QBAD}IX92GgLWJAdYs`R5rYc&I6-=yq4lOjqQ}<8K#5) z88QoE44)HQLc0_*LUsY7wFM#WklzaU?T~;{pyfdGRjMX*d2=z+RSYyeI;O`>x54~1 z$dm$}0mL1QA zX*tpQRsVQ_0~mjHTzK@0F< z(p+fxc&KEszbWH0b9V@W=A?JperGU99+9DXWNmu>?%p#og{RhZw|F zIC&8dpRPm*km%i7Eg66elGi$@PjytE>ZCrkk98||YYsN^wq^wQ5E2Lw1Ta#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IBMm+n+Lklbk7Yhxbb>Ab%S33_27Y%d2Ay5 is)sro_y=Ph`kir6W13Ib^PNe3&!RC Date: Sun, 17 Dec 2023 14:03:54 -0800 Subject: [PATCH 18/51] Suggestions from @Progi1984 --- docs/changes/1.x/1.3.0.md | 14 ++++++++++++++ tests/PhpWordTests/Reader/MsDocTest.php | 2 +- .../{word.2526.doc => reader.font-halfpoint.doc} | Bin 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 docs/changes/1.x/1.3.0.md rename tests/PhpWordTests/_files/documents/{word.2526.doc => reader.font-halfpoint.doc} (100%) diff --git a/docs/changes/1.x/1.3.0.md b/docs/changes/1.x/1.3.0.md new file mode 100644 index 0000000000..e85d9ff892 --- /dev/null +++ b/docs/changes/1.x/1.3.0.md @@ -0,0 +1,14 @@ +# [1.2.0](https://github.com/PHPOffice/PHPWord/tree/1.2.0) (WIP) + +[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.2.0...1.3.0) + +## Enhancements + +### Bug fixes + +- MsDoc Reader : Correct Font Size Calculation by [@oleibman](https://github.com/oleibman) Issue [#2526](https://github.com/PHPOffice/PHPWord/issues/2526) PR [#2531](https://github.com/PHPOffice/PHPWord/pull/2531) + +### Miscellaneous + + +### BC Breaks diff --git a/tests/PhpWordTests/Reader/MsDocTest.php b/tests/PhpWordTests/Reader/MsDocTest.php index f5f75ab790..cf4db6d0d9 100644 --- a/tests/PhpWordTests/Reader/MsDocTest.php +++ b/tests/PhpWordTests/Reader/MsDocTest.php @@ -62,7 +62,7 @@ public function testLoad(): void public function testLoadHalfPointFont(): void { - $filename = __DIR__ . '/../_files/documents/word.2526.doc'; + $filename = __DIR__ . '/../_files/documents/reader.font-halfpoint.doc '; $phpWord = IOFactory::load($filename, 'MsDoc'); $sections = $phpWord->getSections(); self::assertCount(1, $sections); diff --git a/tests/PhpWordTests/_files/documents/word.2526.doc b/tests/PhpWordTests/_files/documents/reader.font-halfpoint.doc similarity index 100% rename from tests/PhpWordTests/_files/documents/word.2526.doc rename to tests/PhpWordTests/_files/documents/reader.font-halfpoint.doc From 4ae15ba80f51718bfd669d63ae5a979d38581dc2 Mon Sep 17 00:00:00 2001 From: oleibman <10341515+oleibman@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:09:32 -0800 Subject: [PATCH 19/51] Typo Tolerated By Windows but Not By Unix --- tests/PhpWordTests/Reader/MsDocTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpWordTests/Reader/MsDocTest.php b/tests/PhpWordTests/Reader/MsDocTest.php index cf4db6d0d9..b62d545de0 100644 --- a/tests/PhpWordTests/Reader/MsDocTest.php +++ b/tests/PhpWordTests/Reader/MsDocTest.php @@ -62,7 +62,7 @@ public function testLoad(): void public function testLoadHalfPointFont(): void { - $filename = __DIR__ . '/../_files/documents/reader.font-halfpoint.doc '; + $filename = __DIR__ . '/../_files/documents/reader.font-halfpoint.doc'; $phpWord = IOFactory::load($filename, 'MsDoc'); $sections = $phpWord->getSections(); self::assertCount(1, $sections); From 5bc9c6a0d3832ba3fce34995f2730250a0e29fd7 Mon Sep 17 00:00:00 2001 From: oleibman <10341515+oleibman@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:16:40 -0800 Subject: [PATCH 20/51] Correct Title Line of Change Log --- docs/changes/1.x/1.3.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changes/1.x/1.3.0.md b/docs/changes/1.x/1.3.0.md index e85d9ff892..e3514080ac 100644 --- a/docs/changes/1.x/1.3.0.md +++ b/docs/changes/1.x/1.3.0.md @@ -1,4 +1,4 @@ -# [1.2.0](https://github.com/PHPOffice/PHPWord/tree/1.2.0) (WIP) +# [1.3.0](https://github.com/PHPOffice/PHPWord/tree/1.3.0) (WIP) [Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.2.0...1.3.0) From fb816313d0e093febc71d3fdc6ed0a42f75a2fc6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Dec 2023 23:32:29 +0000 Subject: [PATCH 21/51] Bump dompdf/dompdf from 2.0.3 to 2.0.4 Bumps [dompdf/dompdf](https://github.com/dompdf/dompdf) from 2.0.3 to 2.0.4. - [Release notes](https://github.com/dompdf/dompdf/releases) - [Commits](https://github.com/dompdf/dompdf/compare/v2.0.3...v2.0.4) --- updated-dependencies: - dependency-name: dompdf/dompdf dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.lock | 42 ++++++++++++++++++++------------------- docs/changes/1.x/1.2.0.md | 2 +- docs/changes/1.x/1.3.0.md | 14 ------------- docs/changes/2.x/2.0.0.md | 15 ++++++++++++++ mkdocs.yml | 4 +++- 5 files changed, 41 insertions(+), 36 deletions(-) delete mode 100644 docs/changes/1.x/1.3.0.md create mode 100644 docs/changes/2.x/2.0.0.md diff --git a/composer.lock b/composer.lock index 0f140f1e5a..d1a795a886 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "23680170abecc52de95d0833296ced64", + "content-hash": "8d0272c1442e11290de55a7947fc849c", "packages": [ { "name": "phpoffice/math", @@ -548,16 +548,16 @@ }, { "name": "dompdf/dompdf", - "version": "v2.0.3", + "version": "v2.0.4", "source": { "type": "git", "url": "https://github.com/dompdf/dompdf.git", - "reference": "e8d2d5e37e8b0b30f0732a011295ab80680d7e85" + "reference": "093f2d9739cec57428e39ddadedfd4f3ae862c0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dompdf/dompdf/zipball/e8d2d5e37e8b0b30f0732a011295ab80680d7e85", - "reference": "e8d2d5e37e8b0b30f0732a011295ab80680d7e85", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/093f2d9739cec57428e39ddadedfd4f3ae862c0f", + "reference": "093f2d9739cec57428e39ddadedfd4f3ae862c0f", "shasum": "" }, "require": { @@ -604,9 +604,9 @@ "homepage": "https://github.com/dompdf/dompdf", "support": { "issues": "https://github.com/dompdf/dompdf/issues", - "source": "https://github.com/dompdf/dompdf/tree/v2.0.3" + "source": "https://github.com/dompdf/dompdf/tree/v2.0.4" }, - "time": "2023-02-07T12:51:48+00:00" + "time": "2023-12-12T20:19:39+00:00" }, { "name": "friendsofphp/php-cs-fixer", @@ -699,16 +699,16 @@ }, { "name": "masterminds/html5", - "version": "2.8.0", + "version": "2.8.1", "source": { "type": "git", "url": "https://github.com/Masterminds/html5-php.git", - "reference": "3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3" + "reference": "f47dcf3c70c584de14f21143c55d9939631bc6cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3", - "reference": "3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3", + "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f47dcf3c70c584de14f21143c55d9939631bc6cf", + "reference": "f47dcf3c70c584de14f21143c55d9939631bc6cf", "shasum": "" }, "require": { @@ -760,9 +760,9 @@ ], "support": { "issues": "https://github.com/Masterminds/html5-php/issues", - "source": "https://github.com/Masterminds/html5-php/tree/2.8.0" + "source": "https://github.com/Masterminds/html5-php/tree/2.8.1" }, - "time": "2023-04-26T07:27:39+00:00" + "time": "2023-05-10T11:58:31+00:00" }, { "name": "mpdf/mpdf", @@ -1322,16 +1322,16 @@ }, { "name": "phenx/php-svg-lib", - "version": "0.5.0", + "version": "0.5.1", "source": { "type": "git", "url": "https://github.com/dompdf/php-svg-lib.git", - "reference": "76876c6cf3080bcb6f249d7d59705108166a6685" + "reference": "8a8a1ebcf6aea861ef30197999f096f7bd4b4456" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/76876c6cf3080bcb6f249d7d59705108166a6685", - "reference": "76876c6cf3080bcb6f249d7d59705108166a6685", + "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/8a8a1ebcf6aea861ef30197999f096f7bd4b4456", + "reference": "8a8a1ebcf6aea861ef30197999f096f7bd4b4456", "shasum": "" }, "require": { @@ -1362,9 +1362,9 @@ "homepage": "https://github.com/PhenX/php-svg-lib", "support": { "issues": "https://github.com/dompdf/php-svg-lib/issues", - "source": "https://github.com/dompdf/php-svg-lib/tree/0.5.0" + "source": "https://github.com/dompdf/php-svg-lib/tree/0.5.1" }, - "time": "2022-09-06T12:16:56+00:00" + "time": "2023-12-11T20:56:08+00:00" }, { "name": "php-cs-fixer/diff", @@ -5060,7 +5060,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "phpstan/phpstan-phpunit": 0 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/docs/changes/1.x/1.2.0.md b/docs/changes/1.x/1.2.0.md index 30d3b35202..265d25b033 100644 --- a/docs/changes/1.x/1.2.0.md +++ b/docs/changes/1.x/1.2.0.md @@ -1,4 +1,4 @@ -# [1.2.0](https://github.com/PHPOffice/PHPWord/tree/1.2.0) (WIP) +# [1.2.0](https://github.com/PHPOffice/PHPWord/tree/1.2.0) [Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.1.0...1.2.0) diff --git a/docs/changes/1.x/1.3.0.md b/docs/changes/1.x/1.3.0.md deleted file mode 100644 index e3514080ac..0000000000 --- a/docs/changes/1.x/1.3.0.md +++ /dev/null @@ -1,14 +0,0 @@ -# [1.3.0](https://github.com/PHPOffice/PHPWord/tree/1.3.0) (WIP) - -[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.2.0...1.3.0) - -## Enhancements - -### Bug fixes - -- MsDoc Reader : Correct Font Size Calculation by [@oleibman](https://github.com/oleibman) Issue [#2526](https://github.com/PHPOffice/PHPWord/issues/2526) PR [#2531](https://github.com/PHPOffice/PHPWord/pull/2531) - -### Miscellaneous - - -### BC Breaks diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md new file mode 100644 index 0000000000..cac743cd13 --- /dev/null +++ b/docs/changes/2.x/2.0.0.md @@ -0,0 +1,15 @@ +# [2.0.0](https://github.com/PHPOffice/PHPWord/tree/2.0.0) (WIP) + +[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.2.0...2.0.0) + +## Enhancements + +### Bug fixes + +- MsDoc Reader : Correct Font Size Calculation by [@oleibman](https://github.com/oleibman) fixing [#2526](https://github.com/PHPOffice/PHPWord/issues/2526) in [#2531](https://github.com/PHPOffice/PHPWord/pull/2531) + +### Miscellaneous + +- Bump dompdf/dompdf from 2.0.3 to 2.0.4 by [@dependabot](https://github.com/dependabot) in [#2530](https://github.com/PHPOffice/PHPWord/pull/2530) + +### BC Breaks diff --git a/mkdocs.yml b/mkdocs.yml index a58ebfdad6..6eb4d42911 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -86,8 +86,10 @@ nav: - How to: 'howto.md' - Credits: 'credits.md' - Releases: + - '2.x': + - '2.0.0 (WIP)': 'changes/2.x/2.0.0.md' - '1.x': - - '1.2.0 (WIP)': 'changes/1.x/1.2.0.md' + - '1.2.0': 'changes/1.x/1.2.0.md' - '1.1.0': 'changes/1.x/1.1.0.md' - '1.0.0': 'changes/1.x/1.0.0.md' - '0.x': From fbff29bf832170e8178bcd2f14d59cab6852d4bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:16:57 +0000 Subject: [PATCH 22/51] Bump phpunit/phpunit from 9.6.13 to 9.6.14 Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.6.13 to 9.6.14. - [Changelog](https://github.com/sebastianbergmann/phpunit/blob/9.6.14/ChangeLog-9.6.md) - [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.6.13...9.6.14) --- updated-dependencies: - dependency-name: phpunit/phpunit dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 24 ++++++++++++------------ docs/changes/2.x/2.0.0.md | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/composer.lock b/composer.lock index d1a795a886..f69b296d9a 100644 --- a/composer.lock +++ b/composer.lock @@ -1938,16 +1938,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.13", + "version": "9.6.14", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be" + "reference": "43653e6ad7adc22e7b667dd561bf8fcb74c10cf0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3d767f7f9e191eab4189abe41ab37797e30b1be", - "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/43653e6ad7adc22e7b667dd561bf8fcb74c10cf0", + "reference": "43653e6ad7adc22e7b667dd561bf8fcb74c10cf0", "shasum": "" }, "require": { @@ -2021,7 +2021,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.13" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.14" }, "funding": [ { @@ -2037,7 +2037,7 @@ "type": "tidelift" } ], - "time": "2023-09-19T05:39:22+00:00" + "time": "2023-12-01T06:10:48+00:00" }, { "name": "psr/cache", @@ -5009,16 +5009,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", "shasum": "" }, "require": { @@ -5047,7 +5047,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.2" }, "funding": [ { @@ -5055,7 +5055,7 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2023-11-20T00:12:19+00:00" } ], "aliases": [], diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index cac743cd13..7bb462acfe 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -11,5 +11,6 @@ ### Miscellaneous - Bump dompdf/dompdf from 2.0.3 to 2.0.4 by [@dependabot](https://github.com/dependabot) in [#2530](https://github.com/PHPOffice/PHPWord/pull/2530) +- Bump phpunit/phpunit from 9.6.13 to 9.6.14 by [@dependabot](https://github.com/dependabot) in [#2519](https://github.com/PHPOffice/PHPWord/pull/2519) ### BC Breaks From d3530482683442ad801a8230edb3f9326ce1620c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Dec 2023 08:41:02 +0000 Subject: [PATCH 23/51] Bump mpdf/mpdf from 8.2.0 to 8.2.2 Bumps [mpdf/mpdf](https://github.com/mpdf/mpdf) from 8.2.0 to 8.2.2. - [Release notes](https://github.com/mpdf/mpdf/releases) - [Changelog](https://github.com/mpdf/mpdf/blob/development/CHANGELOG.md) - [Commits](https://github.com/mpdf/mpdf/compare/v8.2.0...v8.2.2) --- updated-dependencies: - dependency-name: mpdf/mpdf dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 40 +++++++++++++++++++-------------------- docs/changes/2.x/2.0.0.md | 1 + 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/composer.lock b/composer.lock index f69b296d9a..a281bac14b 100644 --- a/composer.lock +++ b/composer.lock @@ -766,16 +766,16 @@ }, { "name": "mpdf/mpdf", - "version": "v8.2.0", + "version": "v8.2.2", "source": { "type": "git", "url": "https://github.com/mpdf/mpdf.git", - "reference": "170a236a588d177c2aa7447ce490a030ca68e6f4" + "reference": "596a87b876d7793be7be060a8ac13424de120dd5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mpdf/mpdf/zipball/170a236a588d177c2aa7447ce490a030ca68e6f4", - "reference": "170a236a588d177c2aa7447ce490a030ca68e6f4", + "url": "https://api.github.com/repos/mpdf/mpdf/zipball/596a87b876d7793be7be060a8ac13424de120dd5", + "reference": "596a87b876d7793be7be060a8ac13424de120dd5", "shasum": "" }, "require": { @@ -785,7 +785,7 @@ "mpdf/psr-log-aware-trait": "^2.0 || ^3.0", "myclabs/deep-copy": "^1.7", "paragonie/random_compat": "^1.4|^2.0|^9.99.99", - "php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", "psr/http-message": "^1.0 || ^2.0", "psr/log": "^1.0 || ^2.0 || ^3.0", "setasign/fpdi": "^2.1" @@ -843,20 +843,20 @@ "type": "custom" } ], - "time": "2023-09-01T11:44:52+00:00" + "time": "2023-11-07T13:52:14+00:00" }, { "name": "mpdf/psr-http-message-shim", - "version": "2.0.0", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/mpdf/psr-http-message-shim.git", - "reference": "1cf4c0b68b8461cea27411ff961482ce7687e34f" + "reference": "f25a0153d645e234f9db42e5433b16d9b113920f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mpdf/psr-http-message-shim/zipball/1cf4c0b68b8461cea27411ff961482ce7687e34f", - "reference": "1cf4c0b68b8461cea27411ff961482ce7687e34f", + "url": "https://api.github.com/repos/mpdf/psr-http-message-shim/zipball/f25a0153d645e234f9db42e5433b16d9b113920f", + "reference": "f25a0153d645e234f9db42e5433b16d9b113920f", "shasum": "" }, "require": { @@ -889,9 +889,9 @@ "description": "Shim to allow support of different psr/message versions.", "support": { "issues": "https://github.com/mpdf/psr-http-message-shim/issues", - "source": "https://github.com/mpdf/psr-http-message-shim/tree/2.0.0" + "source": "https://github.com/mpdf/psr-http-message-shim/tree/v2.0.1" }, - "time": "2023-09-01T06:08:18+00:00" + "time": "2023-10-02T14:34:03+00:00" }, { "name": "mpdf/psr-log-aware-trait", @@ -3308,16 +3308,16 @@ }, { "name": "setasign/fpdi", - "version": "v2.5.0", + "version": "v2.6.0", "source": { "type": "git", "url": "https://github.com/Setasign/FPDI.git", - "reference": "ecf0459643ec963febfb9a5d529dcd93656006a4" + "reference": "a6db878129ec6c7e141316ee71872923e7f1b7ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Setasign/FPDI/zipball/ecf0459643ec963febfb9a5d529dcd93656006a4", - "reference": "ecf0459643ec963febfb9a5d529dcd93656006a4", + "url": "https://api.github.com/repos/Setasign/FPDI/zipball/a6db878129ec6c7e141316ee71872923e7f1b7ad", + "reference": "a6db878129ec6c7e141316ee71872923e7f1b7ad", "shasum": "" }, "require": { @@ -3329,8 +3329,8 @@ }, "require-dev": { "phpunit/phpunit": "~5.7", - "setasign/fpdf": "~1.8", - "setasign/tfpdf": "~1.31", + "setasign/fpdf": "~1.8.6", + "setasign/tfpdf": "~1.33", "squizlabs/php_codesniffer": "^3.5", "tecnickcom/tcpdf": "~6.2" }, @@ -3368,7 +3368,7 @@ ], "support": { "issues": "https://github.com/Setasign/FPDI/issues", - "source": "https://github.com/Setasign/FPDI/tree/v2.5.0" + "source": "https://github.com/Setasign/FPDI/tree/v2.6.0" }, "funding": [ { @@ -3376,7 +3376,7 @@ "type": "tidelift" } ], - "time": "2023-09-28T10:46:27+00:00" + "time": "2023-12-11T16:03:32+00:00" }, { "name": "symfony/config", diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index 7bb462acfe..6105dc4e25 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -12,5 +12,6 @@ - Bump dompdf/dompdf from 2.0.3 to 2.0.4 by [@dependabot](https://github.com/dependabot) in [#2530](https://github.com/PHPOffice/PHPWord/pull/2530) - Bump phpunit/phpunit from 9.6.13 to 9.6.14 by [@dependabot](https://github.com/dependabot) in [#2519](https://github.com/PHPOffice/PHPWord/pull/2519) +- Bump mpdf/mpdf from 8.2.0 to 8.2.2 by [@dependabot](https://github.com/dependabot) in [#2518](https://github.com/PHPOffice/PHPWord/pull/2518) ### BC Breaks From 8b8dfce510c7da46d69e94e917399f8dfd8675d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:49:37 +0000 Subject: [PATCH 24/51] Bump phpmd/phpmd from 2.14.1 to 2.15.0 Bumps [phpmd/phpmd](https://github.com/phpmd/phpmd) from 2.14.1 to 2.15.0. - [Release notes](https://github.com/phpmd/phpmd/releases) - [Changelog](https://github.com/phpmd/phpmd/blob/master/CHANGELOG) - [Commits](https://github.com/phpmd/phpmd/compare/2.14.1...2.15.0) --- updated-dependencies: - dependency-name: phpmd/phpmd dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- composer.lock | 59 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/composer.lock b/composer.lock index a281bac14b..6f7395a174 100644 --- a/composer.lock +++ b/composer.lock @@ -1104,28 +1104,28 @@ }, { "name": "pdepend/pdepend", - "version": "2.15.1", + "version": "2.16.2", "source": { "type": "git", "url": "https://github.com/pdepend/pdepend.git", - "reference": "d12f25bcdfb7754bea458a4a5cb159d55e9950d0" + "reference": "f942b208dc2a0868454d01b29f0c75bbcfc6ed58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pdepend/pdepend/zipball/d12f25bcdfb7754bea458a4a5cb159d55e9950d0", - "reference": "d12f25bcdfb7754bea458a4a5cb159d55e9950d0", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/f942b208dc2a0868454d01b29f0c75bbcfc6ed58", + "reference": "f942b208dc2a0868454d01b29f0c75bbcfc6ed58", "shasum": "" }, "require": { "php": ">=5.3.7", - "symfony/config": "^2.3.0|^3|^4|^5|^6.0", - "symfony/dependency-injection": "^2.3.0|^3|^4|^5|^6.0", - "symfony/filesystem": "^2.3.0|^3|^4|^5|^6.0" + "symfony/config": "^2.3.0|^3|^4|^5|^6.0|^7.0", + "symfony/dependency-injection": "^2.3.0|^3|^4|^5|^6.0|^7.0", + "symfony/filesystem": "^2.3.0|^3|^4|^5|^6.0|^7.0", + "symfony/polyfill-mbstring": "^1.19" }, "require-dev": { "easy-doc/easy-doc": "0.0.0|^1.2.3", "gregwar/rst": "^1.0", - "phpunit/phpunit": "^4.8.36|^5.7.27", "squizlabs/php_codesniffer": "^2.0.0" }, "bin": [ @@ -1155,7 +1155,7 @@ ], "support": { "issues": "https://github.com/pdepend/pdepend/issues", - "source": "https://github.com/pdepend/pdepend/tree/2.15.1" + "source": "https://github.com/pdepend/pdepend/tree/2.16.2" }, "funding": [ { @@ -1163,7 +1163,7 @@ "type": "tidelift" } ], - "time": "2023-09-28T12:00:56+00:00" + "time": "2023-12-17T18:09:59+00:00" }, { "name": "phar-io/manifest", @@ -1421,22 +1421,22 @@ }, { "name": "phpmd/phpmd", - "version": "2.14.1", + "version": "2.15.0", "source": { "type": "git", "url": "https://github.com/phpmd/phpmd.git", - "reference": "442fc2c34edcd5198b442d8647c7f0aec3afabe8" + "reference": "74a1f56e33afad4128b886e334093e98e1b5e7c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmd/phpmd/zipball/442fc2c34edcd5198b442d8647c7f0aec3afabe8", - "reference": "442fc2c34edcd5198b442d8647c7f0aec3afabe8", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/74a1f56e33afad4128b886e334093e98e1b5e7c0", + "reference": "74a1f56e33afad4128b886e334093e98e1b5e7c0", "shasum": "" }, "require": { "composer/xdebug-handler": "^1.0 || ^2.0 || ^3.0", "ext-xml": "*", - "pdepend/pdepend": "^2.15.1", + "pdepend/pdepend": "^2.16.1", "php": ">=5.3.9" }, "require-dev": { @@ -1445,7 +1445,6 @@ "ext-simplexml": "*", "gregwar/rst": "^1.0", "mikey179/vfsstream": "^1.6.8", - "phpunit/phpunit": "^4.8.36 || ^5.7.27", "squizlabs/php_codesniffer": "^2.9.2 || ^3.7.2" }, "bin": [ @@ -1493,7 +1492,7 @@ "support": { "irc": "irc://irc.freenode.org/phpmd", "issues": "https://github.com/phpmd/phpmd/issues", - "source": "https://github.com/phpmd/phpmd/tree/2.14.1" + "source": "https://github.com/phpmd/phpmd/tree/2.15.0" }, "funding": [ { @@ -1501,7 +1500,7 @@ "type": "tidelift" } ], - "time": "2023-09-28T13:07:44+00:00" + "time": "2023-12-11T08:22:20+00:00" }, { "name": "phpstan/phpstan", @@ -3380,16 +3379,16 @@ }, { "name": "symfony/config", - "version": "v5.4.26", + "version": "v5.4.31", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "8109892f27beed9252bd1f1c1880aeb4ad842650" + "reference": "dd5ea39de228813aba0c23c3a4153da2a4cf3cd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/8109892f27beed9252bd1f1c1880aeb4ad842650", - "reference": "8109892f27beed9252bd1f1c1880aeb4ad842650", + "url": "https://api.github.com/repos/symfony/config/zipball/dd5ea39de228813aba0c23c3a4153da2a4cf3cd9", + "reference": "dd5ea39de228813aba0c23c3a4153da2a4cf3cd9", "shasum": "" }, "require": { @@ -3439,7 +3438,7 @@ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v5.4.26" + "source": "https://github.com/symfony/config/tree/v5.4.31" }, "funding": [ { @@ -3455,7 +3454,7 @@ "type": "tidelift" } ], - "time": "2023-07-19T20:21:11+00:00" + "time": "2023-11-09T08:22:43+00:00" }, { "name": "symfony/console", @@ -3557,16 +3556,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v5.4.29", + "version": "v5.4.34", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "338638ed8c9d5c7fcb136a73f5c7043465ae2f05" + "reference": "75d568165a65fa7d8124869ec7c3a90424352e6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/338638ed8c9d5c7fcb136a73f5c7043465ae2f05", - "reference": "338638ed8c9d5c7fcb136a73f5c7043465ae2f05", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/75d568165a65fa7d8124869ec7c3a90424352e6c", + "reference": "75d568165a65fa7d8124869ec7c3a90424352e6c", "shasum": "" }, "require": { @@ -3626,7 +3625,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v5.4.29" + "source": "https://github.com/symfony/dependency-injection/tree/v5.4.34" }, "funding": [ { @@ -3642,7 +3641,7 @@ "type": "tidelift" } ], - "time": "2023-09-20T06:23:43+00:00" + "time": "2023-12-28T09:31:38+00:00" }, { "name": "symfony/deprecation-contracts", From ada4754043c115a2b0c7d5e77f0e57e93ff05897 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 6 Jan 2024 18:06:47 +0100 Subject: [PATCH 25/51] Updated Changelog --- docs/changes/2.x/2.0.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index 6105dc4e25..d5565c76f7 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -13,5 +13,6 @@ - Bump dompdf/dompdf from 2.0.3 to 2.0.4 by [@dependabot](https://github.com/dependabot) in [#2530](https://github.com/PHPOffice/PHPWord/pull/2530) - Bump phpunit/phpunit from 9.6.13 to 9.6.14 by [@dependabot](https://github.com/dependabot) in [#2519](https://github.com/PHPOffice/PHPWord/pull/2519) - Bump mpdf/mpdf from 8.2.0 to 8.2.2 by [@dependabot](https://github.com/dependabot) in [#2518](https://github.com/PHPOffice/PHPWord/pull/2518) +- Bump phpmd/phpmd from 2.14.1 to 2.15.0 by [@dependabot](https://github.com/dependabot) in [#2538](https://github.com/PHPOffice/PHPWord/pull/2538) ### BC Breaks From a402ece87d443ad509b17b6c3c984dd2799f40d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 Jan 2024 17:26:14 +0000 Subject: [PATCH 26/51] Bump phpunit/phpunit from 9.6.14 to 9.6.15 Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.6.14 to 9.6.15. - [Changelog](https://github.com/sebastianbergmann/phpunit/blob/9.6.15/ChangeLog-9.6.md) - [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.6.14...9.6.15) --- updated-dependencies: - dependency-name: phpunit/phpunit dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 66 +++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/composer.lock b/composer.lock index 6f7395a174..6ce71d2a3f 100644 --- a/composer.lock +++ b/composer.lock @@ -998,16 +998,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.17.1", + "version": "v4.18.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" + "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", "shasum": "" }, "require": { @@ -1048,9 +1048,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" }, - "time": "2023-08-13T19:53:39+00:00" + "time": "2023-12-10T21:03:43+00:00" }, { "name": "paragonie/random_compat", @@ -1618,23 +1618,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.29", + "version": "9.2.30", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" + "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca2bd87d2f9215904682a9cb9bb37dda98e76089", + "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -1684,7 +1684,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.30" }, "funding": [ { @@ -1692,7 +1692,7 @@ "type": "github" } ], - "time": "2023-09-19T04:57:46+00:00" + "time": "2023-12-22T06:47:57+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1937,16 +1937,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.14", + "version": "9.6.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "43653e6ad7adc22e7b667dd561bf8fcb74c10cf0" + "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/43653e6ad7adc22e7b667dd561bf8fcb74c10cf0", - "reference": "43653e6ad7adc22e7b667dd561bf8fcb74c10cf0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/05017b80304e0eb3f31d90194a563fd53a6021f1", + "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1", "shasum": "" }, "require": { @@ -2020,7 +2020,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.14" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.15" }, "funding": [ { @@ -2036,7 +2036,7 @@ "type": "tidelift" } ], - "time": "2023-12-01T06:10:48+00:00" + "time": "2023-12-01T16:55:19+00:00" }, { "name": "psr/cache", @@ -2584,20 +2584,20 @@ }, { "name": "sebastian/complexity", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -2629,7 +2629,7 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" }, "funding": [ { @@ -2637,7 +2637,7 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2023-12-22T06:19:30+00:00" }, { "name": "sebastian/diff", @@ -2911,20 +2911,20 @@ }, { "name": "sebastian/lines-of-code", - "version": "1.0.3", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -2956,7 +2956,7 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" }, "funding": [ { @@ -2964,7 +2964,7 @@ "type": "github" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2023-12-22T06:20:34+00:00" }, { "name": "sebastian/object-enumerator", From 400f52433a3f286440c48c0afad2f43e4d444412 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 6 Jan 2024 18:27:50 +0100 Subject: [PATCH 27/51] Updated Changelog --- docs/changes/2.x/2.0.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index d5565c76f7..2aaabc5987 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -14,5 +14,6 @@ - Bump phpunit/phpunit from 9.6.13 to 9.6.14 by [@dependabot](https://github.com/dependabot) in [#2519](https://github.com/PHPOffice/PHPWord/pull/2519) - Bump mpdf/mpdf from 8.2.0 to 8.2.2 by [@dependabot](https://github.com/dependabot) in [#2518](https://github.com/PHPOffice/PHPWord/pull/2518) - Bump phpmd/phpmd from 2.14.1 to 2.15.0 by [@dependabot](https://github.com/dependabot) in [#2538](https://github.com/PHPOffice/PHPWord/pull/2538) +- Bump phpunit/phpunit from 9.6.14 to 9.6.15 by [@dependabot](https://github.com/dependabot) in [#2537](https://github.com/PHPOffice/PHPWord/pull/2537) ### BC Breaks From 24634cc6178758f9f828b0c194469193614f6348 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:49:26 +0000 Subject: [PATCH 28/51] Bump symfony/process from 5.4.28 to 5.4.34 Bumps [symfony/process](https://github.com/symfony/process) from 5.4.28 to 5.4.34. - [Release notes](https://github.com/symfony/process/releases) - [Changelog](https://github.com/symfony/process/blob/7.0/CHANGELOG.md) - [Commits](https://github.com/symfony/process/compare/v5.4.28...v5.4.34) --- updated-dependencies: - dependency-name: symfony/process dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 6ce71d2a3f..6eb3324ccb 100644 --- a/composer.lock +++ b/composer.lock @@ -4643,16 +4643,16 @@ }, { "name": "symfony/process", - "version": "v5.4.28", + "version": "v5.4.34", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b" + "reference": "8fa22178dfc368911dbd513b431cd9b06f9afe7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b", - "reference": "45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b", + "url": "https://api.github.com/repos/symfony/process/zipball/8fa22178dfc368911dbd513b431cd9b06f9afe7a", + "reference": "8fa22178dfc368911dbd513b431cd9b06f9afe7a", "shasum": "" }, "require": { @@ -4685,7 +4685,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.28" + "source": "https://github.com/symfony/process/tree/v5.4.34" }, "funding": [ { @@ -4701,7 +4701,7 @@ "type": "tidelift" } ], - "time": "2023-08-07T10:36:04+00:00" + "time": "2023-12-02T08:41:43+00:00" }, { "name": "symfony/service-contracts", From 8200e9d91fce45deacb57343a971c16ae68a1ac2 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 6 Jan 2024 18:47:38 +0100 Subject: [PATCH 29/51] Updated Changelog --- docs/changes/2.x/2.0.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index 2aaabc5987..2ee54698cc 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -15,5 +15,6 @@ - Bump mpdf/mpdf from 8.2.0 to 8.2.2 by [@dependabot](https://github.com/dependabot) in [#2518](https://github.com/PHPOffice/PHPWord/pull/2518) - Bump phpmd/phpmd from 2.14.1 to 2.15.0 by [@dependabot](https://github.com/dependabot) in [#2538](https://github.com/PHPOffice/PHPWord/pull/2538) - Bump phpunit/phpunit from 9.6.14 to 9.6.15 by [@dependabot](https://github.com/dependabot) in [#2537](https://github.com/PHPOffice/PHPWord/pull/2537) +- Bump symfony/process from 5.4.28 to 5.4.34 by [@dependabot](https://github.com/dependabot) in [#2536](https://github.com/PHPOffice/PHPWord/pull/2536) ### BC Breaks From 12d0660f1e3101868c994d09a6c685bfc5563784 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 12:19:18 +0100 Subject: [PATCH 30/51] Added extractVariables method to IOFactory --- ..._44_ExtractVariablesFromReaderWord2007.php | 8 ++- samples/Sample_Header.php | 1 + src/PhpWord/IOFactory.php | 66 +++++++++++++++++++ tests/PhpWordTests/IOFactoryTest.php | 5 +- 4 files changed, 77 insertions(+), 3 deletions(-) diff --git a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php index 741efc1b5e..1fcbfd5f62 100644 --- a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php +++ b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php @@ -4,6 +4,12 @@ // Read contents $name = basename(__FILE__, '.php'); + $source = __DIR__ . "/resources/{$name}.docx"; + echo date('H:i:s'), " Reading contents from `{$source}`", EOL; -$phpWord = \PhpOffice\PhpWord\IOFactory::extractVariables($source); + +$variables = \PhpOffice\PhpWord\IOFactory::extractVariables($source); + +var_dump($variables); + diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index 8d05a2a34e..3c8b8b6736 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -47,6 +47,7 @@ while (false !== ($sampleFile = readdir($handle))) { $sampleFiles[] = $sampleFile; } + var_dump($sampleFiles); sort($sampleFiles); closedir($handle); diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index f03168d174..722b300980 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -21,6 +21,8 @@ use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Reader\ReaderInterface; use PhpOffice\PhpWord\Writer\WriterInterface; +/* TextRun Element */ +use PhpOffice\PhpWord\Element\TextRun; use ReflectionClass; abstract class IOFactory @@ -89,6 +91,69 @@ public static function load($filename, $readerName = 'Word2007') return $reader->load($filename); } + + /** + * Loads PhpWord ${variable} from file. + * + * @param string $filename The name of the file + * @param string $readerName + * + * @return \PhpOffice\PhpWord\PhpWord $phpWord + */ + public static function extractVariables($filename, $readerName = 'Word2007') + { + /** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */ + $reader = self::createReader($readerName); + $document = $reader->load($filename); + $extractedVariables = []; + foreach ($document->getSections() as $section) { + // Concatenate text from all elements + $concatenatedText = ''; + + foreach ($section->getElements() as $element) { + if ($element instanceof TextRun) { + foreach ($element->getElements() as $textElement) { + if (method_exists($textElement, 'getText')) { + $text = $textElement->getText(); + // Check if $text is a string before concatenation + if (is_string($text)) { + $concatenatedText .= $text; + } else { + error_log("Expected a string, but got a different type: " . print_r($text, true)); + } + } + } + } elseif (method_exists($element, 'getText')) { + $text = $element->getText(); + // Check if $text is a string before concatenation + if (is_string($text)) { + $concatenatedText .= $text; + } else { + // Handle the case where $text is not a string + error_log("Expected a string, but got a different type: " . print_r($text, true)); + } + } + } + + // Regex to find all occurrences of text that starts with ${ + preg_match_all('/\$\{([^}]+)\}/', $concatenatedText, $matches); + + if (!empty($matches[1])) { + foreach ($matches[1] as $match) { + // Ensure $match is a string before adding to the array + $trimmedMatch = trim($match); + if (is_string($trimmedMatch)) { + $extractedVariables[] = $trimmedMatch; + } else { + // Log non-string matches for debugging + error_log("Non-string match found: " . print_r($match, true)); + } + } + } + } + + return $extractedVariables; + } /** * Loads PhpWord ${variable} from file. @@ -141,4 +206,5 @@ private static function isConcreteClass($class) return !$reflection->isAbstract() && !$reflection->isInterface(); } + } diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index 79f0fd0c76..4cdf96e059 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -123,10 +123,11 @@ public function testLoad(): void public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; + $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); - $expectedVariables = ['date', 'A1', 'B1']; + $expectedVariables = ['date', 'A1', 'B1']; - self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); + $this->assertEquals($expectedVariables, $extractedVariables, "Extracted variables do not match expected variables."); } } From d51ce7e3c775d741a6676cd2b541d25ae45ecddd Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 12:25:44 +0100 Subject: [PATCH 31/51] remove var_dumps --- samples/Sample_Header.php | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index 3c8b8b6736..8d05a2a34e 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -47,7 +47,6 @@ while (false !== ($sampleFile = readdir($handle))) { $sampleFiles[] = $sampleFile; } - var_dump($sampleFiles); sort($sampleFiles); closedir($handle); From 3523d2f37c1a6c0d96a9e10ca600c7d4beb246ca Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:10:00 +0100 Subject: [PATCH 32/51] fix return and fix php stan errors and instances --- src/PhpWord/IOFactory.php | 78 +++++---------------------------------- 1 file changed, 10 insertions(+), 68 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 722b300980..ecf9eef7ac 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -16,14 +16,13 @@ namespace PhpOffice\PhpWord; + +use ReflectionClass; use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Reader\ReaderInterface; use PhpOffice\PhpWord\Writer\WriterInterface; -/* TextRun Element */ -use PhpOffice\PhpWord\Element\TextRun; -use ReflectionClass; abstract class IOFactory { @@ -97,73 +96,10 @@ public static function load($filename, $readerName = 'Word2007') * * @param string $filename The name of the file * @param string $readerName - * - * @return \PhpOffice\PhpWord\PhpWord $phpWord - */ - public static function extractVariables($filename, $readerName = 'Word2007') - { - /** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */ - $reader = self::createReader($readerName); - $document = $reader->load($filename); - $extractedVariables = []; - foreach ($document->getSections() as $section) { - // Concatenate text from all elements - $concatenatedText = ''; - - foreach ($section->getElements() as $element) { - if ($element instanceof TextRun) { - foreach ($element->getElements() as $textElement) { - if (method_exists($textElement, 'getText')) { - $text = $textElement->getText(); - // Check if $text is a string before concatenation - if (is_string($text)) { - $concatenatedText .= $text; - } else { - error_log("Expected a string, but got a different type: " . print_r($text, true)); - } - } - } - } elseif (method_exists($element, 'getText')) { - $text = $element->getText(); - // Check if $text is a string before concatenation - if (is_string($text)) { - $concatenatedText .= $text; - } else { - // Handle the case where $text is not a string - error_log("Expected a string, but got a different type: " . print_r($text, true)); - } - } - } - - // Regex to find all occurrences of text that starts with ${ - preg_match_all('/\$\{([^}]+)\}/', $concatenatedText, $matches); - - if (!empty($matches[1])) { - foreach ($matches[1] as $match) { - // Ensure $match is a string before adding to the array - $trimmedMatch = trim($match); - if (is_string($trimmedMatch)) { - $extractedVariables[] = $trimmedMatch; - } else { - // Log non-string matches for debugging - error_log("Non-string match found: " . print_r($match, true)); - } - } - } - } - - return $extractedVariables; - } - - /** - * Loads PhpWord ${variable} from file. - * - * @param string $filename The name of the file - * @param string $readerName - * * @return array The extracted variables + * */ - public static function extractVariables(string $filename, $readerName = 'Word2007') + public static function extractVariables(string $filename, $readerName = 'Word2007'): array { /** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */ $reader = self::createReader($readerName); @@ -171,6 +107,7 @@ public static function extractVariables(string $filename, $readerName = 'Word200 $extractedVariables = []; foreach ($document->getSections() as $section) { $concatenatedText = ''; + foreach ($section->getElements() as $element) { if ($element instanceof TextRun) { foreach ($element->getElements() as $textElement) { @@ -179,9 +116,14 @@ public static function extractVariables(string $filename, $readerName = 'Word200 $concatenatedText .= $text; } } + } elseif ($element instanceof Text) { + $text = $element->getText(); + $concatenatedText .= $text; } } + preg_match_all('/\$\{([^}]+)\}/', $concatenatedText, $matches); + if (!empty($matches[1])) { foreach ($matches[1] as $match) { $trimmedMatch = trim($match); From b884cbc6fce1df8423d8f6ac5b2648ff0d874deb Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:15:14 +0100 Subject: [PATCH 33/51] fix order and whitespace --- src/PhpWord/IOFactory.php | 3 +-- tests/PhpWordTests/IOFactoryTest.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index ecf9eef7ac..702af0fc60 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -16,13 +16,12 @@ namespace PhpOffice\PhpWord; - -use ReflectionClass; use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Reader\ReaderInterface; use PhpOffice\PhpWord\Writer\WriterInterface; +use ReflectionClass; abstract class IOFactory { diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index 4cdf96e059..bc6407619f 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -128,6 +128,6 @@ public function testExtractVariables(): void $expectedVariables = ['date', 'A1', 'B1']; - $this->assertEquals($expectedVariables, $extractedVariables, "Extracted variables do not match expected variables."); + self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); } } From e4a6a43e8731895b5c7bddf2d1771d621f56c77c Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:21:36 +0100 Subject: [PATCH 34/51] remove new lines --- src/PhpWord/IOFactory.php | 4 ---- tests/PhpWordTests/IOFactoryTest.php | 3 --- 2 files changed, 7 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 702af0fc60..67c1d3304b 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -106,7 +106,6 @@ public static function extractVariables(string $filename, $readerName = 'Word200 $extractedVariables = []; foreach ($document->getSections() as $section) { $concatenatedText = ''; - foreach ($section->getElements() as $element) { if ($element instanceof TextRun) { foreach ($element->getElements() as $textElement) { @@ -120,9 +119,7 @@ public static function extractVariables(string $filename, $readerName = 'Word200 $concatenatedText .= $text; } } - preg_match_all('/\$\{([^}]+)\}/', $concatenatedText, $matches); - if (!empty($matches[1])) { foreach ($matches[1] as $match) { $trimmedMatch = trim($match); @@ -130,7 +127,6 @@ public static function extractVariables(string $filename, $readerName = 'Word200 } } } - return $extractedVariables; } diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index bc6407619f..0d2ac1f856 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -123,11 +123,8 @@ public function testLoad(): void public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; - $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); - $expectedVariables = ['date', 'A1', 'B1']; - self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); } } From 3a252ede8273db71c293734bbe69a354a4d37583 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:24:38 +0100 Subject: [PATCH 35/51] white space --- samples/Sample_44_ExtractVariablesFromReaderWord2007.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php index 1fcbfd5f62..2653314e4c 100644 --- a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php +++ b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php @@ -4,9 +4,7 @@ // Read contents $name = basename(__FILE__, '.php'); - $source = __DIR__ . "/resources/{$name}.docx"; - echo date('H:i:s'), " Reading contents from `{$source}`", EOL; $variables = \PhpOffice\PhpWord\IOFactory::extractVariables($source); From 42d1a95fda2e7a7aa8160f7f24104a6a9f68c56a Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:29:07 +0100 Subject: [PATCH 36/51] new lines --- src/PhpWord/IOFactory.php | 6 +++--- tests/PhpWordTests/IOFactoryTest.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 67c1d3304b..d61fc08dae 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -89,14 +89,14 @@ public static function load($filename, $readerName = 'Word2007') return $reader->load($filename); } - + /** * Loads PhpWord ${variable} from file. * * @param string $filename The name of the file * @param string $readerName - * @return array The extracted variables * + * @return array The extracted variables */ public static function extractVariables(string $filename, $readerName = 'Word2007'): array { @@ -127,6 +127,7 @@ public static function extractVariables(string $filename, $readerName = 'Word200 } } } + return $extractedVariables; } @@ -143,5 +144,4 @@ private static function isConcreteClass($class) return !$reflection->isAbstract() && !$reflection->isInterface(); } - } diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index 0d2ac1f856..fbcbf5bfe7 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -124,6 +124,7 @@ public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); + $expectedVariables = ['date', 'A1', 'B1']; self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); } From 3fdd8b40d95ed1d916d8fe3b67a0156f523daad1 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:31:18 +0100 Subject: [PATCH 37/51] whiteline --- tests/PhpWordTests/IOFactoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index fbcbf5bfe7..6d6f763d09 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -124,8 +124,8 @@ public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); - $expectedVariables = ['date', 'A1', 'B1']; + self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); } } From 5fc5d46ddeb8b99670c7f0e5b6b61438229d21e5 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:32:29 +0100 Subject: [PATCH 38/51] new line --- tests/PhpWordTests/IOFactoryTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index 6d6f763d09..9047f468f4 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -124,6 +124,7 @@ public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); + $expectedVariables = ['date', 'A1', 'B1']; self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); From cac3256a8d79ef84c2971a876eaf431342dbfcc3 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:35:50 +0100 Subject: [PATCH 39/51] white space --- tests/PhpWordTests/IOFactoryTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index 9047f468f4..bccea3e699 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -124,9 +124,9 @@ public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); - - $expectedVariables = ['date', 'A1', 'B1']; - + + $expectedVariables = ['date', 'A1', 'B1']; + self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); - } + } } From cd5a155ee0df1976b1627b38d8999159d1ae854b Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 13:41:47 +0100 Subject: [PATCH 40/51] fix --- tests/PhpWordTests/IOFactoryTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/PhpWordTests/IOFactoryTest.php b/tests/PhpWordTests/IOFactoryTest.php index bccea3e699..79f0fd0c76 100644 --- a/tests/PhpWordTests/IOFactoryTest.php +++ b/tests/PhpWordTests/IOFactoryTest.php @@ -124,9 +124,9 @@ public function testExtractVariables(): void { $file = __DIR__ . '/_files/templates/extract-variable.docx'; $extractedVariables = IOFactory::extractVariables($file, 'Word2007'); - + $expectedVariables = ['date', 'A1', 'B1']; - + self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.'); - } + } } From c0338f573be423aaf83ef17da8f6110e1f4e10a8 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 14:35:28 +0100 Subject: [PATCH 41/51] white space --- src/PhpWord/IOFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index d61fc08dae..275352a654 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -116,6 +116,7 @@ public static function extractVariables(string $filename, $readerName = 'Word200 } } elseif ($element instanceof Text) { $text = $element->getText(); + $concatenatedText .= $text; } } From 6b86c52a1a6561cc34e703800f7081e181812cf0 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Thu, 30 Nov 2023 15:56:29 +0100 Subject: [PATCH 42/51] remove some unneecessary if statement --- src/PhpWord/IOFactory.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 275352a654..2e31722069 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -114,10 +114,6 @@ public static function extractVariables(string $filename, $readerName = 'Word200 $concatenatedText .= $text; } } - } elseif ($element instanceof Text) { - $text = $element->getText(); - - $concatenatedText .= $text; } } preg_match_all('/\$\{([^}]+)\}/', $concatenatedText, $matches); From 309b61638f5baf3e16ebfcb31df03587f118a116 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Sun, 7 Jan 2024 18:21:18 +0100 Subject: [PATCH 43/51] variable changes --- docs/changes/2.x/2.0.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index 2ee54698cc..6c6c807794 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -3,6 +3,7 @@ [Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.2.0...2.0.0) ## Enhancements +- Word2007 Reader/Writer : Added extractVariables to extract variables from word and map the insertion [@sibalonat](https://github.com/sibalonat) in GH-2515 ### Bug fixes From 2a28c1e7dd0af1bd81f0ff25f72379d5f2022500 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Sun, 7 Jan 2024 18:32:59 +0100 Subject: [PATCH 44/51] 2.0.0 md --- docs/changes/2.x/2.0.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index 6c6c807794..496cc63171 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -3,7 +3,7 @@ [Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.2.0...2.0.0) ## Enhancements -- Word2007 Reader/Writer : Added extractVariables to extract variables from word and map the insertion [@sibalonat](https://github.com/sibalonat) in GH-2515 + ### Bug fixes From 68d9bd8b66eac155b68fd7285af9c887e014545e Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Sun, 7 Jan 2024 18:33:46 +0100 Subject: [PATCH 45/51] 2.0.0 --- docs/changes/2.x/2.0.0.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index 496cc63171..2ee54698cc 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -4,7 +4,6 @@ ## Enhancements - ### Bug fixes - MsDoc Reader : Correct Font Size Calculation by [@oleibman](https://github.com/oleibman) fixing [#2526](https://github.com/PHPOffice/PHPWord/issues/2526) in [#2531](https://github.com/PHPOffice/PHPWord/pull/2531) From dd5fc0dc58ce1586973bd9317b6defbec923d281 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Sun, 7 Jan 2024 18:41:33 +0100 Subject: [PATCH 46/51] new line at end of the file --- samples/Sample_44_ExtractVariablesFromReaderWord2007.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php index 2653314e4c..24574e5fb7 100644 --- a/samples/Sample_44_ExtractVariablesFromReaderWord2007.php +++ b/samples/Sample_44_ExtractVariablesFromReaderWord2007.php @@ -4,10 +4,11 @@ // Read contents $name = basename(__FILE__, '.php'); + $source = __DIR__ . "/resources/{$name}.docx"; + echo date('H:i:s'), " Reading contents from `{$source}`", EOL; $variables = \PhpOffice\PhpWord\IOFactory::extractVariables($source); var_dump($variables); - From 60b416f80fcc5654e1ff7b3b4986dbb7b39a5894 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Sun, 7 Jan 2024 19:06:09 +0100 Subject: [PATCH 47/51] add entry to md --- docs/changes/2.x/2.0.0.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index 2ee54698cc..e2a48382fc 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -4,6 +4,8 @@ ## Enhancements +- Word2007 Writer : Added extractVariables method to extract variables from word [@sibalonat](https://github.com/sibalonat) in GH-2515 + ### Bug fixes - MsDoc Reader : Correct Font Size Calculation by [@oleibman](https://github.com/oleibman) fixing [#2526](https://github.com/PHPOffice/PHPWord/issues/2526) in [#2531](https://github.com/PHPOffice/PHPWord/pull/2531) From 53e08d5713b50a8672b455465f0bb475c07486c5 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Sun, 7 Jan 2024 23:40:01 +0100 Subject: [PATCH 48/51] additional space, type fixes in enhancement md and iofactory --- docs/changes/2.x/2.0.0.md | 2 +- src/PhpWord/IOFactory.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index e2a48382fc..d0a09df783 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -4,7 +4,7 @@ ## Enhancements -- Word2007 Writer : Added extractVariables method to extract variables from word [@sibalonat](https://github.com/sibalonat) in GH-2515 +- IOFactory : Added extractVariables method to extract variables from a document [@sibalonat](https://github.com/sibalonat) in [#2515](https://github.com/PHPOffice/PHPWord/pull/2515) ### Bug fixes diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 2e31722069..913cca593d 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -12,7 +12,8 @@ * * @see https://github.com/PHPOffice/PHPWord * - * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 + */ namespace PhpOffice\PhpWord; @@ -98,7 +99,7 @@ public static function load($filename, $readerName = 'Word2007') * * @return array The extracted variables */ - public static function extractVariables(string $filename, $readerName = 'Word2007'): array + public static function extractVariables(string $filename, string $readerName = 'Word2007'): array { /** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */ $reader = self::createReader($readerName); From 5b4f434736e1a829bac899443709cbee9aaf8611 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Sun, 7 Jan 2024 23:47:08 +0100 Subject: [PATCH 49/51] some fixes on spacing --- src/PhpWord/IOFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 913cca593d..416e30cd41 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -95,6 +95,7 @@ public static function load($filename, $readerName = 'Word2007') * Loads PhpWord ${variable} from file. * * @param string $filename The name of the file + * * @param string $readerName * * @return array The extracted variables From 56feaf3a05ff6ee6419b40f4f0810cbd0b2c309b Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Sun, 7 Jan 2024 23:53:03 +0100 Subject: [PATCH 50/51] based on fixer suggestions --- src/PhpWord/IOFactory.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 416e30cd41..90afa334ff 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -12,7 +12,7 @@ * * @see https://github.com/PHPOffice/PHPWord * - * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; @@ -95,8 +95,6 @@ public static function load($filename, $readerName = 'Word2007') * Loads PhpWord ${variable} from file. * * @param string $filename The name of the file - * - * @param string $readerName * * @return array The extracted variables */ @@ -143,4 +141,4 @@ private static function isConcreteClass($class) return !$reflection->isAbstract() && !$reflection->isInterface(); } -} +} \ No newline at end of file From d3eac68f9d274ac3aabc030ed4e121cfdc308a44 Mon Sep 17 00:00:00 2001 From: Marin Nikolli Date: Sun, 7 Jan 2024 23:54:27 +0100 Subject: [PATCH 51/51] new line at the end of the file --- src/PhpWord/IOFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 90afa334ff..9ceb7026a3 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -141,4 +141,4 @@ private static function isConcreteClass($class) return !$reflection->isAbstract() && !$reflection->isInterface(); } -} \ No newline at end of file +}