Skip to content
Open
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ indent_style = tab
indent_size = tab
tab_width = 4

[{*.json, *.yaml, *.yml, *.md}]
[*.{json,yaml,yml,md}]
indent_style = space
indent_size = 2
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Not archived
.docs export-ignore
tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
phpstan.neon export-ignore
Makefile export-ignore
README.md export-ignore
phpstan.neon export-ignore
ruleset.xml export-ignore
tests export-ignore
10 changes: 0 additions & 10 deletions .github/.kodiak.toml

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: "Codesniffer"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]
Expand All @@ -10,8 +11,8 @@ on:
- cron: "0 8 * * 1"

jobs:
build:
codesniffer:
name: "Codesniffer"
uses: contributte/.github/.github/workflows/codesniffer.yml@v1
uses: contributte/.github/.github/workflows/codesniffer.yml@master
with:
php: "8.2"
18 changes: 18 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Coverage"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]

schedule:
- cron: "0 9 * * 1"

jobs:
coverage:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master
with:
php: "8.2"
7 changes: 4 additions & 3 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ name: "Phpstan"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"
- cron: "0 10 * * 1"

jobs:
build:
phpstan:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@v1
uses: contributte/.github/.github/workflows/phpstan.yml@master
with:
php: "8.2"
28 changes: 18 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,36 @@ name: "Nette Tester"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"
- cron: "0 10 * * 1"

jobs:
build84:
test85:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@v1
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@master
with:
php: "8.4"
php: "8.5"

build83:
test84:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@v1
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@master
with:
php: "8.3"
php: "8.4"

build82:
test83:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@v1
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@master
with:
php: "8.2"
php: "8.3"

test82:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-mysql.yml@master
with:
php: "8.2"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
/composer.lock

# Tests
/temp
/coverage.xml
/tests/tmp
/coverage.*
/tests/**/*.log
/tests/**/*.html
/tests/**/*.expected
/tests/**/*.actual
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
.PHONY: install qa cs csf phpstan tests coverage

.PHONY: install
install:
composer update

.PHONY: qa
qa: phpstan cs

.PHONY: cs
cs:
ifdef GITHUB_ACTION
vendor/bin/codesniffer -q --report=checkstyle src tests | cs2pr
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp -q --report=checkstyle src tests | cs2pr
else
vendor/bin/codesniffer src tests
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests
endif

.PHONY: csf
csf:
vendor/bin/codefixer src tests
vendor/bin/phpcbf --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests

.PHONY: phpstan
phpstan:
vendor/bin/phpstan analyse -c phpstan.neon src
vendor/bin/phpstan analyse -c phpstan.neon

.PHONY: tests
tests:
vendor/bin/tester -s -p php --colors 1 -C tests/Cases

.PHONY: coverage
coverage:
ifdef GITHUB_ACTION
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.xml --coverage-src src tests/Cases
Expand Down
26 changes: 12 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
],
"require": {
"php": ">=8.2",
"nextras/dbal": "^4.0.0"
"nextras/dbal": "^5.0.0"
},
"require-dev": {
"ninjify/qa": "^0.13",
"ninjify/nunjuck": "^0.4",
"nette/di": "^3.0.1",
"nextras/orm": "^4.0.0",
"contributte/phpstan": "~0.2.0",
"contributte/qa": "~0.4.0",
"contributte/tester": "~0.3.0",
"mockery/mockery": "^1.3.0",
"phpstan/phpstan": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.0.0",
"phpstan/phpstan-deprecation-rules": "^1.0.0",
"phpstan/phpstan-nette": "^1.0.0"
"nette/di": "^3.0.1",
"nextras/orm": "^5.0.0"
},
"autoload": {
"psr-4": {
Expand All @@ -37,14 +34,15 @@
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "0.7.x-dev"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
"branch-alias": {
"dev-master": "0.7.x-dev"
}
}
}
14 changes: 10 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
includes:
- 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
- vendor/contributte/phpstan/phpstan.neon

