Skip to content
This repository was archived by the owner on Apr 12, 2022. It is now read-only.
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
5 changes: 2 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/.github export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php_cs export-ignore
.scrutinizer.yml export-ignore
.travis.run-tests.sh export-ignore
.travis.yml export-ignore
Makefile export-ignore
phpstan.neon export-ignore
phpunit.xml export-ignore
215 changes: 215 additions & 0 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
name: "Integrate"

on:
pull_request:
push:
branches:
- "master"

jobs:
composer-json-lint:
name: "Lint composer.json"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: composer-normalize, composer-require-checker, composer-unused

- name: "Get composer cache directory"
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

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

- name: "Install dependencies"
run: "composer update --no-interaction --no-progress"

- name: "Validate composer.json"
run: "composer validate --strict"

- name: "Normalize composer.json"
run: "composer-normalize --dry-run"

tests:
name: "Tests"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"
- "8.0"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
ini-values: zend.assertions=1

- name: "Get composer cache directory"
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

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

- name: "Install dependencies"
if: ${{ matrix.php-version != '8.0' }}
run: "composer update --no-interaction --no-progress"

- name: "Install dependencies PHP 8.0"
if: ${{ matrix.php-version == '8.0' }}
run: "composer update --no-interaction --no-progress --ignore-platform-reqs"

- name: "Run tests"
timeout-minutes: 3
run: "vendor/bin/phpunit --no-coverage --no-logging"

code-coverage:
name: "Code Coverage"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: zend.assertions=1

- name: "Get composer cache directory"
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

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

- name: "Install dependencies"
run: "composer update --no-interaction --no-progress"

- name: "Run tests"
timeout-minutes: 3
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"

- name: "Send code coverage report to Codecov.io"
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: true

coding-standards:
name: "Coding Standards"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: "Get composer cache directory"
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

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

- name: "Install dependencies"
run: "composer update --no-interaction --no-progress"

- name: "Check coding standards"
run: "vendor/bin/php-cs-fixer fix --verbose --dry-run --diff"

static-analysis:
name: "Static Analysis"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: cs2pr

- name: "Get composer cache directory"
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

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

- name: "Install dependencies"
run: "composer update --no-interaction --no-progress"

- name: "Run static analysis"
run: "vendor/bin/phpstan analyse --no-progress --error-format=checkstyle | cs2pr"
2 changes: 1 addition & 1 deletion .php_cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$config = new SlamCsFixer\Config(SlamCsFixer\Config::LIB);
$config = new SlamCsFixer\Config();
$config->getFinder()
->in(__DIR__ . '/lib/Exception')
->in(__DIR__ . '/lib/Helper')
Expand Down
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
all: csfix static-analysis test
@echo "Done."

vendor: composer.json
composer update
touch vendor

.PHONY: csfix
csfix: vendor
vendor/bin/php-cs-fixer fix --verbose

.PHONY: static-analysis
static-analysis: vendor
vendor/bin/phpstan analyse

.PHONY: test
test: vendor
php -d zend.assertions=1 vendor/bin/phpunit
21 changes: 10 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@
}
],
"require": {
"php": "^7.3"
"php": "^7.4 || ^8.0"
},
"require-dev": {
"mikey179/vfsstream": "^1.6",
"phpoffice/phpspreadsheet": "^1.10",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^8.5",
"roave/security-advisories": "dev-master",
"slam/php-cs-fixer-extensions": "^1.19",
"slam/php-debug-r": "^1.6",
"slam/phpstan-extensions": "^4.0",
"thecodingmachine/phpstan-strict-rules": "^0.12"
"mikey179/vfsstream": "^1.6.8",
"phpoffice/phpspreadsheet": "^1.15.0",
"phpstan/phpstan": "^0.12.50",
"phpstan/phpstan-phpunit": "^0.12.16",
"phpunit/phpunit": "^9.4.2",
"slam/php-cs-fixer-extensions": "^2.0.0",
"slam/php-debug-r": "^1.6.1",
"slam/phpstan-extensions": "^5.0.2",
"thecodingmachine/phpstan-strict-rules": "^0.12.1"
},
"autoload": {
"psr-4": {
Expand Down
23 changes: 4 additions & 19 deletions lib/Helper/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,10 @@

final class Column implements ColumnInterface
{
/**
* @var string
*/
private $key;

/**
* @var string
*/
private $heading;

/**
* @var int
*/
private $width;

/**
* @var CellStyleInterface
*/
private $cellStyle;
private string $key;
private string $heading;
private int $width;
private CellStyleInterface $cellStyle;

public function __construct(string $key, string $heading, int $width, CellStyleInterface $cellStyle)
{
Expand Down
14 changes: 5 additions & 9 deletions lib/Helper/ColumnCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class ColumnCollection implements ColumnCollectionInterface
/**
* @var array<string, ColumnInterface>
*/
private $columns = [];
private array $columns = [];

public function __construct(array $columns)
{
Expand All @@ -29,35 +29,31 @@ private function addColumn(ColumnInterface $column): void
* @param string $offset
* @param mixed $value
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
throw new Exception\RuntimeException('Collection not editable');
}

/**
* @param string $offset
*
* @return bool
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->columns[$offset]);
}

/**
* @param string $offset
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
throw new Exception\RuntimeException('Collection not editable');
}

/**
* @param string $offset
*
* @return null|mixed
*/
public function offsetGet($offset)
public function offsetGet($offset): ?ColumnInterface
{
return $this->columns[$offset] ?? null;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/Helper/ColumnCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use ArrayAccess;

/**
* @extends ArrayAccess<string, ColumnInterface>
*/
interface ColumnCollectionInterface extends ArrayAccess
{
}
Loading