Skip to content
2 changes: 1 addition & 1 deletion .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="2.1.55" installed="2.1.55" location="./tools/phpstan" copy="false"/>
<phar name="phpstan" version="2.3.0" installed="2.3.0" location="./tools/phpstan" copy="false"/>
</phive>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"stan": "@phpstan",
"stan-baseline": "tools/phpstan --generate-baseline",
"stan-setup": "phive install",
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.3.1\" && mv composer.backup composer.json",
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.7.0\" && mv composer.backup composer.json",
"rector-check": "vendor/bin/rector process --dry-run",
"rector-fix": "vendor/bin/rector process",
"test": "phpunit",
Expand Down
309 changes: 163 additions & 146 deletions docs/package-lock.json

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\If_\ArrayExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\If_\ObjectExplicitBoolCompareRector;
use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector;
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveMixedDocblockOverruledByNativeTypeRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessUnionReturnDocblockRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Set\ValueObject\SetList;
Expand Down Expand Up @@ -51,8 +54,11 @@
ReturnTypeFromStrictFluentReturnRector::class,
SplitDoubleAssignRector::class,
NewlineAfterStatementRector::class,
ExplicitBoolCompareRector::class,
TypedPropertyFromCreateMockAssignRector::class,
ArrayExplicitBoolCompareRector::class,
ObjectExplicitBoolCompareRector::class,
RemoveUselessUnionReturnDocblockRector::class,
RemoveMixedDocblockOverruledByNativeTypeRector::class,

// Parent SimpleBakeCommand::buildOptionParser() switched from public
// to protected in cakephp/bake 3.6.4. Narrowing this override would
Expand Down
8 changes: 2 additions & 6 deletions src/Controller/Component/AuthorizationComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ protected function performCheck(
string $method = 'can',
): ResultInterface|bool {
$request = $this->getController()->getRequest();
if ($action === null) {
$action = $this->getDefaultAction($request);
}
$action ??= $this->getDefaultAction($request);

$identity = $this->getIdentity($request);
if (!$identity instanceof IdentityInterface) {
Expand All @@ -152,9 +150,7 @@ protected function performCheck(
public function applyScope(mixed $resource, ?string $action = null, mixed ...$optionalArgs): mixed
{
$request = $this->getController()->getRequest();
if ($action === null) {
$action = $this->getDefaultAction($request);
}
$action ??= $this->getDefaultAction($request);
$identity = $this->getIdentity($request);
if (!$identity instanceof IdentityInterface) {
return $this->getService($request)->applyScope(null, $action, $resource);
Expand Down
8 changes: 3 additions & 5 deletions src/Middleware/AuthorizationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ public function __construct(
array $config = [],
?ContainerInterface $container = null,
) {
if ($this->_defaultConfig['identityDecorator'] === null) {
$this->_defaultConfig['identityDecorator'] = interface_exists(AuthenIdentityInterface::class)
? Identity::class
: IdentityDecorator::class;
}
$this->_defaultConfig['identityDecorator'] ??= interface_exists(AuthenIdentityInterface::class)
? Identity::class
: IdentityDecorator::class;

$this->subject = $subject;
$this->container = $container;
Expand Down
4 changes: 1 addition & 3 deletions src/Policy/OrmResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ protected function findPolicy(string $class, string $name, string $namespace): m
}

// Check the application/plugin.
if ($policyClass === null) {
$policyClass = App::className($namespace . '.' . $name, 'Policy', 'Policy');
}
$policyClass ??= App::className($namespace . '.' . $name, 'Policy', 'Policy');

if ($policyClass === null) {
throw new MissingPolicyException([$class]);
Expand Down
7 changes: 3 additions & 4 deletions tests/test_app/TestApp/Policy/ArticlePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function canAdd($user): bool
* @param \Authorization\IdentityInterface $user
* @return bool
*/
public function canEdit($user, Article $article)
public function canEdit($user, Article $article): bool
{
if ($user === null) {
return false;
Expand All @@ -56,7 +56,7 @@ public function canEdit($user, Article $article)
* @param \Authorization\IdentityInterface $user
* @return bool
*/
public function canModify($user, Article $article)
public function canModify($user, Article $article): bool
{
if (in_array($user['role'], ['admin', 'author'])) {
return true;
Expand All @@ -71,7 +71,7 @@ public function canModify($user, Article $article)
* @param \Authorization\IdentityInterface $user
* @return bool
*/
public function canDelete($user, Article $article)
public function canDelete($user, Article $article): bool
{
if ($user['role'] === 'admin') {
return true;
Expand All @@ -84,7 +84,6 @@ public function canDelete($user, Article $article)
* Scope method for index
*
* @param \Authorization\IdentityInterface $user
* @return bool
*/
public function scopeIndex($user, Article $article): Article
{
Expand Down
Loading