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
9 changes: 9 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<ruleset name="friendsofcake-crud-users">
<rule ref="CakePHP"/>

<file>src/</file>
<file>tests/</file>

<exclude-pattern>*/tests/test_files/*</exclude-pattern>
</ruleset>
31 changes: 31 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
parameters:
ignoreErrors:
-
message: '#^Access to an undefined property Cake\\Controller\\Controller\:\:\$Authentication\.$#'
identifier: property.notFound
count: 4
path: src/Action/LoginAction.php

-
message: '#^Access to an undefined property Cake\\Controller\\Controller\:\:\$Authentication\.$#'
identifier: property.notFound
count: 1
path: src/Action/LogoutAction.php

-
message: '#^Parameter \#1 \$type of method Cake\\ORM\\Table\<array\>\:\:find\(\) expects string, \$this\(CrudUsers\\Action\\ResetPasswordAction\)\|array\|string given\.$#'
identifier: argument.type
count: 1
path: src/Action/ResetPasswordAction.php

-
message: '#^Unable to resolve the template type TEntity in call to method Cake\\ORM\\Table\<array\>\:\:patchEntity\(\)$#'
identifier: argument.templateType
count: 1
path: src/Action/ResetPasswordAction.php

-
message: '#^Parameter \#1 \$type of method Cake\\ORM\\Table\<array\>\:\:find\(\) expects string, \$this\(CrudUsers\\Action\\VerifyAction\)\|array\|string given\.$#'
identifier: argument.type
count: 1
path: src/Action/VerifyAction.php
22 changes: 3 additions & 19 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
includes:
- phpstan-baseline.neon

parameters:
level: 8
paths:
Expand All @@ -7,22 +10,3 @@ parameters:
ignoreErrors:
-
identifier: missingType.iterableValue
-
message: "#^Access to an undefined property Cake\\\\Controller\\\\Controller\\:\\:\\$Authentication\\.$#"
count: 4
path: src/Action/LoginAction.php

-
message: "#^Access to an undefined property Cake\\\\Controller\\\\Controller\\:\\:\\$Authentication\\.$#"
count: 1
path: src/Action/LogoutAction.php

-
message: "#^Parameter \\#1 \\$type of method Cake\\\\ORM\\\\Table\\:\\:find\\(\\) expects string, \\$this\\(CrudUsers\\\\Action\\\\ResetPasswordAction\\)\\|array\\|string given\\.$#"
count: 1
path: src/Action/ResetPasswordAction.php

-
message: "#^Parameter \\#1 \\$type of method Cake\\\\ORM\\\\Table\\:\\:find\\(\\) expects string, \\$this\\(CrudUsers\\\\Action\\\\VerifyAction\\)\\|array\\|string given\\.$#"
count: 1
path: src/Action/VerifyAction.php
2 changes: 1 addition & 1 deletion src/Action/ForgotPasswordAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function _get(): void
'success' => true,
'entity' => $this->_entity(
$this->_request()->getQueryParams(),
['validate' => false]
['validate' => false],
),
]);

Expand Down
4 changes: 2 additions & 2 deletions src/Action/LoginAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LoginAction extends BaseAction
*/
protected function _get(): ?Response
{
/** @psalm-suppress UndefinedMagicPropertyFetch */
/** @psalm-suppress UndefinedMagicPropertyFetch,UndefinedMagicMethod */
$result = $this->_controller()->Authentication->getResult();
$subject = $this->_subject([
'success' => true,
Expand Down Expand Up @@ -88,7 +88,7 @@ protected function _success(Subject $subject): ?Response
$this->setFlash('success', $subject);
}

/** @psalm-suppress UndefinedInterfaceMethod */
/** @psalm-suppress UndefinedMagicMethod,UndefinedMethod */
$redirectUrl = $this->_controller()->Authentication->getLoginRedirect()
?? $this->getConfig('redirectUrl');

Expand Down
2 changes: 1 addition & 1 deletion src/Action/LogoutAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function _get(): ?Response

return $this->_redirect(
$subject,
$subject->redirectUrl
$subject->redirectUrl,
);
}
}
2 changes: 1 addition & 1 deletion src/Action/RegisterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected function _get(): void
'success' => true,
'entity' => $this->_entity(
$this->_request()->getQueryParams() ?: [],
$this->saveOptions()
$this->saveOptions(),
),
]);

Expand Down
2 changes: 1 addition & 1 deletion src/Action/ResetPasswordAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected function _save(Subject $subject): EntityInterface|false
$entity = $this->_model()->patchEntity(
$subject->entity,
$this->_request()->getData(),
$this->saveOptions()
$this->saveOptions(),
);
$subject->set(['entity' => $entity]);

Expand Down
2 changes: 1 addition & 1 deletion src/Action/VerifyAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function _save(EntityInterface $entity): EntityInterface|false
$entity = $this->_model()->patchEntity(
$entity,
['verified' => true],
$this->saveOptions()
$this->saveOptions(),
);
$subject = $this->_subject(['entity' => $entity]);

Expand Down
23 changes: 23 additions & 0 deletions src/CrudUsersPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);

namespace Marketing;

use Cake\Core\BasePlugin;

class CrudUsersPlugin extends BasePlugin
{
protected ?string $name = 'CrudUsers';

protected bool $bootstrapEnabled = true;

protected bool $consoleEnabled = true;

protected bool $middlewareEnabled = true;

protected bool $servicesEnabled = true;

protected bool $routesEnabled = true;

protected bool $eventsEnabled = true;
}