Skip to content

Commit a794a8b

Browse files
committed
Remove Symfony 5.4 support and PHP 7.4, 8.0 support
1 parent 69ba061 commit a794a8b

File tree

5 files changed

+20
-83
lines changed

5 files changed

+20
-83
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,24 @@ jobs:
1414
matrix:
1515
include:
1616
#Mini (for each Symfony version)
17-
- php-version: '7.4'
18-
symfony-version: '5.4.*'
19-
composer-flags: '--prefer-stable --prefer-lowest'
20-
install-dos2unix: true
21-
description: 'with SF 5.4.* lowest'
2217
- php-version: '8.1'
2318
symfony-version: '6.4.*'
2419
composer-flags: '--prefer-stable --prefer-lowest'
2520
install-dos2unix: true
2621
description: 'with SF 6.4.* lowest'
27-
- php-version: '8.2'
28-
symfony-version: '7.0.*'
29-
composer-flags: '--prefer-stable --prefer-lowest'
30-
install-dos2unix: true
31-
description: 'with SF 7.0.* lowest'
3222
- php-version: '8.2'
3323
symfony-version: '7.1.*'
3424
composer-flags: '--prefer-stable --prefer-lowest'
3525
install-dos2unix: true
3626
description: 'with SF 7.1.* lowest'
3727

3828
#Symfony versions
39-
- php-version: '8.3'
40-
symfony-version: '5.4.*'
41-
description: 'with SF 5.4.*'
42-
- php-version: '8.3'
43-
symfony-version: '5.4.*@dev'
44-
description: 'with SF 5.4.* dev'
4529
- php-version: '8.3'
4630
symfony-version: '6.4.*'
4731
description: 'with SF 6.4.*'
4832
- php-version: '8.3'
4933
symfony-version: '6.4.*@dev'
5034
description: 'with SF 6.4.* dev'
51-
- php-version: '8.3'
52-
symfony-version: '7.0.*'
53-
description: 'with SF 7.0.*'
54-
- php-version: '8.3'
55-
symfony-version: '7.0.*@dev'
56-
description: 'with SF 7.0.* dev'
5735
- php-version: '8.3'
5836
symfony-version: '7.1.*'
5937
description: 'with SF 7.1.*'
@@ -65,10 +43,6 @@ jobs:
6543
description: 'with SF 7.2.* dev'
6644

6745
#PHP versions
68-
- php-version: '7.4'
69-
install-dos2unix: true
70-
- php-version: '8.0'
71-
install-dos2unix: true
7246
- php-version: '8.1'
7347
- php-version: '8.2'
7448
- php-version: '8.3'
@@ -80,7 +54,7 @@ jobs:
8054
coding-standards: true
8155

8256
#Static Analysis (min PHP version)
83-
- php-version: '7.4'
57+
- php-version: '8.1'
8458
description: 'with Static Analysis'
8559
static-analysis: true
8660

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"psr-4": { "Ecommit\\CsvTableGenerator\\Tests\\": "tests/" }
1818
},
1919
"require": {
20-
"php": "^7.4|^8.0",
21-
"symfony/options-resolver": "^5.4|^6.4|^7.0"
20+
"php": "^8.1",
21+
"symfony/options-resolver": "^6.4|^7.0"
2222
},
2323
"require-dev": {
2424
"friendsofphp/php-cs-fixer": "^3.0",

psalm.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@
1212
<directory name="vendor"/>
1313
</ignoreFiles>
1414
</projectFiles>
15+
16+
<issueHandlers>
17+
<DeprecatedProperty>
18+
<errorLevel type="suppress">
19+
<file name="src/Csv.php" />
20+
</errorLevel>
21+
</DeprecatedProperty>
22+
</issueHandlers>
1523
</psalm>

src/Csv.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

tests/CsvTest.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,11 @@ class CsvTest extends TestCase
2020
{
2121
protected $path;
2222

23-
protected $unix2dosLocation = 'not-found';
24-
2523
protected function setUp(): void
2624
{
2725
$this->path = sys_get_temp_dir().'/test-csv';
2826
$this->deleteDir();
2927
mkdir($this->path);
30-
31-
if (\PHP_VERSION_ID < 80100) { // PHP < 8.1
32-
$this->unix2dosLocation = exec('which unix2dos');
33-
if (empty($this->unix2dosLocation)) {
34-
throw new \Exception('unix2dos not found');
35-
}
36-
}
3728
}
3829

3930
protected function tearDown(): void
@@ -183,34 +174,11 @@ public function testWithEolOption(): void
183174
{
184175
$csv = $this->createCsv([
185176
'eol' => Csv::EOL_CRLF,
186-
'unix2dos_path' => $this->unix2dosLocation,
187-
]);
188-
$csv->write(['a a', 'bb']);
189-
$csv->write(['cc', 'dd']);
190-
$csv->close();
191-
192-
$this->assertCsvFile('my-csv.csv', [
193-
'"a a",bb',
194-
'cc,dd',
195-
], true);
196-
}
197-
198-
public function testWithBadUnix2DosPath(): void
199-
{
200-
if (\PHP_VERSION_ID < 80100) { // PHP < 8.1
201-
$this->expectException(\Exception::class);
202-
$this->expectExceptionMessage('Unix2dos error (my-csv file)');
203-
}
204-
205-
$csv = $this->createCsv([
206-
'eol' => Csv::EOL_CRLF,
207-
'unix2dos_path' => 'unix2dosFake',
208177
]);
209178
$csv->write(['a a', 'bb']);
210179
$csv->write(['cc', 'dd']);
211180
$csv->close();
212181

213-
// PHP >= 8.1
214182
$this->assertCsvFile('my-csv.csv', [
215183
'"a a",bb',
216184
'cc,dd',

0 commit comments

Comments
 (0)