Skip to content
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
2 changes: 2 additions & 0 deletions .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ jobs:
codesniffer:
name: "Codesniffer"
uses: contributte/.github/.github/workflows/codesniffer.yml@v1
with:
php: "8.4"
3 changes: 2 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ on:

jobs:
coverage:
name: "Phpunit"
name: "Coverage"
uses: contributte/.github/.github/workflows/phpunit-coverage.yml@v1
with:
php: "8.4"
make: "init coverage"
55 changes: 55 additions & 0 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Database"

on:
pull_request:

push:
branches: ["*"]

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

jobs:
database:
name: "Database"
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16
env:
POSTGRES_USER: contributte
POSTGRES_PASSWORD: contributte
POSTGRES_DB: contributte
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
extensions: pdo, pdo_pgsql

- name: Install dependencies
run: composer install --no-interaction --prefer-dist

- name: Setup config
run: |
cp config/local.neon.example config/local.neon
sed -i 's/host: 0.0.0.0/host: 127.0.0.1/' config/local.neon
mkdir -p var/tmp var/log
chmod +0777 var/tmp var/log

- name: Run migrations
run: NETTE_DEBUG=1 bin/console migrations:migrate --no-interaction --allow-no-migration
env:
NETTE_ENV: test
1 change: 1 addition & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ jobs:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@v1
with:
php: "8.4"
make: "init phpstan"
15 changes: 4 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Phpunit"
name: "Tester"

on:
pull_request:
Expand All @@ -10,16 +10,9 @@ on:
- cron: "0 8 * * 1"

jobs:
test82:
name: "Phpunit"
test84:
name: "Tester"
uses: contributte/.github/.github/workflows/phpunit.yml@v1
with:
php: "8.2"
make: "init tests"

test81:
name: "Phpunit"
uses: contributte/.github/.github/workflows/phpunit.yml@v1
with:
php: "8.1"
php: "8.4"
make: "init tests"
4 changes: 3 additions & 1 deletion app/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Contributte\Bootstrap\ExtraConfigurator;
use Nette\Application\Application as NetteApplication;
use Nette\Bootstrap\Configurator;
use Nette\DI\Compiler;
use Symfony\Component\Console\Application as SymfonyApplication;
use Tracy\Debugger;
Expand All @@ -16,8 +17,9 @@ public static function boot(): ExtraConfigurator
$configurator = new ExtraConfigurator();
$configurator->setTempDirectory(__DIR__ . '/../var/tmp');

$configurator->onCompile[] = function (ExtraConfigurator $configurator, Compiler $compiler): void {
$configurator->onCompile[] = static function (Configurator $configurator, Compiler $compiler): void {
// Add env variables to config structure
assert($configurator instanceof ExtraConfigurator);
$compiler->addConfig(['parameters' => $configurator->getEnvironmentParameters()]);
};

Expand Down
4 changes: 2 additions & 2 deletions app/Domain/User/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

/**
* @method User|NULL find($id, ?int $lockMode = NULL, ?int $lockVersion = NULL)
* @method User|NULL findOneBy(array $criteria, array $orderBy = NULL)
* @method User|NULL findOneBy(array<string, mixed> $criteria, ?array<string, string> $orderBy = NULL)
* @method User[] findAll()
* @method User[] findBy(array $criteria, array $orderBy = NULL, ?int $limit = NULL, ?int $offset = NULL)
* @method User[] findBy(array<string, mixed> $criteria, ?array<string, string> $orderBy = NULL, ?int $limit = NULL, ?int $offset = NULL)
* @extends AbstractRepository<User>
*/
class UserRepository extends AbstractRepository
Expand Down
3 changes: 3 additions & 0 deletions app/Model/Database/Query/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public function setup(): void
// Can be defined in child.
}

