Skip to content

Commit

Permalink
Improve GitHub actions, run php-cs-fixer and fix broken tests (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreyu authored Feb 11, 2024
1 parent ec49179 commit e82dc8f
Show file tree
Hide file tree
Showing 31 changed files with 110 additions and 75 deletions.
33 changes: 25 additions & 8 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,35 @@ jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: php-actions/composer@v6
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php_extensions: dom fileinfo filter libxml xmlreader zip gd
- name: php-cs-fixer
php-version: 8.1
extensions: dom fileinfo filter libxml xmlreader zip gd

- name: Install dependencies
uses: ramsey/composer-install@v2

- name: Run php-cs-fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff

phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: php-actions/composer@v6
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php_extensions: dom fileinfo filter libxml xmlreader zip gd
- uses: php-actions/phpstan@v3
php-version: 8.1
extensions: dom fileinfo filter libxml xmlreader zip gd

- name: Install dependencies
uses: ramsey/composer-install@v2

- name: Run php-cs-fixer
run: ./vendor/bin/phpstan analyse
34 changes: 25 additions & 9 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,31 @@ on:
jobs:
phpunit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.3']
include:
- php-version: '8.1'
dependency-version: 'lowest'
- php-version: '8.3'
dependency-version: 'highest'
steps:
- uses: actions/checkout@v3
- uses: php-actions/composer@v6
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php_extensions: dom fileinfo filter libxml xmlreader zip gd
- uses: php-actions/phpunit@v3
php-version: ${{ matrix.php-version }}
extensions: dom fileinfo filter libxml xmlreader zip gd
tools: phpunit:10.5.8

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
version: 10.5.8
php_extensions: xdebug dom fileinfo filter libxml xmlreader zip gd
args: --coverage-text
env:
XDEBUG_MODE: coverage
dependency-versions: ${{ matrix.dependency-version }}

- name: Run PHPUnit
run: vendor/bin/phpunit

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"friendsofphp/php-cs-fixer": "^3.23",
"friendsofphp/php-cs-fixer": "^3.49",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.11",
"symfony/maker-bundle": "^1.48",
"symfony/security-core": "^6.2",
Expand Down
2 changes: 1 addition & 1 deletion src/Action/Type/ResolvedActionTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ResolvedActionTypeFactory implements ResolvedActionTypeFactoryInterface
{
public function createResolvedType(ActionTypeInterface $type, array $typeExtensions = [], ResolvedActionTypeInterface $parent = null): ResolvedActionTypeInterface
public function createResolvedType(ActionTypeInterface $type, array $typeExtensions = [], ?ResolvedActionTypeInterface $parent = null): ResolvedActionTypeInterface
{
return new ResolvedActionType($type, $typeExtensions, $parent);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Action/Type/ResolvedActionTypeFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ interface ResolvedActionTypeFactoryInterface
/**
* @param array<ActionTypeExtensionInterface> $typeExtensions
*/
public function createResolvedType(ActionTypeInterface $type, array $typeExtensions = [], ResolvedActionTypeInterface $parent = null): ResolvedActionTypeInterface;
public function createResolvedType(ActionTypeInterface $type, array $typeExtensions = [], ?ResolvedActionTypeInterface $parent = null): ResolvedActionTypeInterface;
}
8 changes: 4 additions & 4 deletions src/Column/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getSortPropertyPath(): ?PropertyPathInterface
return $this->sortPropertyPath = $this->getPropertyPath();
}

public function createHeaderView(HeaderRowView $parent = null): ColumnHeaderView
public function createHeaderView(?HeaderRowView $parent = null): ColumnHeaderView
{
$view = $this->config->getType()->createHeaderView($this, $parent);

Expand All @@ -81,7 +81,7 @@ public function createHeaderView(HeaderRowView $parent = null): ColumnHeaderView
return $view;
}

public function createValueView(ValueRowView $parent = null): ColumnValueView
public function createValueView(?ValueRowView $parent = null): ColumnValueView
{
$view = $this->config->getType()->createValueView($this, $parent);

Expand All @@ -90,7 +90,7 @@ public function createValueView(ValueRowView $parent = null): ColumnValueView
return $view;
}

public function createExportHeaderView(HeaderRowView $parent = null): ColumnHeaderView
public function createExportHeaderView(?HeaderRowView $parent = null): ColumnHeaderView
{
$view = $this->config->getType()->createExportHeaderView($this, $parent);

Expand All @@ -99,7 +99,7 @@ public function createExportHeaderView(HeaderRowView $parent = null): ColumnHead
return $view;
}

public function createExportValueView(ValueRowView $parent = null): ColumnValueView
public function createExportValueView(?ValueRowView $parent = null): ColumnValueView
{
$view = $this->config->getType()->createExportValueView($this, $parent);

Expand Down
4 changes: 2 additions & 2 deletions src/Column/ColumnConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function getPropertyPath(): ?PropertyPathInterface
return $this->propertyPath;
}

public function setPropertyPath(null|string|PropertyPathInterface $propertyPath): static
public function setPropertyPath(string|PropertyPathInterface|null $propertyPath): static
{
if ($this->locked) {
throw $this->createBuilderLockedException();
Expand All @@ -159,7 +159,7 @@ public function getSortPropertyPath(): ?PropertyPathInterface
return $this->sortPropertyPath;
}

public function setSortPropertyPath(null|string|PropertyPathInterface $sortPropertyPath): static
public function setSortPropertyPath(string|PropertyPathInterface|null $sortPropertyPath): static
{
if ($this->locked) {
throw $this->createBuilderLockedException();
Expand Down
4 changes: 2 additions & 2 deletions src/Column/ColumnConfigBuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function setAttributes(array $attributes): static;

public function setAttribute(string $name, mixed $value): static;

public function setPropertyPath(null|string|PropertyPathInterface $propertyPath): static;
public function setPropertyPath(string|PropertyPathInterface|null $propertyPath): static;

public function setSortPropertyPath(null|string|PropertyPathInterface $sortPropertyPath): static;
public function setSortPropertyPath(string|PropertyPathInterface|null $sortPropertyPath): static;

public function setSortable(bool $sortable): static;

Expand Down
8 changes: 4 additions & 4 deletions src/Column/ColumnInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public function getPropertyPath(): ?PropertyPathInterface;

public function getSortPropertyPath(): ?PropertyPathInterface;

public function createHeaderView(HeaderRowView $parent = null): ColumnHeaderView;
public function createHeaderView(?HeaderRowView $parent = null): ColumnHeaderView;

public function createValueView(ValueRowView $parent = null): ColumnValueView;
public function createValueView(?ValueRowView $parent = null): ColumnValueView;

public function createExportHeaderView(HeaderRowView $parent = null): ColumnHeaderView;
public function createExportHeaderView(?HeaderRowView $parent = null): ColumnHeaderView;

public function createExportValueView(ValueRowView $parent = null): ColumnValueView;
public function createExportValueView(?ValueRowView $parent = null): ColumnValueView;

public function getPriority(): int;

Expand Down
8 changes: 4 additions & 4 deletions src/Column/Type/ResolvedColumnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ public function createBuilder(ColumnFactoryInterface $factory, string $name, arr
return $builder;
}

public function createHeaderView(ColumnInterface $column, HeaderRowView $parent = null): ColumnHeaderView
public function createHeaderView(ColumnInterface $column, ?HeaderRowView $parent = null): ColumnHeaderView
{
return new ColumnHeaderView($parent);
}

public function createValueView(ColumnInterface $column, ValueRowView $parent = null): ColumnValueView
public function createValueView(ColumnInterface $column, ?ValueRowView $parent = null): ColumnValueView
{
return new ColumnValueView($parent);
}

public function createExportHeaderView(ColumnInterface $column, HeaderRowView $parent = null): ColumnHeaderView
public function createExportHeaderView(ColumnInterface $column, ?HeaderRowView $parent = null): ColumnHeaderView
{
return new ColumnHeaderView($parent);
}

public function createExportValueView(ColumnInterface $column, ValueRowView $parent = null): ColumnValueView
public function createExportValueView(ColumnInterface $column, ?ValueRowView $parent = null): ColumnValueView
{
return new ColumnValueView($parent);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Column/Type/ResolvedColumnTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ResolvedColumnTypeFactory implements ResolvedColumnTypeFactoryInterface
{
public function createResolvedType(ColumnTypeInterface $type, array $typeExtensions = [], ResolvedColumnTypeInterface $parent = null): ResolvedColumnTypeInterface
public function createResolvedType(ColumnTypeInterface $type, array $typeExtensions = [], ?ResolvedColumnTypeInterface $parent = null): ResolvedColumnTypeInterface
{
return new ResolvedColumnType($type, $typeExtensions, $parent);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Column/Type/ResolvedColumnTypeFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ interface ResolvedColumnTypeFactoryInterface
/**
* @param array<ColumnTypeExtensionInterface> $typeExtensions
*/
public function createResolvedType(ColumnTypeInterface $type, array $typeExtensions = [], ResolvedColumnTypeInterface $parent = null): ResolvedColumnTypeInterface;
public function createResolvedType(ColumnTypeInterface $type, array $typeExtensions = [], ?ResolvedColumnTypeInterface $parent = null): ResolvedColumnTypeInterface;
}
8 changes: 4 additions & 4 deletions src/Column/Type/ResolvedColumnTypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public function getTypeExtensions(): array;

public function createBuilder(ColumnFactoryInterface $factory, string $name, array $options): ColumnBuilderInterface;

public function createHeaderView(ColumnInterface $column, HeaderRowView $parent = null): ColumnHeaderView;
public function createHeaderView(ColumnInterface $column, ?HeaderRowView $parent = null): ColumnHeaderView;

public function createValueView(ColumnInterface $column, ValueRowView $parent = null): ColumnValueView;
public function createValueView(ColumnInterface $column, ?ValueRowView $parent = null): ColumnValueView;

public function createExportHeaderView(ColumnInterface $column, HeaderRowView $parent = null): ColumnHeaderView;
public function createExportHeaderView(ColumnInterface $column, ?HeaderRowView $parent = null): ColumnHeaderView;

public function createExportValueView(ColumnInterface $column, ValueRowView $parent = null): ColumnValueView;
public function createExportValueView(ColumnInterface $column, ?ValueRowView $parent = null): ColumnValueView;

public function buildColumn(ColumnBuilderInterface $builder, array $options): void;

Expand Down
8 changes: 4 additions & 4 deletions src/DataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public function personalize(PersonalizationData $data, bool $persistence = true)
$this->dispatch(DataTableEvents::POST_PERSONALIZE, new DataTablePersonalizationEvent($this, $data));
}

public function export(ExportData $data = null): ExportFile
public function export(?ExportData $data = null): ExportFile
{
if (!$this->config->isExportingEnabled()) {
throw new RuntimeException('The data table has exporting feature disabled.');
Expand Down Expand Up @@ -696,7 +696,7 @@ public function setExportData(?ExportData $exportData): static
return $this;
}

public function createFiltrationFormBuilder(DataTableView $view = null): FormBuilderInterface
public function createFiltrationFormBuilder(?DataTableView $view = null): FormBuilderInterface
{
if (!$this->config->isFiltrationEnabled()) {
throw new RuntimeException('The data table has filtration feature disabled.');
Expand All @@ -712,7 +712,7 @@ public function createFiltrationFormBuilder(DataTableView $view = null): FormBui
);
}

public function createPersonalizationFormBuilder(DataTableView $view = null): FormBuilderInterface
public function createPersonalizationFormBuilder(?DataTableView $view = null): FormBuilderInterface
{
if (!$this->config->isPersonalizationEnabled()) {
throw new RuntimeException('The data table has personalization feature disabled.');
Expand All @@ -731,7 +731,7 @@ public function createPersonalizationFormBuilder(DataTableView $view = null): Fo
);
}

public function createExportFormBuilder(DataTableView $view = null): FormBuilderInterface
public function createExportFormBuilder(?DataTableView $view = null): FormBuilderInterface
{
if (!$this->config->isExportingEnabled()) {
throw new RuntimeException('The data table has export feature disabled.');
Expand Down
12 changes: 6 additions & 6 deletions src/DataTableBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function getColumn(string $name): ColumnBuilderInterface
throw new InvalidArgumentException(sprintf('The column with the name "%s" does not exist.', $name));
}

public function addColumn(ColumnBuilderInterface|string $column, string $type = null, array $options = []): static
public function addColumn(ColumnBuilderInterface|string $column, ?string $type = null, array $options = []): static
{
if ($this->locked) {
throw $this->createBuilderLockedException();
Expand Down Expand Up @@ -267,7 +267,7 @@ public function getFilter(string $name): FilterBuilderInterface
throw new InvalidArgumentException(sprintf('The filter with the name "%s" does not exist.', $name));
}

public function addFilter(string|FilterBuilderInterface $filter, string $type = null, array $options = []): static
public function addFilter(string|FilterBuilderInterface $filter, ?string $type = null, array $options = []): static
{
if ($this->locked) {
throw $this->createBuilderLockedException();
Expand Down Expand Up @@ -375,7 +375,7 @@ public function getAction(string $name): ActionBuilderInterface
throw new InvalidArgumentException(sprintf('The action with the name "%s" does not exist.', $name));
}

public function addAction(string|ActionBuilderInterface $action, string $type = null, array $options = []): static
public function addAction(string|ActionBuilderInterface $action, ?string $type = null, array $options = []): static
{
if ($this->locked) {
throw $this->createBuilderLockedException();
Expand Down Expand Up @@ -452,7 +452,7 @@ public function hasBatchAction(string $name): bool
return isset($this->batchActions[$name]) || isset($this->unresolvedBatchActions[$name]);
}

public function addBatchAction(string|ActionBuilderInterface $action, string $type = null, array $options = []): static
public function addBatchAction(string|ActionBuilderInterface $action, ?string $type = null, array $options = []): static
{
if ($this->locked) {
throw $this->createBuilderLockedException();
Expand Down Expand Up @@ -540,7 +540,7 @@ public function hasRowAction(string $name): bool
return isset($this->rowActions[$name]) || isset($this->unresolvedRowActions[$name]);
}

public function addRowAction(string|ActionBuilderInterface $action, string $type = null, array $options = []): static
public function addRowAction(string|ActionBuilderInterface $action, ?string $type = null, array $options = []): static
{
if ($this->locked) {
throw $this->createBuilderLockedException();
Expand Down Expand Up @@ -619,7 +619,7 @@ public function getExporter(string $name): ExporterBuilderInterface
throw new InvalidArgumentException(sprintf('The exporter with the name "%s" does not exist.', $name));
}

public function addExporter(string|ExporterBuilderInterface $exporter, string $type = null, array $options = []): static
public function addExporter(string|ExporterBuilderInterface $exporter, ?string $type = null, array $options = []): static
{
if ($this->locked) {
throw $this->createBuilderLockedException();
Expand Down
12 changes: 6 additions & 6 deletions src/DataTableBuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function hasColumn(string $name): bool;
/**
* @param class-string<ColumnTypeInterface>|null $type
*/
public function addColumn(ColumnBuilderInterface|string $column, string $type = null, array $options = []): static;
public function addColumn(ColumnBuilderInterface|string $column, ?string $type = null, array $options = []): static;

public function removeColumn(string $name): static;

Expand All @@ -61,7 +61,7 @@ public function hasFilter(string $name): bool;
/**
* @param class-string<FilterTypeInterface>|null $type
*/
public function addFilter(FilterBuilderInterface|string $filter, string $type = null, array $options = []): static;
public function addFilter(FilterBuilderInterface|string $filter, ?string $type = null, array $options = []): static;

public function removeFilter(string $name): static;

Expand All @@ -88,7 +88,7 @@ public function hasAction(string $name): bool;
/**
* @param class-string<ActionTypeInterface>|null $type
*/
public function addAction(ActionBuilderInterface|string $action, string $type = null, array $options = []): static;
public function addAction(ActionBuilderInterface|string $action, ?string $type = null, array $options = []): static;

public function removeAction(string $name): static;

Expand All @@ -107,7 +107,7 @@ public function hasBatchAction(string $name): bool;
/**
* @param class-string<ActionTypeInterface>|null $type
*/
public function addBatchAction(ActionBuilderInterface|string $action, string $type = null, array $options = []): static;
public function addBatchAction(ActionBuilderInterface|string $action, ?string $type = null, array $options = []): static;

public function removeBatchAction(string $name): static;

Expand All @@ -130,7 +130,7 @@ public function hasRowAction(string $name): bool;
/**
* @param class-string<ActionTypeInterface>|null $type
*/
public function addRowAction(ActionBuilderInterface|string $action, string $type = null, array $options = []): static;
public function addRowAction(ActionBuilderInterface|string $action, ?string $type = null, array $options = []): static;

public function removeRowAction(string $name): static;

Expand All @@ -153,7 +153,7 @@ public function hasExporter(string $name): bool;
/**
* @param class-string<ExporterTypeInterface>|null $type
*/
public function addExporter(ExporterBuilderInterface|string $exporter, string $type = null, array $options = []): static;
public function addExporter(ExporterBuilderInterface|string $exporter, ?string $type = null, array $options = []): static;

public function removeExporter(string $name): static;

Expand Down
Loading

0 comments on commit e82dc8f

Please sign in to comment.