Skip to content

Commit

Permalink
PHP 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
radimvaculik committed Jan 24, 2023
1 parent 1b0ff6a commit 516f215
Show file tree
Hide file tree
Showing 134 changed files with 1,083 additions and 2,370 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
name: "Codesniffer"
uses: contributte/.github/.github/workflows/codesniffer.yml@v1
with:
php: "8.1"
php: "8.2"
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@v1
with:
php: "8.1"
php: "8.2"
database: tests
coverage: true
makefile: coverage
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@v1
with:
php: "8.1"
php: "8.2"
22 changes: 7 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,23 @@ on:
- cron: "0 8 * * 1"

jobs:
test81:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@v1
with:
php: "8.1"
database: tests

test80:
test82:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@v1
with:
php: "8.0"
database: tests
php: "8.2"
database: tests

test74:
test81:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@v1
with:
php: "7.4"
php: "8.1"
database: tests

test74-lower:
test80:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@v1
with:
php: "7.4"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
php: "8.0"
database: tests
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
},
"require": {
"php": ">=7.2",
"php": ">=8.0",
"contributte/application": "^0.5.0",
"nette/di": "^3.0.0",
"nette/forms": "^3.1.3",
Expand All @@ -43,18 +43,19 @@
},
"require-dev": {
"dibi/dibi": "^3.0.0 || ^4.0.0",
"doctrine/annotations": "^1.12.1",
"doctrine/cache": "^1.11.0",
"doctrine/orm": "^2.11.1",
"doctrine/annotations": "^1.12.1",
"elasticsearch/elasticsearch": "^7.1",
"contributte/code-rules": "^1.1.0",
"mockery/mockery": "^1.3.3",
"nette/database": "^3.0.2",
"nette/tester": "^2.3.4",
"nextras/dbal": "^3.0.1 || ^4.0",
"nextras/orm": "^3.1.0 || ^4.0",
"ninjify/coding-standard": "^0.12.1",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-nette": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.4",
"tharos/leanmapper": "^3.4.2 || ^4.0.0",
"tracy/tracy": "^2.6.3"
},
Expand All @@ -69,7 +70,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "6.10.x-dev"
"dev-master": "7.x-dev"
}
}
}
10 changes: 6 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
includes:
- ./vendor/contributte/code-rules/paveljanda/phpstan.neon
- ./vendor/phpstan/phpstan-nette/extension.neon
- ./vendor/phpstan/phpstan-nette/rules.neon
# - vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon

parameters:
level: 8

paths:
- src

reportMaybesInPropertyPhpDocTypes: false
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false

ignoreErrors:
-
Expand Down
44 changes: 21 additions & 23 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
<?xml version="1.0"?>
<ruleset>
<!-- Contributte Coding Standard -->
<rule ref="./vendor/ninjify/coding-standard/ruleset-gamee.xml">
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment"/>
<exclude name="SlevomatCodingStandard.Classes.MethodSpacing.IncorrectLinesCountBetweenMethods"/>
<exclude name="SlevomatCodingStandard.Classes.ClassMemberSpacing.IncorrectCountOfBlankLinesBetweenMembers"/>
<exclude name="SlevomatCodingStandard.Commenting.DisallowCommentAfterCode.DisallowedCommentAfterCode"/>
<exclude name="SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature.RequiredSingleLineSignature"/>
<exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator.RequiredNullCoalesceEqualOperator"/>
<exclude name="SlevomatCodingStandard.Files.LineLength.LineTooLong"/>
<exclude name="SlevomatCodingStandard.Functions.RequireMultiLineCall.RequiredMultiLineCall"/>
<exclude name="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator.MultiLineTernaryOperatorNotUsed"/>
<exclude name="SlevomatCodingStandard.Classes.RequireAbstractOrFinal.ClassNeitherAbstractNorFinal"/>
<rule ref="./vendor/ninjify/coding-standard/contributte.xml">
<exclude name="Squiz.PHP.Heredoc.NotAllowed"/>
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed"/>
<exclude name="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException"/>
</rule>

<!-- Specific rules -->
Expand All @@ -25,21 +19,25 @@
<property name="extensions" type="array" value="php,phpt"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.RequireSingleLineCall">
<properties>
<property name="maxLineLength" type="int" value="120"/>
<property name="alwaysForSimpleConditions" type="boolean" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition">
<properties>
<property name="maxLineLengtaash" type="int" value="120"/>
<property name="alwaysForSimpleConditions" type="boolean" value="false"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName.NoMatchBetweenTypeNameAndFileName">
<exclude-pattern>tests/Cases/DataSources/NextrasDataSourceTest.phpt</exclude-pattern>
<exclude-pattern>tests/Cases/DataSources/DoctrineDataSourceTest.phpt</exclude-pattern>
</rule>

