Skip to content

Commit

Permalink
Add override method attributes (#2130)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek authored Nov 28, 2023
1 parent cb8e2d0 commit 30b06e6
Show file tree
Hide file tree
Showing 175 changed files with 425 additions and 190 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- php: 'latest'
type: 'Phpunit Burn'
env:
LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == '8.2' && matrix.type == 'Phpunit' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}"
LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == '8.3' && matrix.type == 'Phpunit' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}"
services:
mysql:
image: mysql:8
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
if [ -n "$LOG_COVERAGE" ]; then composer require --no-interaction --no-install phpunit/phpcov; fi
composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader
if [ "${{ matrix.type }}" = "Phpunit Lowest" ]; then composer update --ansi --prefer-dist --prefer-lowest --prefer-stable --no-interaction --no-progress --optimize-autoloader; fi
if [ "${{ matrix.type }}" = "Phpunit Burn" ]; then sed -i 's~public function runBare(): void~public function runBare(): void { gc_collect_cycles(); gc_collect_cycles(); $memDiffs = array_fill(0, '"$(if [ \"$GITHUB_EVENT_NAME\" == \"schedule\" ]; then echo 64; else echo 16; fi)"', 0); for ($i = -1; $i < count($memDiffs); ++$i) { $this->_runBare(); gc_collect_cycles(); gc_collect_cycles(); $mem = memory_get_usage(); if ($i !== -1) { $memDiffs[$i] = $mem - $memPrev; } $memPrev = $mem; rsort($memDiffs); if (array_sum($memDiffs) >= 4096 * 1024 || $memDiffs[2] > 0) { $this->onNotSuccessfulTest(new AssertionFailedError("Memory leak detected! (" . implode(" + ", array_map(static fn ($v) => number_format($v / 1024, 3, ".", " "), array_filter($memDiffs))) . " KB, " . ($i + 2) . " iterations)")); } } } private function _runBare(): void~' vendor/phpunit/phpunit/src/Framework/TestCase.php && cat vendor/phpunit/phpunit/src/Framework/TestCase.php | grep '_runBare('; fi
if [ "${{ matrix.type }}" = "Phpunit Burn" ]; then sed -i 's~public function runBare(): void~public function runBare(): void { gc_collect_cycles(); $memDiffs = array_fill(0, '"$(if [ \"$GITHUB_EVENT_NAME\" == \"schedule\" ]; then echo 64; else echo 16; fi)"', 0); $emitter = Event\\Facade::emitter(); for ($i = -1; $i < count($memDiffs); ++$i) { $this->_runBare(); if ($this->inIsolation) { $dispatcher = \\Closure::bind(static fn () => $emitter->dispatcher, null, Event\\DispatchingEmitter::class)(); if ($i === -1) { $dispatcherEvents = $dispatcher->flush()->asArray(); } else { $dispatcher->flush(); } foreach ($dispatcherEvents as $event) { $dispatcher->dispatch($event); } } gc_collect_cycles(); $mem = memory_get_usage(); if ($i !== -1) { $memDiffs[$i] = $mem - $memPrev; } $memPrev = $mem; rsort($memDiffs); if (array_sum($memDiffs) >= 4096 * 1024 || $memDiffs[2] > 0) { $e = new AssertionFailedError("Memory leak detected! (" . implode(" + ", array_map(static fn ($v) => number_format($v / 1024, 3, ".", " "), array_filter($memDiffs))) . " KB, " . ($i + 2) . " iterations)"); $this->status = TestStatus::failure($e->getMessage()); $emitter->testFailed($this->valueObjectForEvents(), Event\\Code\\ThrowableBuilder::from($e), Event\\Code\\ComparisonFailureBuilder::from($e)); $this->onNotSuccessfulTest($e); } } } private function _runBare(): void~' vendor/phpunit/phpunit/src/Framework/TestCase.php && cat vendor/phpunit/phpunit/src/Framework/TestCase.php | grep '_runBare('; fi
- name: Init
run: |
Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:
- php: 'latest'
type: 'Firefox Slow'
env:
LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == '8.2' && matrix.type == 'Chrome' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}"
LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == '8.3' && matrix.type == 'Chrome' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}"
services:
mysql:
image: mysql:8
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Agile UI is the quickest way for building back-end UI, admin interfaces, data ma

