diff --git a/demos/_includes/MigratorConsole.php b/demos/_includes/MigratorConsole.php index 87f07697..c0ceb54e 100644 --- a/demos/_includes/MigratorConsole.php +++ b/demos/_includes/MigratorConsole.php @@ -8,6 +8,7 @@ use Atk4\Core\DynamicMethodTrait; use Atk4\Core\Factory; use Atk4\Core\HookTrait; +use Atk4\Data\Model; use Atk4\Data\Schema\Migrator; use Atk4\Ui\Console; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8912227f..03f9f173 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -13,7 +13,6 @@ parameters: # relax strict rules - '~^Only booleans are allowed in .+, .+ given( on the (left|right) side)?\.~' - - '~^Variable (static )?(property access|method call) on .+\.~' # TODO these rules are generated, this ignores should be fixed in the code - @@ -48,3 +47,7 @@ parameters: message: '~^Call to an undefined method Atk4\\Ui\\Form\\Control::addAction\(\)\.$~' count: 1 path: src/UserAdmin.php + - + message: '~^Call to an undefined method Atk4\\Ui\\View::hide\(\)\.$~' + count: 1 + path: src/UserAdmin.php diff --git a/src/Acl.php b/src/Acl.php index 3189457f..cf89d598 100644 --- a/src/Acl.php +++ b/src/Acl.php @@ -6,6 +6,8 @@ use Atk4\Data\Exception; use Atk4\Data\Model; +use Atk4\Login\Model\AccessRule; +use Atk4\Login\Model\User; /** * Access Control Layer. Create one and pass it to your Auth controller. @@ -23,11 +25,11 @@ class Acl /** * Returns AccessRules model for logged in user and in model scope. * - * @return Model\AccessRule + * @return AccessRule */ public function getRules(Model $model) { - /** @var Model\User */ + /** @var User */ $user = $this->auth->user; if (!$user->isLoaded()) { diff --git a/src/Auth.php b/src/Auth.php index 7d537130..7eb93517 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -16,6 +16,7 @@ use Atk4\Data\Model; use Atk4\Data\Persistence; use Atk4\Login\Cache\Session; +use Atk4\Login\Form as LoginForm; use Atk4\Login\Layout\Narrow; use Atk4\Login\Model\User; use Atk4\Ui\App; @@ -79,7 +80,7 @@ class Auth * * @var array */ - public $formLoginSeed = [Form\Login::class]; + public $formLoginSeed = [LoginForm\Login::class]; /** @var array Seed that would create VirtualPage for adding Preference page content */ public $preferencePage = [VirtualPage::class]; @@ -272,7 +273,7 @@ public function addUserMenu(): void $menu = $this->getApp()->layout->menuRight->addMenu($this->user->getTitle()); if ($this->hasPreferences) { - $userPage = VirtualPage::assertInstanceOf($this->getApp()->add($this->preferencePage)); + $userPage = VirtualPage::addToWithCl($this->getApp(), $this->preferencePage); $this->setPreferencePage($userPage); $menu->addItem(['Preferences', 'icon' => 'user'], $userPage->getUrl()); @@ -311,15 +312,11 @@ public function displayLoginForm(array $seed = []): void $app->initLayout([Narrow::class]); $app->title .= ' - Login Required'; $app->layout->template->set('title', $app->title); - $app->add(array_merge( - $this->formLoginSeed, - [ - 'auth' => $this, - 'linkSuccess' => [$this->pageAfterLogin], - 'linkForgot' => false, - ], - $seed - )); + $app->add(Factory::factory($this->formLoginSeed, array_merge([ + 'auth' => $this, + 'linkSuccess' => [$this->pageAfterLogin], + 'linkForgot' => false, + ], $seed))); $app->run(); $app->callExit(); } diff --git a/src/Form/Control/Actions.php b/src/Form/Control/Actions.php index bc2af841..c0d086a5 100644 --- a/src/Form/Control/Actions.php +++ b/src/Form/Control/Actions.php @@ -13,7 +13,7 @@ public function setModel(Model $model, array $fields = null): void $this->renderRowFunction = function ($action) { return [ 'value' => $action->shortName, - 'title' => $action->caption ?: $action->shortName, + 'title' => $action->caption ?? $action->shortName, 'icon' => ($action->ui['icon'] ?? null), ]; }; diff --git a/src/Layout/Narrow.php b/src/Layout/Narrow.php index 2c98702a..6b2d34c1 100644 --- a/src/Layout/Narrow.php +++ b/src/Layout/Narrow.php @@ -11,6 +11,5 @@ */ class Narrow extends Layout { - /** @var string default template */ public $defaultTemplate = __DIR__ . '/../../template/layout/narrow.html'; } diff --git a/tests/AclTest.php b/tests/AclTest.php index 9db04650..0a957a7f 100644 --- a/tests/AclTest.php +++ b/tests/AclTest.php @@ -74,7 +74,7 @@ public function testAclBasic(): void // $this->invokeAndAssertAclException(function () use ($clientEntity) { // $clientEntity->save([$clientEntity->fieldName()->balance => 100]); // }); -// $this->assertSame($clientEntity->balance, 1234.56); +// static::assertSame($clientEntity->balance, 1234.56); // must also match parent classes $clientEntity = (new class($this->db) extends AclTestClient {})->load(1); diff --git a/tests/Feature/PasswordManagementTest.php b/tests/Feature/PasswordManagementTest.php index fccc394d..84a49852 100644 --- a/tests/Feature/PasswordManagementTest.php +++ b/tests/Feature/PasswordManagementTest.php @@ -39,9 +39,9 @@ public function testBasic(): void // replace callback so we can catch it $entity->getUserAction('sendEmail')->callback = function () { $args = func_get_args(); - $this->assertInstanceOf(User::class, $args[0]); - $this->assertStringContainsString('reset', $args[1]); - $this->assertIsString($args[2]); + static::assertInstanceOf(User::class, $args[0]); + static::assertStringContainsString('reset', $args[1]); + static::assertIsString($args[2]); }; static::assertIsString($pass = $entity->executeUserAction('resetPassword', 8)); diff --git a/tests/Feature/SendEmailActionTest.php b/tests/Feature/SendEmailActionTest.php index 6a431c24..816f0b54 100644 --- a/tests/Feature/SendEmailActionTest.php +++ b/tests/Feature/SendEmailActionTest.php @@ -21,9 +21,9 @@ public function testBasic(): void // replace callback so we can catch it $entity->getUserAction('sendEmail')->callback = function () { $args = func_get_args(); - $this->assertInstanceOf(User::class, $args[0]); - $this->assertSame('Email subject', $args[1]); - $this->assertSame('Email body', $args[2]); + static::assertInstanceOf(User::class, $args[0]); + static::assertSame('Email subject', $args[1]); + static::assertSame('Email body', $args[2]); }; $entity->executeUserAction('sendEmail', 'Email subject', 'Email body');