parameters:
level: 9
phpVersion: 80200

scanDirectories:
- src

fileExtensions:
- php

paths:
- src

ignoreErrors:
- identifier: trait.unused
31 changes: 24 additions & 7 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
<?xml version="1.0"?>
<ruleset name="Contributte">
<!-- Contributte Coding Standard -->
<rule ref="vendor/ninjify/coding-standard/contributte.xml"/>
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Contributte" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<!-- Rulesets -->
<rule ref="./vendor/contributte/qa/ruleset-8.2.xml"/>

<!-- Specific rules -->
<!-- Rules -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="Contributte\Nextras\Orm\QueryObject"/>
<element key="tests" value="Tests"/>
</property>
<property name="extensions" type="array" value="php,phpt" />
<property name="extensions" type="array">
<element value="php"/>
<element value="phpt"/>
</property>
</properties>
</rule>

<!-- Exclude folders -->
<!-- Exclude class naming rules for test files with inline helper classes -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName.NoMatchBetweenTypeNameAndFileName">
<exclude-pattern>/tests/Cases</exclude-pattern>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>/tests/Cases</exclude-pattern>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<exclude-pattern>/tests/Cases</exclude-pattern>
</rule>
<rule ref="Squiz.Classes.ClassFileName.NoMatch">
<exclude-pattern>/tests/Cases</exclude-pattern>
</rule>

<!-- Excludes -->
<exclude-pattern>/tests/tmp</exclude-pattern>
</ruleset>
6 changes: 3 additions & 3 deletions src/DI/NextrasQueryObjectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Contributte\Nextras\Orm\QueryObject\QueryObjectManager;
use Nette\DI\CompilerExtension;
use Nette\DI\Extensions\InjectExtension;
use Nextras\Orm\Mapper\Mapper;
use Nextras\Orm\Mapper\Dbal\DbalMapper;
use Nextras\Orm\Repository\Repository;

final class NextrasQueryObjectExtension extends CompilerExtension
Expand All @@ -31,11 +31,11 @@ public function beforeCompile(): void
{
$builder = $this->getContainerBuilder();

foreach ($builder->findByType(Repository::class) as $name => $def) {
foreach ($builder->findByType(Repository::class) as $def) {
$def->addTag(InjectExtension::TagInject);
}

foreach ($builder->findByType(Mapper::class) as $name => $def) {
foreach ($builder->findByType(DbalMapper::class) as $def) {
$def->addTag(InjectExtension::TagInject);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/ExecutableQueryObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
abstract class ExecutableQueryObject extends QueryObject
{

/** @var Connection */
protected $connection;
protected Connection $connection;

public function __construct(Connection $connection)
{
Expand Down
10 changes: 5 additions & 5 deletions src/QueryObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
abstract class QueryObject implements Queryable
{

protected function postQuery(QueryBuilder $builder): QueryBuilder
{
return $builder;
}

public function fetch(QueryBuilder $builder): QueryBuilder
{
// Build query
Expand All @@ -23,4 +18,9 @@ public function fetch(QueryBuilder $builder): QueryBuilder
return $qb;
}

protected function postQuery(QueryBuilder $builder): QueryBuilder
{
return $builder;
}

}
5 changes: 2 additions & 3 deletions src/QueryObjectContextAwareManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
class QueryObjectContextAwareManager implements QueryObjectManager
{

/** @var Container */
protected $context;
protected Container $context;

public function __construct(Container $context)
{
Expand Down Expand Up @@ -45,7 +44,7 @@ public function create(string $class): QueryObject
$obj = $this->context->getByType($class);

if (!($obj instanceof QueryObject)) {
throw new InvalidObjectCreationException(sprintf('Created object must be typed of %s, type of %s given.', QueryObject::class, get_class($obj)));
throw new InvalidObjectCreationException(sprintf('Created object must be typed of %s, type of %s given.', QueryObject::class, $obj::class));
}

return $obj;
Expand Down
Loading
Loading