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

docs: fix phpdoc types #6959

Merged
merged 9 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion system/API/ResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ trait ResponseTrait
/**
* How to format the response data.
* Either 'json' or 'xml'. If blank will be
* determine through content negotiation.
* determined through content negotiation.
*
* @var string
*/
Expand Down
11 changes: 6 additions & 5 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function app_timezone(): string
* $foo = cache('bar');
*
* @return CacheInterface|mixed
* @phpstan-return ($key is null ? CacheInterface : mixed)
*/
function cache(?string $key = null)
{
Expand Down Expand Up @@ -196,7 +197,7 @@ function command(string $command)
/**
* More simple way of getting config instances from Factories
*
* @return mixed
* @return object|null
*/
function config(string $name, bool $getShared = true)
{
Expand Down Expand Up @@ -376,7 +377,7 @@ function dd(...$vars)
*
* @param string|null $default
*
* @return mixed
* @return bool|string|null
*/
function env(string $key, $default = null)
{
Expand Down Expand Up @@ -952,7 +953,7 @@ function session(?string $val = null)
*
* @param mixed ...$params
*
* @return mixed
* @return object
*/
function service(string $name, ...$params)
{
Expand All @@ -966,7 +967,7 @@ function service(string $name, ...$params)
*
* @param mixed ...$params
*
* @return mixed
* @return object|null
*/
function single_service(string $name, ...$params)
{
Expand Down Expand Up @@ -1076,7 +1077,7 @@ function stringify_attributes($attributes, bool $js = false): string
* If no parameter is passed, it will return the timer instance,
* otherwise will start or stop the timer intelligently.
*
* @return mixed|Timer
* @return Timer
*/
function timer(?string $name = null)
{
Expand Down
2 changes: 1 addition & 1 deletion system/Config/Factories.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* large performance boost and helps keep code clean of lengthy
* instantiation checks.
*
* @method static BaseConfig config(...$arguments)
* @method static BaseConfig|null config(...$arguments)
*/
class Factories
{
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Database
* Parses the connection binds and returns an instance of the driver
* ready to go.
*
* @return mixed
* @return BaseConnection
*
* @throws InvalidArgumentException
*/
Expand Down
4 changes: 2 additions & 2 deletions system/Debug/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Timer
* Multiple calls can be made to this method so that several
* execution points can be measured.
*
* @param string $name The name of this timer.
* @param float $time Allows user to provide time.
* @param string $name The name of this timer.
* @param float|null $time Allows user to provide time.
*
* @return Timer
*/
Expand Down
4 changes: 2 additions & 2 deletions system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class Email
protected static $func_overload;

/**
* @param array|null $config
* @param array|\Config\Email|null $config
*/
public function __construct($config = null)
{
Expand All @@ -405,7 +405,7 @@ public function __construct($config = null)
/**
* Initialize preferences
*
* @param array|\Config\Email $config
* @param array|\Config\Email|null $config
*
* @return Email
*/
Expand Down
9 changes: 5 additions & 4 deletions system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Config\Services;
use InvalidArgumentException;
use Locale;
use stdClass;

/**
* Class IncomingRequest
Expand Down Expand Up @@ -478,7 +479,7 @@ public function getDefaultLocale(): string
* @param int|null $filter Filter constant
* @param mixed $flags
*
* @return mixed
* @return array|bool|float|int|stdClass|string|null
*/
public function getVar($index = null, $filter = null, $flags = null)
{
Expand Down Expand Up @@ -516,7 +517,7 @@ public function getVar($index = null, $filter = null, $flags = null)
*
* @see http://php.net/manual/en/function.json-decode.php
*
* @return mixed
* @return array|bool|float|int|stdClass|null
*/
public function getJSON(bool $assoc = false, int $depth = 512, int $options = 0)
{
Expand All @@ -531,7 +532,7 @@ public function getJSON(bool $assoc = false, int $depth = 512, int $options = 0)
* @param int|null $filter Filter Constant
* @param array|int|null $flags Option
*
* @return mixed
* @return array|bool|float|int|stdClass|string|null
*/
public function getJsonVar(string $index, bool $assoc = false, ?int $filter = null, $flags = null)
{
Expand Down Expand Up @@ -565,7 +566,7 @@ public function getJsonVar(string $index, bool $assoc = false, ?int $filter = nu
* A convenience method that grabs the raw input stream(send method in PUT, PATCH, DELETE) and decodes
* the String into an array.
*
* @return mixed
* @return array
*/
public function getRawInput()
{
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getMethod(bool $upper = false): string
/**
* Sets the request method. Used when spoofing the request.
*
* @return Request
* @return $this
*
* @deprecated Use withMethod() instead for immutability
*
Expand Down
10 changes: 5 additions & 5 deletions system/HTTP/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ class URI
/**
* Builds a representation of the string from the component parts.
*
* @param string $scheme
* @param string $authority
* @param string $path
* @param string $query
* @param string $fragment
* @param string|null $scheme URI scheme. E.g., http, ftp
* @param string $authority
* @param string $path
* @param string $query
* @param string $fragment
*/
public static function createURIString(?string $scheme = null, ?string $authority = null, ?string $path = null, ?string $query = null, ?string $fragment = null): string
{
Expand Down
2 changes: 2 additions & 0 deletions system/Helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function _get_uri(string $relativePath = '', ?App $config = null): URI
* Returns a site URL as defined by the App config.
*
* @param array|string $relativePath URI string or array of URI segments
* @param string|null $scheme URI scheme. E.g., http, ftp
* @param App|null $config Alternate configuration to use
*/
function site_url($relativePath = '', ?string $scheme = null, ?App $config = null): string
Expand All @@ -96,6 +97,7 @@ function site_url($relativePath = '', ?string $scheme = null, ?App $config = nul
* Base URLs are trimmed site URLs without the index page.
*
* @param array|string $relativePath URI string or array of URI segments
* @param string|null $scheme URI scheme. E.g., http, ftp
*/
function base_url($relativePath = '', ?string $scheme = null): string
{
Expand Down
6 changes: 3 additions & 3 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,9 @@ public function builder(?string $table = null)
* data here. This allows it to be used with any of the other
* builder methods and still get validated data, like replace.
*
* @param mixed $key Field name, or an array of field/value pairs
* @param mixed $value Field value, if $key is a single field
* @param bool|null $escape Whether to escape values
* @param array|object|string $key Field name, or an array of field/value pairs
* @param bool|float|int|object|string|null $value Field value, if $key is a single field
* @param bool|null $escape Whether to escape values
*
* @return $this
*/
Expand Down
9 changes: 9 additions & 0 deletions tests/system/CommonSingleServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function testSingleServiceWithNoParamsSupplied(string $service): void
$service1 = single_service($service);
$service2 = single_service($service);

assert($service1 !== null);
assert($service1 !== null);
samsonasik marked this conversation as resolved.
Show resolved Hide resolved

$this->assertInstanceOf(get_class($service1), $service2);
$this->assertNotSame($service1, $service2);
}
Expand Down Expand Up @@ -64,6 +67,9 @@ public function testSingleServiceWithAtLeastOneParamSupplied(string $service): v
$service1 = single_service($service, ...$params);
$service2 = single_service($service, ...$params);

assert($service1 !== null);
assert($service1 !== null);
samsonasik marked this conversation as resolved.
Show resolved Hide resolved

$this->assertInstanceOf(get_class($service1), $service2);
$this->assertNotSame($service1, $service2);

Expand All @@ -77,6 +83,9 @@ public function testSingleServiceWithAllParamsSupplied(): void
$cache1 = single_service('cache', null, true);
$cache2 = single_service('cache', null, true);

assert($cache1 !== null);
assert($cache2 !== null);

// Assert that even passing true as last param this will
// not create a shared instance.
$this->assertInstanceOf(get_class($cache1), $cache2);
Expand Down