<rule ref="PSR1.Classes.ClassDeclaration">
<exclude-pattern>*tests/Cases/*</exclude-pattern>
</rule>

<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>*tests/Cases/*</exclude-pattern>
</rule>

<rule ref="Squiz.Classes.ClassFileName.NoMatch">
<exclude-pattern>*tests/Cases/*</exclude-pattern>
</rule>

<rule ref="Generic.Classes.DuplicateClassName.Found">
<exclude-pattern>*tests/Cases/*</exclude-pattern>
</rule>
</ruleset>
42 changes: 10 additions & 32 deletions src/AggregationFunction/FunctionSum.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,25 @@
<?php

declare(strict_types=1);
<?php declare(strict_types = 1);

namespace Ublaboo\DataGrid\AggregationFunction;

use Dibi\Fluent;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\QueryBuilder;
use Nette\Database\Table\Selection;
use Nette\Utils\Strings;
use Nextras\Orm\Collection\DbalCollection;
use Nextras\Orm\Collection\ICollection;
use Ublaboo\DataGrid\Utils\PropertyAccessHelper;

class FunctionSum implements ISingleColumnAggregationFunction
{

/**
* @var string
*/
protected $column;

/**
* @var int
*/
protected $result = 0;

/**
* @var string
*/
protected $dataType;
protected int $result = 0;

/**
* @var callable|null
*/
/** @var callable|null */
protected $renderer = null;


public function __construct(
string $column,
string $dataType = IAggregationFunction::DATA_TYPE_PAGINATED
) {
$this->column = $column;
$this->dataType = $dataType;
public function __construct(protected string $column, protected string $dataType = IAggregationFunction::DATA_TYPE_PAGINATED)
{
}


Expand All @@ -65,7 +42,7 @@ public function processDataSource($dataSource): void
}

if ($dataSource instanceof QueryBuilder) {
$column = Strings::contains($this->column, '.')
$column = str_contains($this->column, '.')
? $this->column
: current($dataSource->getRootAliases()) . '.' . $this->column;

Expand All @@ -85,9 +62,9 @@ public function processDataSource($dataSource): void
});
}

if ( $dataSource instanceof DbalCollection) {
foreach( $dataSource->fetchAll() as $item )
$this->result += $item->getValue( $this->column );
if ($dataSource instanceof DbalCollection) {
foreach ($dataSource->fetchAll() as $item)
$this->result += $item->getValue($this->column);
}
}

Expand Down Expand Up @@ -116,4 +93,5 @@ public function setRenderer(?callable $callback = null): self

return $this;
}

}
5 changes: 2 additions & 3 deletions src/AggregationFunction/IAggregatable.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

declare(strict_types=1);
<?php declare(strict_types = 1);

namespace Ublaboo\DataGrid\AggregationFunction;

interface IAggregatable
{

public function processAggregation(IAggregationFunction $function): void;

}
5 changes: 2 additions & 3 deletions src/AggregationFunction/IAggregationFunction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
<?php declare(strict_types = 1);

namespace Ublaboo\DataGrid\AggregationFunction;

Expand All @@ -24,4 +22,5 @@ public function getFilterDataType(): string;
* @param Fluent|QueryBuilder|Collection|Selection|ICollection $dataSource
*/
public function processDataSource($dataSource): void;

}
5 changes: 2 additions & 3 deletions src/AggregationFunction/IMultipleAggregationFunction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
<?php declare(strict_types = 1);

namespace Ublaboo\DataGrid\AggregationFunction;

Expand All @@ -11,4 +9,5 @@ interface IMultipleAggregationFunction extends IAggregationFunction
* @return mixed
*/
public function renderResult(string $key);

}
5 changes: 2 additions & 3 deletions src/AggregationFunction/ISingleColumnAggregationFunction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
<?php declare(strict_types = 1);

namespace Ublaboo\DataGrid\AggregationFunction;

Expand All @@ -11,4 +9,5 @@ interface ISingleColumnAggregationFunction extends IAggregationFunction
* @return mixed
*/
public function renderResult();

}
16 changes: 5 additions & 11 deletions src/AggregationFunction/TDataGridAggregationFunction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
<?php declare(strict_types = 1);

namespace Ublaboo\DataGrid\AggregationFunction;

Expand All @@ -11,15 +9,10 @@
trait TDataGridAggregationFunction
{

/**
* @var array|ISingleColumnAggregationFunction[]
*/
private $aggregationFunctions = [];
/** @var array|ISingleColumnAggregationFunction[] */
private array $aggregationFunctions = [];

/**
* @var IMultipleAggregationFunction|null
*/
private $multipleAggregationFunction = null;
private ?IMultipleAggregationFunction $multipleAggregationFunction = null;

/**
* @return static
Expand Down Expand Up @@ -182,4 +175,5 @@ public function getMultipleAggregationFunction(): ?IMultipleAggregationFunction
{
return $this->multipleAggregationFunction;
}

}
Loading

0 comments on commit 516f215

Please sign in to comment.