Skip to content

Commit

Permalink
Nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Dec 10, 2024
1 parent eb3f90d commit a9daa10
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions bin/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ protected function init()
/**
* execute
*
* @param \Closure|null $callback
* @param \Closure|null $callback
*
* @return int
*/
public function execute(\Closure $callback = null)
public function execute(?\Closure $callback = null)
{
try {
if ($this->getOption($this->helpOptions)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Attributes/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Author extends CastForSave
{
protected function getDefaultCaster(): callable
{
return function (mixed $value, ORM $orm, object $entity, UserService $userService = null) {
return function (mixed $value, ORM $orm, object $entity, ?UserService $userService = null) {
if (!$value && $userService) {
$mapper = $orm->mapper($entity::class);

Expand Down
2 changes: 1 addition & 1 deletion src/Attributes/Modifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Modifier extends CastForSave
{
protected function getDefaultCaster(): callable
{
return function (mixed $value, ORM $orm, object $entity, UserService $userService = null) {
return function (mixed $value, ORM $orm, object $entity, ?UserService $userService = null) {
if (!$userService) {
return $value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/LunaAuthMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected function getUsernames(array $credential): array|object
return Arr::only($credential, $loginNames);
}

protected function isSRPEnabled(array $credential, array &$srp = null): bool
protected function isSRPEnabled(array $credential, ?array &$srp = null): bool
{
if (!$this->srpService->isEnabled()) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Captcha/Recaptcha/WindwalkerRequestMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class WindwalkerRequestMethod implements RequestMethod
* @param HttpClient|null $http
* @param null $url
*/
public function __construct(HttpClient $http = null, $url = null)
public function __construct(?HttpClient $http = null, $url = null)
{
$this->http = $http ?: new HttpClient();
$this->url = $url ?: ReCaptcha::SITE_VERIFY_URL;
Expand Down
4 changes: 2 additions & 2 deletions src/Helper/PravatarHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PravatarHelper
*
* @return string
*/
public static function url(int $size = 300, int $id = null, string $u = null): string
public static function url(int $size = 300, ?int $id = null, ?string $u = null): string
{
$uri = new Uri(static::$host);

Expand Down Expand Up @@ -58,7 +58,7 @@ public static function url(int $size = 300, int $id = null, string $u = null): s
* @return string
* @throws Exception
*/
public static function unique(int $size = 300, string $u = null): string
public static function unique(int $size = 300, ?string $u = null): string
{
if ((string) $u === '') {
$u = uid();
Expand Down
7 changes: 4 additions & 3 deletions src/Menu/Tree/MenuNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Windwalker\Core\Router\RouteUri;
use Windwalker\DI\Attributes\Inject;
use Windwalker\DOM\DOMElement;
use Windwalker\DOM\HTMLElement;
use Windwalker\Uri\Uri;

/**
Expand All @@ -33,7 +34,7 @@ class MenuNode extends Node implements MenuNodeInterface

protected string $layout = 'link.link';

protected ?DOMElement $element = null;
protected ?HTMLElement $element = null;

protected ?bool $forceActive = null;

Expand Down Expand Up @@ -283,9 +284,9 @@ public function getHTMLAttributes(array $merge = []): array
);
}

public function getElement(): DOMElement
public function getElement(): HTMLElement
{
return $this->element ??= DOMElement::create('div');
return $this->element ??= HTMLElement::new('div');
}

public function attr(string $name, string $value): static
Expand Down
8 changes: 4 additions & 4 deletions src/PageBuilder/Renderer/Style/StyleContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function self(string $suffix = ''): StyleRules
*
* @since 1.5.2
*/
public function select(string $selector, callable $callback = null): StyleRules
public function select(string $selector, ?callable $callback = null): StyleRules
{
$k = trim($this->prefix . ' ' . $selector);

Expand All @@ -74,7 +74,7 @@ public function select(string $selector, callable $callback = null): StyleRules
*
* @since 1.5.2
*/
public function selectAppend(string $selector, callable $callback = null): StyleRules
public function selectAppend(string $selector, ?callable $callback = null): StyleRules
{
$k = trim($this->prefix . $selector);

Expand All @@ -91,7 +91,7 @@ public function selectAppend(string $selector, callable $callback = null): Style
*
* @since 1.5.2
*/
protected function doSelect(string $selector, callable $callback = null): StyleRules
protected function doSelect(string $selector, ?callable $callback = null): StyleRules
{
if (!isset($this->selectors[$selector])) {
$this->selectors[$selector] = new StyleRules();
Expand All @@ -116,7 +116,7 @@ protected function doSelect(string $selector, callable $callback = null): StyleR
*
* @since 1.5.2
*/
public function wrap(string $selector, callable $callback = null): StyleContainer
public function wrap(string $selector, ?callable $callback = null): StyleContainer
{
if (!isset($this->selectors[$selector])) {
$this->selectors[$selector] = new StyleRules();
Expand Down
4 changes: 2 additions & 2 deletions src/Services/TagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(protected ORM $orm)
{
}

public function createTagsIfNew(iterable $tagIds, callable $configure = null): array
public function createTagsIfNew(iterable $tagIds, ?callable $configure = null): array
{
$r = [];

Expand Down Expand Up @@ -68,7 +68,7 @@ public function flushTagMapsFromInput(
string|\BackedEnum $type,
mixed $targetId,
iterable $tagIds,
callable $configureNewTag = null
?callable $configureNewTag = null
): iterable {
$tagIds = $this->createTagsIfNew($tagIds, $configureNewTag);

Expand Down
10 changes: 5 additions & 5 deletions src/User/Exception/LoginFailException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class LoginFailException extends AuthenticateFailException
/**
* Class init.
*
* @param string $mainMessage
* @param string|array $messages
* @param int $code
* @param Throwable $previous
* @param string $mainMessage
* @param string|array $messages
* @param int $code
* @param Throwable|null $previous
*/
public function __construct(string $mainMessage, $messages = [], int $code = 0, Throwable $previous = null)
public function __construct(string $mainMessage, $messages = [], int $code = 0, ?Throwable $previous = null)
{
parent::__construct($messages, $code, $previous);

Expand Down
4 changes: 2 additions & 2 deletions src/User/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function mustLoad(mixed $conditions = null): UserEntityInterface
public function attemptToLogin(
array $credential,
array $options = [],
ResultSet &$resultSet = null
?ResultSet &$resultSet = null
): false|AuthResult {
$event = $this->emit(
BeforeLoginEvent::class,
Expand Down Expand Up @@ -206,7 +206,7 @@ public function can(string $action, mixed $user = null, ...$args): bool
return $this->getAuthService()->authorize($action, $user, ...$args);
}

public function authenticate(array $credential, ResultSet &$resultSet = null): false|AuthResult
public function authenticate(array $credential, ?ResultSet &$resultSet = null): false|AuthResult
{
return $this->getAuthService()->authenticate($credential, $resultSet);
}
Expand Down

0 comments on commit a9daa10

Please sign in to comment.