@@ -89,11 +89,15 @@ class Csv
8989
9090 /**
9191 * @var bool
92+ *
93+ * @deprecated No longer used
9294 */
9395 protected $ unixToDos = false ;
9496
9597 /**
9698 * @var string
99+ *
100+ * @deprecated No longer used
97101 */
98102 protected $ unixToDosPath ;
99103
@@ -130,6 +134,7 @@ public function __construct(string $pathDir, string $filename, array $options =
130134 $ resolver ->setAllowedTypes ('escape ' , 'string ' );
131135 $ resolver ->setAllowedTypes ('unix2dos_path ' , 'string ' );
132136 $ resolver ->setAllowedTypes ('add_utf8_bom ' , 'bool ' );
137+ $ resolver ->setDeprecated ('unix2dos_path ' , 'ecommit/csv-table-generator ' , '1.3 ' );
133138 $ this ->configureOptions ($ resolver );
134139 $ options = $ resolver ->resolve ($ options );
135140
@@ -152,9 +157,7 @@ public function __construct(string $pathDir, string $filename, array $options =
152157 $ this ->eol = $ options ['eol ' ];
153158 $ this ->escape = $ options ['escape ' ];
154159
155- if (self ::EOL_CRLF === $ options ['eol ' ] && \PHP_VERSION_ID < 80100 ) { // PHP < 8.1
156- $ this ->unixToDos = true ;
157- }
160+ /* @psalm-suppress DeprecatedProperty */
158161 $ this ->unixToDosPath = $ options ['unix2dos_path ' ];
159162
160163 $ this ->addUtf8Bom = $ options ['add_utf8_bom ' ];
@@ -201,18 +204,6 @@ public function close(): void
201204 if (\is_resource ($ this ->handle )) {
202205 fclose ($ this ->handle );
203206 $ this ->handle = null ;
204-
205- if ($ this ->unixToDos ) { // PHP < 8.1
206- if (\PHP_OS_FAMILY === 'Linux ' ) {
207- $ command = \sprintf ('%s %s 2> /dev/null ' , $ this ->unixToDosPath , $ this ->currentPathname );
208- } else {
209- $ command = \sprintf ('%s %s ' , $ this ->unixToDosPath , $ this ->currentPathname );
210- }
211- exec ($ command , $ output , $ returnVar );
212- if (0 !== $ returnVar ) {
213- throw new \Exception (\sprintf ('Unix2dos error (%s file) ' , $ this ->filename ));
214- }
215- }
216207 }
217208 }
218209
@@ -242,13 +233,9 @@ public function write($data): void
242233 }
243234
244235 // Write
245- if (\PHP_VERSION_ID >= 80100 ) { // PHP >= 8.1
246- $ eol = (self ::EOL_CRLF === $ this ->eol ) ? "\r\n" : "\n" ;
247- /** @psalm-suppress TooManyArguments */
248- $ result = fputcsv ($ this ->handle , $ data , $ this ->delimiter , $ this ->enclosure , $ this ->escape , $ eol );
249- } else { // PHP < 8.1
250- $ result = fputcsv ($ this ->handle , $ data , $ this ->delimiter , $ this ->enclosure , $ this ->escape );
251- }
236+ $ eol = (self ::EOL_CRLF === $ this ->eol ) ? "\r\n" : "\n" ;
237+ /** @psalm-suppress TooManyArguments */
238+ $ result = fputcsv ($ this ->handle , $ data , $ this ->delimiter , $ this ->enclosure , $ this ->escape , $ eol );
252239 if (false === $ result ) {
253240 throw new \Exception (\sprintf ('Error during the writing in %s file ' , $ this ->filename ));
254241 }
0 commit comments