/**
* @return Query<null, mixed>
*/
public function doQuery(EntityManagerInterface $em): Query
{
$qb = $em->createQueryBuilder();
Expand Down
3 changes: 3 additions & 0 deletions app/Model/Database/Query/Queryable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
interface Queryable
{

/**
* @return Query<null, mixed>
*/
public function doQuery(EntityManagerInterface $em): Query;

}
14 changes: 14 additions & 0 deletions app/Model/Latte/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Model\Latte;

use DateTimeInterface;
use Nette\Neon\Neon;
use Nette\StaticClass;
use Nette\Utils\Json;
Expand All @@ -11,6 +12,19 @@ final class Filters

use StaticClass;

public static function datetime(DateTimeInterface|string|int|null $value, string $format = 'j. n. Y'): string
{
if ($value === null) {
return '';
}

if (is_string($value) || is_int($value)) {
$value = new \DateTimeImmutable(is_int($value) ? '@' . $value : $value);
}

return $value->format($format);
}

public static function neon(mixed $value): string
{
return Neon::encode($value, true);
Expand Down
16 changes: 0 additions & 16 deletions app/Model/Latte/Macros.php

This file was deleted.

13 changes: 9 additions & 4 deletions app/Model/Latte/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,23 @@ public function __construct(
IRequest $httpRequest,
SecurityUser $user,
Storage $cacheStorage,
string $templateClass = null
?string $templateClass = null
)
{
parent::__construct($latteFactory, $httpRequest, $user, $cacheStorage, $templateClass);
$this->latteFactory = $latteFactory;
$this->user = $user;
}

public function createTemplate(Control $control = null, string $class = null): Template
/**
* @template T of Template
* @param class-string<T>|null $class
* @return T
*/
public function createTemplate(?Control $control = null, ?string $class = null): Template
{
/** @var Template $template */
$template = parent::createTemplate($control);
/** @var T $template */
$template = parent::createTemplate($control, $class);

// Remove default $template->user for prevent misused
unset($template->user);
Expand Down
2 changes: 1 addition & 1 deletion app/Model/Latte/TemplateProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @property-read BaseControl $control
* @property-read string $baseUri
* @property-read string $basePath
* @property-read array $flashes
* @property-read array<\stdClass> $flashes
*/
final class TemplateProperty extends Template
{
Expand Down
5 changes: 4 additions & 1 deletion app/Model/Security/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class Identity extends NetteIdentity

public function getFullname(): string
{
return sprintf('%s %s', $this->data['name'] ?? '', $this->data['surname'] ?? '');
/** @phpstan-ignore method.deprecatedClass */
$data = $this->getData();

return sprintf('%s %s', $data['name'] ?? '', $data['surname'] ?? '');
}

}
4 changes: 2 additions & 2 deletions app/UI/Control/TFlashMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\UI\Control;

use App\UI\Modules\Base\BasePresenter;
use Nette\HtmlStringable;
use stdClass;
use Stringable;

/**
* @mixin BasePresenter
Expand All @@ -13,7 +13,7 @@ trait TFlashMessage
{

/**
* @param string|stdClass|HtmlStringable $message
* @param string|stdClass|Stringable $message
* @internal
*/
public function flashMessage(mixed $message, string $type = 'info'): stdClass
Expand Down
1 change: 1 addition & 0 deletions app/UI/Control/TTranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* @mixin BasePresenter
* @phpstan-ignore trait.unused
*/
trait TTranslate
{
Expand Down
6 changes: 3 additions & 3 deletions app/UI/Form/BaseForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class BaseForm extends Form
public function addNumeric(string $name, ?string $label = null): TextInput
{
$input = self::addText($name, $label);
$input->addCondition(self::FILLED)
->addRule(self::MAX_LENGTH, null, 255)
->addRule(self::NUMERIC);
$input->addCondition(self::Filled)
->addRule(self::MaxLength, null, 255)
->addRule(self::Numeric);

return $input;
}
Expand Down
54 changes: 27 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,42 @@
"license": "MIT",
"type": "project",
"require": {
"php": ">=8.1",
"php": ">=8.2",

"contributte/bootstrap": "^0.6.0",
"contributte/application": "^0.5.0",
"contributte/cache": "^0.6.0",
"contributte/console": "^0.10.0",
"contributte/bootstrap": "^0.7.0",
"contributte/application": "^0.6.0",
"contributte/cache": "^0.7.0",
"contributte/console": "^0.11.0",
"contributte/console-extra": "^0.8.0",
"contributte/event-dispatcher": "^0.10.0",
"contributte/event-dispatcher": "^0.9.0",
"contributte/event-dispatcher-extra": "^0.10.0",
"contributte/di": "^0.5.0",
"contributte/di": "^0.6.0",
"contributte/forms": "^0.5.0",
"contributte/http": "^0.4.0",
"contributte/latte": "^0.5.0",
"contributte/mail": "^0.7.0",
"contributte/mailing": "^0.5.0",
"contributte/monolog": "^0.5.0",
"contributte/http": "^0.5.0",
"contributte/latte": "^0.6.0",
"contributte/mail": "^0.8.0",
"contributte/mailing": "^0.7.0",
"contributte/monolog": "^0.6.0",
"contributte/security": "^0.4.0",
"contributte/utils": "^0.6.0",
"contributte/utils": "^0.7.0",
"contributte/tracy": "^0.6.0",
"contributte/pdf": "^7.0.0",
"contributte/pdf": "^8.0.0",

"nettrine/annotations": "^0.7.0",
"nettrine/orm": "^0.8.0",
"nettrine/dbal": "^0.8.0",
"nettrine/cache": "^0.3.0",
"nettrine/migrations": "^0.9.1",
"nettrine/fixtures": "^0.8.0"
"nettrine/annotations": "^0.9.0",
"nettrine/orm": "^0.10.0",
"nettrine/dbal": "^0.10.0",
"nettrine/cache": "^0.5.0",
"nettrine/migrations": "^0.10.0",
"nettrine/fixtures": "^0.9.0"
},
"require-dev": {
"contributte/qa": "^0.3",
"contributte/tester": "^0.2",
"contributte/phpstan": "^0.1",
"contributte/dev": "^0.5",
"mockery/mockery": "^1.3.0",
"nelmio/alice": "^3.5.8",
"phpstan/phpstan-doctrine": "^1.3.40"
"contributte/qa": "^0.4.0",
"contributte/tester": "^0.3.0",
"contributte/phpstan": "^0.3.0",
"contributte/dev": "^0.5.0",
"mockery/mockery": "^1.6.0",
"nelmio/alice": "^3.14.0",
"phpstan/phpstan-doctrine": "^2.0.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading