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
99 changes: 49 additions & 50 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,58 @@ on:

jobs:
unit-test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.2']
php: ["8.3"]

steps:
- uses: actions/checkout@v3

- name: Setup PHP with PCOV
uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.php}}
coverage: pcov

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

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

- name: CodeStyle
run: vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --verbose

- name: Static analysis
run: vendor/bin/phpstan analyse

- name: Setup Apache for http app-test
uses: ./.github/actions/apache-setup
with:
php-version: ${{ matrix.php }}
site-directory: /home/runner/work/fohn-ui/fohn-ui
http-port: 7000

- name: Run test suite
run: composer run-script unit-test

- name: merge coverage
run: vendor/bin/phpcov merge build/logs/ --clover build/coverage/merged.xml

- name: Upload Coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: build/coverage/merged.xml
verbose: true
- uses: actions/checkout@v3

- name: Setup PHP with PCOV
uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.php}}
coverage: pcov

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

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

- name: CodeStyle
run: vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --verbose

- name: Static analysis
run: vendor/bin/phpstan analyse

- name: Setup Apache for http app-test
uses: ./.github/actions/apache-setup
with:
php-version: ${{ matrix.php }}
site-directory: /home/runner/work/fohn-ui/fohn-ui
http-port: 7000

- name: Run test suite
run: composer run-script unit-test

- name: merge coverage
run: vendor/bin/phpcov merge build/logs/ --clover build/coverage/merged.xml

- name: Upload Coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: build/coverage/merged.xml
verbose: true
6 changes: 0 additions & 6 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
->setRiskyAllowed(true)
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@PHP74Migration:risky' => true,
'@PHP74Migration' => true,

// required by PSR-12
'concat_space' => [
Expand Down Expand Up @@ -62,9 +59,6 @@
'general_phpdoc_annotation_remove' => [
'annotations' => ['author', 'copyright', 'throws'],
],
'nullable_type_declaration_for_default_null_value' => [
'use_nullable_type_declaration' => false,
],

// fn => without curly brackets is less readable,
// also prevent bounding of unwanted variables for GC
Expand Down
2 changes: 1 addition & 1 deletion app-test/_includes/Model/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function init(): void
});
}

public function validate(string $intent = null): array
public function validate(?string $intent = null): array
{
$errors = parent::validate($intent);

Expand Down
2 changes: 1 addition & 1 deletion app-test/_includes/Model/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function init(): void
]);
}

public function validate(string $intent = null): array
public function validate(?string $intent = null): array
{
$errors = parent::validate($intent);
if (mb_strlen($this->get('first_name') ?? '') < 2) {
Expand Down
2 changes: 1 addition & 1 deletion app-test/_includes/Model/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getFilesHierarchy(bool $isFolderSelectable = true): array
/**
* Return Files Hierarchy as a TreeNode property.
*/
private function getHierarchicalTreeNodes(array $files, int $useId = null, bool $isFolderSelectable): array
private function getHierarchicalTreeNodes(array $files, ?int $useId = null, bool $isFolderSelectable = true): array
{
$parent = [];
// Get top level files or folders.
Expand Down
4 changes: 2 additions & 2 deletions app-test/basic/grid-layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

require_once __DIR__ . '/../init-ui.php';

$viewStyle =
[
$viewStyle
= [
'text-white',
'flex',
'items-center',
Expand Down
1 change: 1 addition & 0 deletions app-test/collection/table-as-crud.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Create a Table Vue Component and display Country data
* using an Atk4\Country model.
Expand Down
1 change: 1 addition & 0 deletions app-test/collection/table-filter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Create a Table Vue Component and display Country data
* using an Atk4\Country model.
Expand Down
2 changes: 1 addition & 1 deletion app-test/interactive/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require_once __DIR__ . '/../init-ui.php';

/** @var View $testRunClass */
$testRunClass = get_class(new class() extends View {
$testRunClass = get_class(new class extends View {
public function generateReport(LoggerInterface $console): array
{
$console->log('info', 'Console Implements Logger Interface');
Expand Down
7 changes: 7 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

header('Location: ./app-test/index.php');

exit;
1 change: 1 addition & 0 deletions src/App/ResponseEmitter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Credit to Slim Framework (https://slimframework.com).
*
Expand Down
4 changes: 2 additions & 2 deletions src/Callback/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function getRunningCallbackArgs(): array
return static::$runningCallbackArgs;
}

public static function protect(string $redirectUrl = null): void
public static function protect(?string $redirectUrl = null): void
{
self::$guard = true;
self::$csfrRedirectUrl = $redirectUrl;
Expand All @@ -57,7 +57,7 @@ protected function initRenderTree(): void
$this->setUrlTrigger($this->urlTrigger);
}

public function setUrlTrigger(string $trigger = null): void
public function setUrlTrigger(?string $trigger = null): void
{
if (!$trigger && strlen($this->getViewId()) > 10) {
$this->urlTrigger = Ui::service()->factoryId($this->getViewId());
Expand Down
6 changes: 3 additions & 3 deletions src/Callback/ServerEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected function initStreamingApp(): void
$this->app = new App(['registerShutdown' => false]);
}

public function onRequest(\Closure $fx, array $params = [], \Closure $onAbortedFx = null): void
public function onRequest(\Closure $fx, array $params = [], ?\Closure $onAbortedFx = null): void
{
if ($onAbortedFx) {
$this->onAborted($onAbortedFx);
Expand Down Expand Up @@ -139,7 +139,7 @@ protected function sendBlock(string $id, string $event, string $name): void
$this->app->streamEvent($streamEvent, $this->minBufferSize);
}

public function start(JsStatements $statements = null): JsRenderInterface
public function start(?JsStatements $statements = null): JsRenderInterface
{
if (!$statements) {
$statements = JsStatements::with([]);
Expand All @@ -152,7 +152,7 @@ public function start(JsStatements $statements = null): JsRenderInterface
return $statements;
}

public function stop(JsStatements $statements = null): JsRenderInterface
public function stop(?JsStatements $statements = null): JsRenderInterface
{
if (!$statements) {
$statements = JsStatements::with([]);
Expand Down
4 changes: 2 additions & 2 deletions src/Component/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function initRenderTree(): void
$this->initDefaultLayout(self::MAIN_LAYOUT, $this->defaultLayout);
}

protected function initDefaultLayout(string $layoutName, FormLayoutInterface $layout = null): self
protected function initDefaultLayout(string $layoutName, ?FormLayoutInterface $layout = null): self
{
$this->defaultLayout = $layout ?: Ui::service()->getFormLayout();

Expand Down Expand Up @@ -180,7 +180,7 @@ public function addControls(array $controls, string $layoutName = self::MAIN_LAY
return $this;
}

public function addControl(Control $control, string $layoutName = self::MAIN_LAYOUT, string $regionName = null): Control
public function addControl(Control $control, string $layoutName = self::MAIN_LAYOUT, ?string $regionName = null): Control
{
$this->registerControl($control);

Expand Down
2 changes: 1 addition & 1 deletion src/Component/Form/Layout/FormLayoutInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

interface FormLayoutInterface
{
public function setSubmitButton(Button $button = null): self;
public function setSubmitButton(?Button $button = null): self;

public function addButton(Button $button): Button;

Expand Down
4 changes: 2 additions & 2 deletions src/Component/Form/Layout/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function addSubmitButton(bool $add): void
$this->addSubmitBtnInLayout = false;
}

public function setSubmitButton(Button $button = null): self
public function setSubmitButton(?Button $button = null): self
{
if (!$button) {
$button = Button::factoryFromSeed($this->defaultSubmitBtnSeed);
Expand All @@ -46,7 +46,7 @@ public function setSubmitButton(Button $button = null): self
return $this;
}

public function addControl(Control $control, string $regionName = null): Control
public function addControl(Control $control, ?string $regionName = null): Control
{
if (!$regionName) {
$regionName = $this->template->hasTag(self::CTRL_REGION_PREFIX . $control->getControlName()) ? self::CTRL_REGION_PREFIX . $control->getControlName() : View::MAIN_TEMPLATE_REGION;
Expand Down
4 changes: 2 additions & 2 deletions src/Component/Modal/AsDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AsDialog extends Modal
* When calling this method with no Closure function, the modal will
* close without triggering a callback event.
*/
public function addCancelEvent(\Closure $fx = null, View $trigger = null): View
public function addCancelEvent(?\Closure $fx = null, ?View $trigger = null): View
{
$cancelTrigger = $trigger ?: View::factoryFromSeed($this->cancelButtonSeed);
if ($fx) {
Expand All @@ -45,7 +45,7 @@ public function addCancelEvent(\Closure $fx = null, View $trigger = null): View
return $cancelTrigger;
}

public function addConfirmEvent(\Closure $fx = null, View $trigger = null): View
public function addConfirmEvent(?\Closure $fx = null, ?View $trigger = null): View
{
$confirmTrigger = $trigger ?: View::factoryFromSeed($this->confirmButtonSeed);
if ($fx) {
Expand Down
4 changes: 2 additions & 2 deletions src/Component/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function jsGetCellValue(string $colName): JsRenderInterface
return $this->jsGetStore(self::PINIA_PREFIX)->getCellValue(Js::var($idVar), Js::string($colName));
}

public function addActionColumn(string $columnName, string $actionName, View\Button $button, Header $header = null, string $eventName = 'click.stop'): JsFunction
public function addActionColumn(string $columnName, string $actionName, View\Button $button, ?Header $header = null, string $eventName = 'click.stop'): JsFunction
{
if (!$this->hasColumn($columnName)) {
if (!$header) {
Expand Down Expand Up @@ -242,7 +242,7 @@ public function addFilter(Filter $filter, string $regionName = self::FILTER_REGI
return $this->filter;
}

public function filterColumns(array $columnFilters, Filter $filter = null): self
public function filterColumns(array $columnFilters, ?Filter $filter = null): self
{
if (!$this->filter) {
$this->addFilter($filter ?? new Filter());
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Table/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getConfirmationModal(): ?AsDialog
return $this->confirmationModal;
}

public function addConfirmationDialog(string $title, Messages $messages, View\Button $ok = null, View\Button $cancel = null, bool $isClosable = true): self
public function addConfirmationDialog(string $title, Messages $messages, ?View\Button $ok = null, ?View\Button $cancel = null, bool $isClosable = true): self
{
$this->addProperty('messages', $messages->getJsMessages());
$this->confirmationModal = AsDialog::addTo($this, ['title' => $title, 'isClosable' => $isClosable]);
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Table/Filter/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Date extends Generic implements FilterColumnInterface
protected string $type = 'date';
protected string $format;

public function __construct(string $id, string $format = 'Y-m-d', string $label = null, array $props = [])
public function __construct(string $id, string $format = 'Y-m-d', ?string $label = null, array $props = [])
{
$props['config'] = Utils::getFlatPickrConfig($this->type, $format);
$props['config']['allowInput'] = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Table/Filter/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class Generic
'type' => 'text',
];

public function __construct(string $id, string $label = null, array $props = [])
public function __construct(string $id, ?string $label = null, array $props = [])
{
$this->id = $id;
$this->label = $label ?? ucfirst($id);
Expand Down
4 changes: 2 additions & 2 deletions src/Component/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function setValue(array $value): void
* Function $fx to be executed when using Save Btn.
* The callback function ($fx) must return a jsRenderInterface.
*/
public function onTreePost(\Closure $fx, Button $btn = null): void
public function onTreePost(\Closure $fx, ?Button $btn = null): void
{
$this->initTreePostRequest($fx);

Expand Down Expand Up @@ -168,7 +168,7 @@ public function onTreeNodeChanged(\Closure $fx): void
});
}

public function setFilter(array $fields, string $mode = 'lenient', string $placeholder = null, ?string $locale = 'en'): self
public function setFilter(array $fields, string $mode = 'lenient', ?string $placeholder = null, ?string $locale = 'en'): self
{
$this->ptProps['filter'] = true;
$this->ptProps['filterBy'] = implode(',', $fields);
Expand Down
2 changes: 1 addition & 1 deletion src/Core/ContainerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getOwner(): AbstractView
* Starting with the immediate owner of the view and each owner of view-owner
* until no more owner is set.
*/
public function getOwners(AbstractView $view = null, array $owners = []): array
public function getOwners(?AbstractView $view = null, array $owners = []): array
{
if (!$view) {
$view = $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Exception extends \Exception
/** @var string[] */
private array $solutions = []; // store solutions

public function __construct(string $message = '', int $code = 0, \Throwable $previous = null)
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);

Expand Down
2 changes: 1 addition & 1 deletion src/Core/ExceptionRenderer/RendererAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class RendererAbstract

public string $output = '';

final public function __construct(\Throwable $exception, \Throwable $parent_exception = null)
final public function __construct(\Throwable $exception, ?\Throwable $parent_exception = null)
{
$this->exception = $exception;
$this->parent_exception = $parent_exception;
Expand Down
Loading