Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

PHP8 for V1 #51

Merged
merged 4 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .codeclimate.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test
on:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions:
- '5.6'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
steps:
- uses: actions/checkout@v2
- run: composer self-update
- run: composer install --prefer-dist --no-interaction
- run: composer ci
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"codeclimate/php-test-reporter": "^0.4",
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "^3.2"
},
"config": {
"lock": false
},
"scripts": {
"tests": "phpunit",
"ci": [
"@composer validate --strict",
"@tests"
]
}
}
5 changes: 5 additions & 0 deletions src/CsvFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ public function validateLineBreak()
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->currentRow;
Expand All @@ -428,6 +429,7 @@ public function current()
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function next()
{
$this->currentRow = $this->readLine();
Expand All @@ -437,6 +439,7 @@ public function next()
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->rowCounter;
Expand All @@ -445,6 +448,7 @@ public function key()
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function valid()
{
return $this->currentRow !== false;
Expand All @@ -453,6 +457,7 @@ public function valid()
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function rewind()
{
rewind($this->getFilePointer());
Expand Down
7 changes: 5 additions & 2 deletions tests/CsvFileErrorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testException()
$csv->getHeader();
self::fail("Must throw exception.");
} catch (Exception $e) {
self::assertContains('Cannot open file', $e->getMessage());
self::assertStringContainsString('Cannot open file', $e->getMessage());
self::assertEquals(1, $e->getCode());
self::assertEquals([], $e->getContextParams());
self::assertEquals('fileNotExists', $e->getStringCode());
Expand All @@ -30,6 +30,9 @@ public function testException()
*/
public function testInvalidFileName($filename, $message)
{
if (PHP_MAJOR_VERSION > 7) {
$this->markTestSkipped('Skipped for php8 since SplFileInfo throws ValueError.');
}
$csv = new CsvFile($filename);
self::expectException(Exception::class);
self::expectExceptionMessage($message);
Expand All @@ -40,7 +43,7 @@ public function invalidFileNameProvider()
{
return [
["", 'Filename cannot be empty'],
["\0", 'fopen() expects parameter 1 to be a valid path, string given'],
// ["\0", 'fopen() expects parameter 1 to be a valid path, string given'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

co s timhle, smazat nebo pridat komentar proc je to zakomentovany?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v php8 sa to chová trochu jinak a nejde to moc rozumně vyřesit bez hacků a ztráty dalšího času pro knihovnu co je obsolete.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CsvFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ public function validLineBreaksData()
}

/**
* @expectedException \Keboola\Csv\InvalidArgumentException
* @dataProvider invalidLineBreaksData
* @param string $file
*/
public function testInvalidLineBreak($file)
{
$this->expectException(\Keboola\Csv\InvalidArgumentException::class);
$csvFile = new CsvFile(__DIR__ . '/data/' . $file);
$csvFile->validateLineBreak();
}
Expand Down