Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from AgencyPMG/ALLI-7565-php82
Browse files Browse the repository at this point in the history
[ALLI-7565] Drop PHP 7.4 Support
  • Loading branch information
chrisguitarguy authored Jan 12, 2023
2 parents 93a82a7 + be43fbf commit afd5942
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 43 deletions.
37 changes: 37 additions & 0 deletions .github/actions/setup-php/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Setup PHP

description: Set up PHP & Composer

inputs:
php-version:
required: false
type: string
description: the php version to use, defaults to 8.2
default: '8.2'

runs:
using: composite
steps:
- name: PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ inputs.php-version }}"
tools: composer
coverage: xdebug
ini-values: zend.assertions=1,assert.exception=1,xdebug.mode=coverage

- name: composer cache
id: composercache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: cache php dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ inputs.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-${{ inputs.php-version }}-

- name: install php dependencies
shell: bash
run: composer install --no-interaction --no-progress
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: test

on:
push:
branches:
- "**"

jobs:
test:
name: test
runs-on: "ubuntu-20.04"

strategy:
matrix:
include:
- php-version: 8.0
- php-version: 8.1
- php-version: 8.2

steps:
- name: checkout
uses: actions/checkout@v3

- name: PHP
uses: ./.github/actions/setup-php
with:
php-version: "${{ matrix.php-version }}"

- name: tests
run: ./vendor/bin/phpunit
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@
A few helpers to make reading and writing CSV (and other delimited files)
a bit easier.

## A Quick Note on Line Endings

This library is a thin wrapper around `SplFileObject`, so all the caveats for
using that come into play here. This includes line endings. Your best best may
be to set `auto_detect_line_endings = On` in your `php.ini` or use...

```php
ini_set('auto_detect_line_endings', true)
```

## Reading CSV

```php
Expand Down
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@
{ "name": "Christopher Davis", "email": "[email protected]" }
],
"require": {
"php": "^7.4 || ^8.0"
"php": "^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"mikey179/vfsstream": "^1.6"
"mikey179/vfsstream": "^1.6",
"symfony/phpunit-bridge": "^5.4"
},
"autoload": {
"psr-4": {
"PMG\\CsvSugar\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"PMG\\CsvSugar\\": "test/"
}
}
}
10 changes: 9 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="test/bootstrap.php">
bootstrap="vendor/autoload.php">

<testsuites>
<testsuite name="unit">
Expand All @@ -22,5 +22,13 @@
</include>
</coverage>

<php>
<ini name="assert.exception" value="On"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
</php>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>

</phpunit>
6 changes: 4 additions & 2 deletions src/AbstractReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace PMG\CsvSugar;

use Generator;

/**
* ABC for readers.
*
Expand All @@ -34,11 +36,11 @@ public function __construct(string $filename, Dialect $dialect=null)
$this->dialect = $dialect ?: Dialect::csv();
}

public function getIterator() : iterable
public function getIterator() : Generator
{
$fh = $this->openFile();
try {
return $this->readFile($fh);
yield from $this->readFile($fh);
} finally {
@fclose($fh);
}
Expand Down
4 changes: 3 additions & 1 deletion test/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@

class ConfigurationTest extends TestCase
{
use Configuration;

public function testConfigureFileObjectChangesTheCsvControlForTheFileObjectBaseOnDialect()
{
$dialect = new Dialect('|', "'");
$fh = new \SplFileObject(__FILE__, 'r');
Configuration::configureFileObject($fh, $dialect);
self::configureFileObject($fh, $dialect);

list($delimiter, $enclosure) = $fh->getCsvControl();
$this->assertEquals('|', $delimiter);
Expand Down
15 changes: 0 additions & 15 deletions test/bootstrap.php

This file was deleted.

0 comments on commit afd5942

Please sign in to comment.