Skip to content

Commit

Permalink
fix stan
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Aug 27, 2022
1 parent a8f5aea commit 438b4b1
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 23 deletions.
1 change: 1 addition & 0 deletions demos/_includes/MigratorConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 4 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
-
Expand Down Expand Up @@ -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
6 changes: 4 additions & 2 deletions src/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()) {
Expand Down
19 changes: 8 additions & 11 deletions src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Control/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];
};
Expand Down
1 change: 0 additions & 1 deletion src/Layout/Narrow.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
*/
class Narrow extends Layout
{
/** @var string default template */
public $defaultTemplate = __DIR__ . '/../../template/layout/narrow.html';
}
2 changes: 1 addition & 1 deletion tests/AclTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/PasswordManagementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/SendEmailActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 438b4b1

Please sign in to comment.