Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge development branch into main #849

Merged
merged 22 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Code quality improvements
  • Loading branch information
evansims committed Sep 16, 2022
commit 8ac26391f5c5552382228d925d03d470c57397c7
8 changes: 3 additions & 5 deletions src/Actions/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Auth0\WordPress\Actions;

use Auth0\SDK\Exception\ConfigurationException;
use Auth0\SDK\Exception\StateException;
use Throwable;
use WP_Error;
Expand Down Expand Up @@ -48,7 +47,8 @@ public function onInit(): void
}

/** @var object{user: array<string, mixed[]|int|string>, idToken?: string, accessToken?: string, accessTokenScope?: array<string, string>, accessTokenExpiration?: int, accessTokenExpired: bool, refreshToken?: string}|null $session */
$session = $this->getSdk()->getCredentials();
$session = $this->getSdk()
->getCredentials();
$expired = $session?->accessTokenExpired ?? true;
$wordpress = wp_get_current_user();

Expand Down Expand Up @@ -130,8 +130,6 @@ public function onInit(): void
* Fires when 'auth_cookie_malformed' is triggered by WordPress.
*
* @link https://developer.wordpress.org/reference/hooks/auth_cookie_malformed/
* @param string $cookie
* @param string|null $scheme
*/
public function onAuthCookieMalformed(string $cookie, ?string $scheme = null): void
{
Expand Down Expand Up @@ -351,7 +349,7 @@ private function resolveIdentity(
$role = $this->getPlugin()
->getOption('accounts', 'default_role', get_option('default_role'));

if (is_string($role) && ! in_array($role, $user->roles)) {
if (is_string($role) && ! in_array($role, $user->roles, true)) {
$user->set_role($role);
wp_update_user($user);
}
Expand Down
49 changes: 10 additions & 39 deletions src/Actions/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,7 @@ public function onSetup(): void
$sectionType = (isset($section['type']) && is_string($section['type'])) ? $section['type'] : 'array';
$sectionCallback = [
$this,
'onUpdate' . str_replace(' ', '', ucwords(
str_replace(['auth0_', '_'], ' ', $sectionId)
)),
'onUpdate' . str_replace(' ', '', ucwords(str_replace(['auth0_', '_'], ' ', $sectionId))),
];

/**
Expand Down Expand Up @@ -403,9 +401,7 @@ public function onSetup(): void
$optionValues = get_option($sectionId, false);
}

/**
* @var array<mixed>|null $optionValues
*/
/** @var array<mixed>|null $optionValues */

$options = (isset($section['options']) && is_array($section['options'])) ? $section['options'] : [];

Expand All @@ -426,50 +422,34 @@ public function onSetup(): void
if (is_array($optionDescription)) {
$callback = [$this, $optionDescription[0]];

/**
* @var callable $callback
*/
/** @var callable $callback */

$optionDescription = call_user_func_array(
$callback,
array_slice($optionDescription, 1)
);
$optionDescription = call_user_func_array($callback, array_slice($optionDescription, 1));
}

if (is_array($optionPlaceholder)) {
$callback = [$this, $optionPlaceholder[0]];

/**
* @var callable $callback
*/
/** @var callable $callback */

$optionPlaceholder = call_user_func_array(
$callback,
array_slice($optionPlaceholder, 1)
);
$optionPlaceholder = call_user_func_array($callback, array_slice($optionPlaceholder, 1));
}

if (is_string($optionDisabled)) {
$callback = [$this, $optionDisabled];
/**
* @var callable $callback
*/
/** @var callable $callback */
$optionDisabled = (call_user_func($callback) === true);
}

if (is_string($optionEnabled)) {
$callback = [$this, $optionEnabled];
/**
* @var callable $callback
*/
/** @var callable $callback */
$optionDisabled = (call_user_func($callback) === false);
}

if (is_string($optionSelections)) {
$callback = [$this, $optionSelections];
/**
* @var callable $callback
*/
/** @var callable $callback */
$optionSelections = call_user_func($callback) ?? [];
}

Expand Down Expand Up @@ -809,14 +789,7 @@ public function renderAdvancedConfiguration(): void
}

/**
* @param string $element
* @param string $name
* @param string|int|bool|null $value
* @param string $type
* @param string $description
* @param string $placeholder
* @param null|array<string|int|bool> $select
* @param null|bool $disabled
*/
private function renderOption(
string $element,
Expand Down Expand Up @@ -916,9 +889,7 @@ private function renderPageBegin(string $pageId, string $formAction = 'options.p
{
$pages = $this->pages;

/**
* @var array<array<string>> $pages
*/
/** @var array<array<string>> $pages */

$title = $pages[$pageId]['title'];

Expand Down
4 changes: 1 addition & 3 deletions src/Cache/WpObjectCacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public function set(mixed $value): static
return $this;
}

/**
* @param DateTimeInterface|null $dateTime
*/

public function expiresAt(?DateTimeInterface $dateTime): static
{
if ($dateTime instanceof DateTimeInterface) {
Expand Down
3 changes: 0 additions & 3 deletions src/Cache/WpObjectCachePool.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Auth0\WordPress\Cache;

use Auth0\SDK\Configuration\SdkConfiguration;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use WP_Object_Cache;
Expand All @@ -21,7 +20,6 @@ final class WpObjectCachePool implements CacheItemPoolInterface
public const CONST_CACHE_GROUP = 'auth0';

/**
*
* @var array<array{item: CacheItemInterface, expiration: int|null}>
*/
private array $deferred = [];
Expand All @@ -42,7 +40,6 @@ public function getItem(string $key): CacheItemInterface
}

/**
*
* @param string[] $keys
*
* @return CacheItemInterface[]
Expand Down