You've already forked pilot-sdk
php 8.4 support
This commit is contained in:
@@ -7,12 +7,12 @@ use Illuminate\Support\Str;
|
||||
abstract class Action extends Entity
|
||||
{
|
||||
public function action(
|
||||
$type = 'info',
|
||||
$title = null,
|
||||
$message = null,
|
||||
$button = null,
|
||||
$url = null,
|
||||
$files = [],
|
||||
string $type = 'info',
|
||||
?string $title = null,
|
||||
?string $message = null,
|
||||
?string $button = null,
|
||||
?string $url = null,
|
||||
array $files = [],
|
||||
) {
|
||||
return [
|
||||
'json' => [
|
||||
@@ -23,16 +23,16 @@ abstract class Action extends Entity
|
||||
}
|
||||
|
||||
public function file(
|
||||
$contents,
|
||||
$name = '',
|
||||
$type = ''
|
||||
string $contents,
|
||||
string $name = '',
|
||||
string $type = ''
|
||||
) {
|
||||
return [
|
||||
'file' => compact('contents', 'name', 'type'),
|
||||
];
|
||||
}
|
||||
|
||||
public function iframe($url, $expires = 240)
|
||||
public function iframe(string $url, int $expires = 240)
|
||||
{
|
||||
$key = 'pilot_action_' . Str::random(10);
|
||||
$token = Str::random(40);
|
||||
@@ -49,7 +49,7 @@ abstract class Action extends Entity
|
||||
];
|
||||
}
|
||||
|
||||
public function link($url, $expires = 5)
|
||||
public function link(string $url, int $expires = 5)
|
||||
{
|
||||
$key = 'pilot_action_' . Str::random(10);
|
||||
$token = Str::random(40);
|
||||
@@ -66,7 +66,7 @@ abstract class Action extends Entity
|
||||
];
|
||||
}
|
||||
|
||||
public function error($message)
|
||||
public function error(string $message)
|
||||
{
|
||||
return [
|
||||
'json' => [
|
||||
|
||||
@@ -6,7 +6,7 @@ abstract class Entity
|
||||
{
|
||||
protected $slug = null;
|
||||
|
||||
public function __construct($slug = null)
|
||||
public function __construct(?string $slug = null)
|
||||
{
|
||||
if (! is_null($slug)) {
|
||||
$this->slug = $slug;
|
||||
|
||||
@@ -62,12 +62,12 @@ abstract class Metric extends Widget
|
||||
];
|
||||
}
|
||||
|
||||
public function filter($label, $value, callable $callback)
|
||||
public function filter(string $label, $value, callable $callback)
|
||||
{
|
||||
return ['label' => $label, 'value' => $value, 'callback' => $callback];
|
||||
}
|
||||
|
||||
public function filters($filters)
|
||||
public function filters(array $filters)
|
||||
{
|
||||
return $this->resolveFilter($filters);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ abstract class Metric extends Widget
|
||||
];
|
||||
}
|
||||
|
||||
public function trend($values)
|
||||
public function trend(array $values)
|
||||
{
|
||||
return [
|
||||
'type' => 'trend',
|
||||
@@ -89,7 +89,7 @@ abstract class Metric extends Widget
|
||||
];
|
||||
}
|
||||
|
||||
public function partition($values)
|
||||
public function partition(array $values)
|
||||
{
|
||||
return [
|
||||
'type' => 'partition',
|
||||
@@ -106,7 +106,7 @@ abstract class Metric extends Widget
|
||||
];
|
||||
}
|
||||
|
||||
public function monitor($available)
|
||||
public function monitor(bool $available)
|
||||
{
|
||||
return [
|
||||
'type' => 'monitor',
|
||||
|
||||
@@ -18,14 +18,14 @@ class Pilot
|
||||
|
||||
}
|
||||
|
||||
public function authorize($token, $user_token)
|
||||
public function authorize(string $token, string $user_token)
|
||||
{
|
||||
if ($token !== $user_token) {
|
||||
throw new \Exception('Unauthorized Pilot request');
|
||||
}
|
||||
}
|
||||
|
||||
public function form($slug, callable $function)
|
||||
public function form(string $slug, callable $function)
|
||||
{
|
||||
$this->register('form', $slug, function () use ($function) {
|
||||
return [
|
||||
@@ -36,17 +36,17 @@ class Pilot
|
||||
});
|
||||
}
|
||||
|
||||
public function action($slug, callable $function)
|
||||
public function action(string $slug, callable $function)
|
||||
{
|
||||
$this->register('action', $slug, $function);
|
||||
}
|
||||
|
||||
public function metric($slug, callable $function)
|
||||
public function metric(string $slug, callable $function)
|
||||
{
|
||||
$this->register('metric', $slug, $function);
|
||||
}
|
||||
|
||||
protected function register($type, $slug, callable $function)
|
||||
protected function register(string $type, string $slug, callable $function)
|
||||
{
|
||||
$this->registry[$type][$slug] = $function;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class Pilot
|
||||
return Response::error("Unknown {$type} {$slug}");
|
||||
}
|
||||
|
||||
public function resolveDependencies($slug, $function, $data, $files)
|
||||
public function resolveDependencies(string $slug, $function, $data, $files)
|
||||
{
|
||||
$entries = isset($data['entries']) && is_array($data['entries']) ? $data['entries'] : [];
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace Bluesquare\Pilot;
|
||||
class Response
|
||||
{
|
||||
public static function action(
|
||||
$type = 'info',
|
||||
$title = null,
|
||||
$message = null,
|
||||
$button = null,
|
||||
$url = null,
|
||||
$files = [],
|
||||
string $type = 'info',
|
||||
?string $title = null,
|
||||
?string $message = null,
|
||||
?string $button = null,
|
||||
?string $url = null,
|
||||
array $files = [],
|
||||
) {
|
||||
return [
|
||||
'json' => [
|
||||
@@ -20,7 +20,7 @@ class Response
|
||||
];
|
||||
}
|
||||
|
||||
public static function error($message)
|
||||
public static function error(string $message)
|
||||
{
|
||||
return [
|
||||
'json' => [
|
||||
@@ -31,9 +31,9 @@ class Response
|
||||
}
|
||||
|
||||
public static function file(
|
||||
$contents,
|
||||
$name = '',
|
||||
$type = ''
|
||||
string $contents,
|
||||
string $name = '',
|
||||
string $type = ''
|
||||
) {
|
||||
return [
|
||||
'file' => compact('contents', 'name', 'type'),
|
||||
|
||||
Reference in New Issue
Block a user