Upgrade to 3.8.0
This commit is contained in:
@@ -16,15 +16,11 @@ abstract class Auth
|
||||
/**
|
||||
* Raw authentication data after the first space
|
||||
* in the `Authorization` header
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
protected string $data;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct(string $data)
|
||||
{
|
||||
@@ -33,8 +29,6 @@ abstract class Auth
|
||||
|
||||
/**
|
||||
* Converts the object to a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
@@ -44,8 +38,6 @@ abstract class Auth
|
||||
/**
|
||||
* Returns the raw authentication data after the
|
||||
* first space in the `Authorization` header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function data(): string
|
||||
{
|
||||
@@ -54,8 +46,6 @@ abstract class Auth
|
||||
|
||||
/**
|
||||
* Returns the name of the auth type (lowercase)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function type(): string;
|
||||
}
|
||||
|
@@ -16,24 +16,10 @@ use Kirby\Toolkit\Str;
|
||||
*/
|
||||
class BasicAuth extends Auth
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $credentials;
|
||||
protected string $credentials;
|
||||
protected string|null $password;
|
||||
protected string|null $username;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $password;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $username;
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
*/
|
||||
public function __construct(string $data)
|
||||
{
|
||||
parent::__construct($data);
|
||||
@@ -45,8 +31,6 @@ class BasicAuth extends Auth
|
||||
|
||||
/**
|
||||
* Returns the entire unencoded credentials string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function credentials(): string
|
||||
{
|
||||
@@ -55,18 +39,14 @@ class BasicAuth extends Auth
|
||||
|
||||
/**
|
||||
* Returns the password
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function password(): ?string
|
||||
public function password(): string|null
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the authentication type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function type(): string
|
||||
{
|
||||
@@ -75,10 +55,8 @@ class BasicAuth extends Auth
|
||||
|
||||
/**
|
||||
* Returns the username
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function username(): ?string
|
||||
public function username(): string|null
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
@@ -17,8 +17,6 @@ class BearerAuth extends Auth
|
||||
{
|
||||
/**
|
||||
* Returns the authentication token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function token(): string
|
||||
{
|
||||
@@ -27,8 +25,6 @@ class BearerAuth extends Auth
|
||||
|
||||
/**
|
||||
* Returns the auth type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function type(): string
|
||||
{
|
||||
|
@@ -4,6 +4,7 @@ namespace Kirby\Http\Request\Auth;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Http\Request\Auth;
|
||||
use Kirby\Session\Session;
|
||||
|
||||
/**
|
||||
* Authentication data using Kirby's session
|
||||
@@ -18,18 +19,14 @@ class SessionAuth extends Auth
|
||||
{
|
||||
/**
|
||||
* Tries to return the session object
|
||||
*
|
||||
* @return \Kirby\Session\Session
|
||||
*/
|
||||
public function session()
|
||||
public function session(): Session
|
||||
{
|
||||
return App::instance()->sessionHandler()->getManually($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the session token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function token(): string
|
||||
{
|
||||
@@ -38,8 +35,6 @@ class SessionAuth extends Auth
|
||||
|
||||
/**
|
||||
* Returns the authentication type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function type(): string
|
||||
{
|
||||
|
@@ -20,17 +20,13 @@ class Body
|
||||
|
||||
/**
|
||||
* The raw body content
|
||||
*
|
||||
* @var string|array
|
||||
*/
|
||||
protected $contents;
|
||||
protected string|array|null $contents;
|
||||
|
||||
/**
|
||||
* The parsed content as array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data;
|
||||
protected array|null $data = null;
|
||||
|
||||
/**
|
||||
* Creates a new request body object.
|
||||
@@ -38,10 +34,8 @@ class Body
|
||||
* If null is being passed, the class will
|
||||
* fetch the body either from the $_POST global
|
||||
* or from php://input.
|
||||
*
|
||||
* @param array|string|null $contents
|
||||
*/
|
||||
public function __construct($contents = null)
|
||||
public function __construct(array|string|null $contents = null)
|
||||
{
|
||||
$this->contents = $contents;
|
||||
}
|
||||
@@ -49,10 +43,8 @@ class Body
|
||||
/**
|
||||
* Fetches the raw contents for the body
|
||||
* or uses the passed contents.
|
||||
*
|
||||
* @return string|array
|
||||
*/
|
||||
public function contents()
|
||||
public function contents(): string|array
|
||||
{
|
||||
if ($this->contents === null) {
|
||||
if (empty($_POST) === false) {
|
||||
@@ -71,8 +63,6 @@ class Body
|
||||
* the body with the json decoder first and
|
||||
* then run parse_str to get some results
|
||||
* if the json decoder failed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function data(): array
|
||||
{
|
||||
@@ -109,8 +99,6 @@ class Body
|
||||
/**
|
||||
* Converts the data array back
|
||||
* to a http query string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
@@ -119,8 +107,6 @@ class Body
|
||||
|
||||
/**
|
||||
* Magic string converter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
|
@@ -20,8 +20,6 @@ trait Data
|
||||
{
|
||||
/**
|
||||
* Improved `var_dump` output
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function __debugInfo(): array
|
||||
{
|
||||
@@ -33,8 +31,6 @@ trait Data
|
||||
* implemented by each class using this Trait
|
||||
* and has to return an associative array
|
||||
* for the get method
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function data(): array;
|
||||
|
||||
@@ -43,12 +39,8 @@ trait Data
|
||||
* Trait. You can use it to fetch a single value
|
||||
* of the data array by key or multiple values by
|
||||
* passing an array of keys.
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param mixed|null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
public function get(string|array $key, $default = null)
|
||||
{
|
||||
if (is_array($key) === true) {
|
||||
$result = [];
|
||||
@@ -64,8 +56,6 @@ trait Data
|
||||
/**
|
||||
* Returns the data array.
|
||||
* This is basically an alias for Data::data()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
@@ -74,8 +64,6 @@ trait Data
|
||||
|
||||
/**
|
||||
* Converts the data array to json
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toJson(): string
|
||||
{
|
||||
|
@@ -21,19 +21,15 @@ class Files
|
||||
|
||||
/**
|
||||
* Sanitized array of all received files
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $files;
|
||||
protected array $files;
|
||||
|
||||
/**
|
||||
* Creates a new Files object
|
||||
* Pass your own array to mock
|
||||
* uploads.
|
||||
*
|
||||
* @param array|null $files
|
||||
*/
|
||||
public function __construct($files = null)
|
||||
public function __construct(array|null $files = null)
|
||||
{
|
||||
if ($files === null) {
|
||||
$files = $_FILES;
|
||||
@@ -63,8 +59,6 @@ class Files
|
||||
* array. This is only needed to make
|
||||
* the Data trait work for the Files::get($key)
|
||||
* method.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function data(): array
|
||||
{
|
||||
|
@@ -19,10 +19,8 @@ class Query
|
||||
|
||||
/**
|
||||
* The Query data array
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
protected $data;
|
||||
protected array|null $data;
|
||||
|
||||
/**
|
||||
* Creates a new Query object.
|
||||
@@ -30,10 +28,8 @@ class Query
|
||||
* or a parsable query string. If
|
||||
* null is passed, the current Query
|
||||
* will be taken from $_GET
|
||||
*
|
||||
* @param array|string|null $data
|
||||
*/
|
||||
public function __construct($data = null)
|
||||
public function __construct(array|string|null $data = null)
|
||||
{
|
||||
if ($data === null) {
|
||||
$this->data = $_GET;
|
||||
@@ -47,8 +43,6 @@ class Query
|
||||
|
||||
/**
|
||||
* Returns the Query data as array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function data(): array
|
||||
{
|
||||
@@ -57,8 +51,6 @@ class Query
|
||||
|
||||
/**
|
||||
* Returns `true` if the request doesn't contain query variables
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
@@ -67,8 +59,6 @@ class Query
|
||||
|
||||
/**
|
||||
* Returns `true` if the request contains query variables
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotEmpty(): bool
|
||||
{
|
||||
@@ -78,8 +68,6 @@ class Query
|
||||
/**
|
||||
* Converts the query data array
|
||||
* back to a query string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
@@ -88,8 +76,6 @@ class Query
|
||||
|
||||
/**
|
||||
* Magic string converter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
|
Reference in New Issue
Block a user