Skip to content

Commit

Permalink
PHP 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
radimvaculik authored and f3l1x committed Jan 24, 2023
1 parent 1b0ff6a commit df2d054
Show file tree
Hide file tree
Showing 135 changed files with 1,150 additions and 3,325 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ csf:
vendor/bin/phpcbf --standard=ruleset.xml --extensions=php,phpt --tab-width=4 --ignore=tests/tmp --colors -nsp src tests

phpstan:
vendor/bin/phpstan analyse -c phpstan.neon
vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=4G

tests:
vendor/bin/tester -s -p php --colors 1 -C tests/Cases
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,28 @@
}
},
"require": {
"php": ">=7.2",
"php": ">=8.0",
"contributte/application": "^0.5.0",
"nette/di": "^3.0.0",
"nette/forms": "^3.1.3",
"nette/utils": "^3.0.1",
"symfony/property-access": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
},
"require-dev": {
"contributte/qa": "^0.3.0",
"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"
}
}
}
14 changes: 6 additions & 8 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 All @@ -20,10 +22,6 @@ parameters:
message: '/^Instanceof between Ublaboo\\DataGrid\\Filter\\Filter and Ublaboo\\DataGrid\\Filter\\FilterDateRange will always evaluate to false\.$/'
count: 1
path: src/DataGrid.php
-
message: '/^Class dibi referenced with incorrect case\: Dibi\.$/'
count: 1
path: src/DataModel.php
-
message: '/^Call to an undefined method Nextras\\Orm\\Collection\\ICollection\:\:getQueryBuilder\(\)\.$/'
count: 2
Expand Down
47 changes: 24 additions & 23 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?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/contributte/qa/ruleset-8.0.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"/>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>

<!-- Specific rules -->
Expand All @@ -25,21 +22,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>
56 changes: 12 additions & 44 deletions src/AggregationFunction/FunctionSum.php
Original file line number Diff line number Diff line change
@@ -1,61 +1,33 @@
<?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;
protected int $result = 0;

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

/**
* @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)
{
}


public function getFilterDataType(): string
{
return $this->dataType;
}


/**
* @param Fluent|QueryBuilder|Collection|Selection|ICollection $dataSource
*/
public function processDataSource($dataSource): void
public function processDataSource(Fluent|QueryBuilder|Collection|Selection|ICollection $dataSource): void
{
if ($dataSource instanceof Fluent) {
$connection = $dataSource->getConnection();
Expand All @@ -65,7 +37,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,17 +57,13 @@ 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);
}
}


/**
* @return mixed
*/
public function renderResult()
public function renderResult(): mixed
{
$result = $this->result;

Expand All @@ -106,7 +74,6 @@ public function renderResult()
return $result;
}


/**
* @return static
*/
Expand All @@ -116,4 +83,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;

}
9 changes: 2 additions & 7 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 @@ -19,9 +17,6 @@ interface IAggregationFunction

public function getFilterDataType(): string;

public function processDataSource(Fluent|QueryBuilder|Collection|Selection|ICollection $dataSource): void;

/**
* @param Fluent|QueryBuilder|Collection|Selection|ICollection $dataSource
*/
public function processDataSource($dataSource): void;
}
10 changes: 3 additions & 7 deletions src/AggregationFunction/IMultipleAggregationFunction.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php

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

namespace Ublaboo\DataGrid\AggregationFunction;

interface IMultipleAggregationFunction extends IAggregationFunction
{

/**
* @return mixed
*/
public function renderResult(string $key);
public function renderResult(string $key): mixed;

}
10 changes: 3 additions & 7 deletions src/AggregationFunction/ISingleColumnAggregationFunction.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php

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

namespace Ublaboo\DataGrid\AggregationFunction;

interface ISingleColumnAggregationFunction extends IAggregationFunction
{

/**
* @return mixed
*/
public function renderResult();
public function renderResult(): mixed;

}
Loading

0 comments on commit df2d054

Please sign in to comment.