[![Build](https://github.com/atk4/ui/actions/workflows/test-unit.yml/badge.svg?branch=develop)](https://github.com/atk4/ui/actions?query=branch:develop)
[![CodeCov](https://codecov.io/gh/atk4/ui/branch/develop/graph/badge.svg)](https://codecov.io/gh/atk4/ui)
[![GitHub release](https://img.shields.io/github/release/atk4/ui.svg)](CHANGELOG.md)
[![GitHub release](https://img.shields.io/github/release/atk4/ui.svg)](https://github.com/atk4/ui/releases)
[![Code Climate](https://codeclimate.com/github/atk4/ui/badges/gpa.svg)](https://codeclimate.com/github/atk4/ui)

Quick-Links: [Documentation](https://atk4-ui.readthedocs.io/). [Demo-site](https://ui.atk4.org/). [ATK Data](https://github.com/atk4/data). [Discord community](https://discord.gg/QVKSk2B).
Expand Down Expand Up @@ -41,9 +41,9 @@ Many companies use Agile Toolkit to implement admin interface and in some cases

### How does it work?

Download from [releases](https://github.com/atk4/ui/releases) or install Agile UI with `composer require atk4/ui` using composer.
Install Agile UI with `composer require atk4/ui` using composer.

Create "index.php" file with:
Create `index.php` file with:

```php
<?php
Expand Down Expand Up @@ -78,7 +78,7 @@ ATK UI relies on https://fomantic-ui.com CSS framework to render the form beauti

To get most of ATK UI, use [ATK Data](https://github.com/atk4/data) to describe your business models such as "User" or "Purchase". When you define models, you can start using some more advanced components:

[Crud](https://ui.atk4.org/demos/crud.php) is a fully-interactive component that supports pagination, reloading, conditions, data formatting, sorting, quick-search, ordering, custom actions and modals, but at the same time is very easy to use:
[Crud](https://ui.atk4.org/demos/collection/crud.php) is a fully-interactive component that supports pagination, reloading, conditions, data formatting, sorting, quick-search, ordering, custom actions and modals, but at the same time is very easy to use:

```php
$app = new \Atk4\Ui\App(['title' => 'hello world']);
Expand Down
2 changes: 2 additions & 0 deletions demos/_demo-data/create-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private function prefixFieldName(string $fieldName, bool $forActualName = false)
return 'atk_' . ($forActualName ? 'a' : '') . 'fp_' . $tableShort . '__' . $fieldShort;
}

#[\Override]
public function addField(string $name, $seed = []): \Atk4\Data\Field
{
if ($name === 'id') {
Expand All @@ -57,6 +58,7 @@ public function addField(string $name, $seed = []): \Atk4\Data\Field
return parent::addField($this->prefixFieldName($name), $seed);
}

#[\Override]
public function import(array $rowsMulti)
{
return parent::import(array_map(function (array $rows): array {
Expand Down
1 change: 1 addition & 0 deletions demos/_includes/Counter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Counter extends Form\Control\Line
{
public $content = '20';

#[\Override]
protected function init(): void
{
parent::init();
Expand Down
1 change: 1 addition & 0 deletions demos/_includes/Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Demo extends Columns
/** @var int */
public $rightWidth = 8;

#[\Override]
protected function init(): void
{
parent::init();
Expand Down
1 change: 1 addition & 0 deletions demos/_includes/DemoInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class DemoInvoice extends Model
{
public ?string $titleField = 'reference';

#[\Override]
protected function init(): void
{
parent::init();
Expand Down
1 change: 1 addition & 0 deletions demos/_includes/Flyers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class Flyers extends Model
{
#[\Override]
protected function init(): void
{
parent::init();
Expand Down
1 change: 1 addition & 0 deletions demos/_includes/FlyersForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FlyersForm extends Form
['name' => 'Around the world', 'id' => 3, 'nodes' => []],
];

#[\Override]
protected function init(): void
{
parent::init();
Expand Down
1 change: 1 addition & 0 deletions demos/_includes/PromotionText.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

class PromotionText extends View
{
#[\Override]
protected function init(): void
{
parent::init();
Expand Down
1 change: 1 addition & 0 deletions demos/_includes/ReloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class ReloadTest extends View
{
#[\Override]
protected function init(): void
{
parent::init();
Expand Down
1 change: 1 addition & 0 deletions demos/_includes/SomeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function __construct()
parent::__construct($fakerPersistence);
}

#[\Override]
protected function init(): void
{
parent::init();
Expand Down
1 change: 1 addition & 0 deletions demos/_includes/ViewTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
class ViewTester extends View
{
#[\Override]
protected function init(): void
{
parent::init();
Expand Down
15 changes: 15 additions & 0 deletions demos/_unit-test/stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,69 +37,82 @@ public function throwNotSupported(): void
throw new Exception('Not implemented/supported');
}

#[\Override]
public function __toString(): string
{
$this->throwNotSupported();
}

#[\Override]
public function close(): void
{
$this->pos = null;
$this->buffer = '';
}

#[\Override]
public function detach()
{
$this->close();

return null;
}

#[\Override]
public function getSize(): int
{
return $this->size;
}

#[\Override]
public function tell(): int
{
return $this->pos;
}

#[\Override]
public function eof(): bool
{
return $this->pos === $this->size;
}

#[\Override]
public function isSeekable(): bool
{
return false;
}

#[\Override]
public function seek($offset, $whence = \SEEK_SET): void
{
$this->throwNotSupported();
}

#[\Override]
public function rewind(): void
{
$this->seek(0);
}

#[\Override]
public function isWritable(): bool
{
return false;
}

#[\Override]
public function write($string): int
{
$this->throwNotSupported();
}

#[\Override]
public function isReadable(): bool
{
return true;
}

#[\Override]
public function read($length): string
{
if ($this->pos + $length > $this->size) {
Expand All @@ -117,11 +130,13 @@ public function read($length): string
return $res;
}

#[\Override]
public function getContents(): string
{
$this->throwNotSupported();
}

#[\Override]
public function getMetadata($key = null)
{
$this->throwNotSupported();
Expand Down
1 change: 1 addition & 0 deletions demos/basic/columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
$boxClass = AnonymousClassNameCache::get_class(fn () => new class() extends View {
public $ui = 'segment';

#[\Override]
protected function init(): void
{
parent::init();
Expand Down
1 change: 1 addition & 0 deletions demos/collection/crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
Header::addTo($column, ['Customizations']);

$myExecutorClass = AnonymousClassNameCache::get_class(fn () => new class() extends ModalExecutor {
#[\Override]
public function addFormTo(View $view): Form
{
$columns = Columns::addTo($view);
Expand Down
1 change: 1 addition & 0 deletions demos/collection/crud3.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

public $caption = 'Country';

#[\Override]
protected function init(): void
{
parent::init();
Expand Down
1 change: 1 addition & 0 deletions demos/collection/multitable.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$finderClass = AnonymousClassNameCache::get_class(fn () => new class() extends Columns {
public array $route = [];

#[\Override]
public function setModel(Model $model, array $route = []): void
{
parent::setModel($model);
Expand Down
1 change: 1 addition & 0 deletions demos/collection/tablecolumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
require_once __DIR__ . '/../init-app.php';

$modelColorClass = AnonymousClassNameCache::get_class(fn () => new class() extends Model {
#[\Override]
protected function init(): void
{
parent::init();
Expand Down
2 changes: 2 additions & 0 deletions demos/form/form2.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
$personClass = AnonymousClassNameCache::get_class(fn () => new class() extends Model {
public $table = 'person';

#[\Override]
protected function init(): void
{
parent::init();
Expand All @@ -98,6 +99,7 @@ protected function init(): void
$this->hasOne('country_dropdown_id', ['model' => [Country::class], 'ui' => ['form' => new Form\Control\Dropdown()]]); // this works slow
}

#[\Override]
public function validate(string $intent = null): array
{
$errors = parent::validate($intent);
Expand Down
Loading

0 comments on commit 30b06e6

Please sign in to comment.