Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 27 additions & 0 deletions src/Application/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,31 @@ public function __invoke(...$params): mixed

return $this->capsule->bind($params[0], $params[1]);
}

/**
* Send the application response
*
* @return void
*/
public function send(): void
{
$this->run();
}

/**
* Delegate method calls to the router
*
* @param string $method
* @param array $args
* @return mixed
* @throws ApplicationException
*/
public function __call(string $method, array $args): mixed
{
if (!method_exists($this->router, $method)) {
throw new ApplicationException("Method [$method] does not exist in Application.");
}

return call_user_func_array([$this->router, $method], $args);
}
}
10 changes: 5 additions & 5 deletions src/Security/Tokenize.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Tokenize
* @return ?array
* @throws SessionException
*/
public static function csrf(int $time = null): ?array
public static function csrf(?int $time = null): ?array
{
static::makeCsrfToken($time);

Expand Down Expand Up @@ -53,9 +53,9 @@ public static function makeCsrfToken(?int $time = null): bool
Session::getInstance()->add(
'__bow.csrf',
[
'token' => $token,
'expire_at' => time() + static::$expire_at,
'field' => '<input type="hidden" name="_token" value="' . $token . '"/>'
'token' => $token,
'expire_at' => time() + static::$expire_at,
'field' => '<input type="hidden" name="_token" value="' . $token . '"/>'
]
);

Expand Down Expand Up @@ -114,7 +114,7 @@ public static function verify(string $token, bool $strict = false): bool
* @return bool
* @throws SessionException
*/
public static function csrfExpired(int $time = null): bool
public static function csrfExpired(?int $time = null): bool
{
if (Session::getInstance()->has('__bow.csrf')) {
return false;
Expand Down
24 changes: 14 additions & 10 deletions src/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ private function __construct(array $config)
// We merge configuration
$this->config = array_merge(
[
'name' => 'Bow',
'path' => '/',
'domain' => null,
'secure' => false,
'httponly' => false,
'save_path' => null,
'name' => 'Bow',
'path' => '/',
'domain' => null,
'secure' => false,
'httponly' => false,
'save_path' => null,
],
$config
);
Expand Down Expand Up @@ -214,18 +214,22 @@ private function generateId(): string
}

/**
* Set session cookie params
* Set session cookie parameters
*
* @return void
*/
private function setCookieParameters(): void
{
$domain = $this->config['domain'] ?? null;
$secure = (bool)$this->config["secure"];
$httponly = (bool)$this->config["httponly"];

session_set_cookie_params(
(int)$this->config["lifetime"],
$this->config["path"],
$this->config['domain'],
$this->config["secure"],
$this->config["httponly"]
$domain,
$secure,
$httponly
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Service/DiskFilesystemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function getBaseDirectory(): string
*
* @return array|bool|string
*/
public function store(UploadedFile $file, $location = null, array $option = []): array|bool|string
public function store(UploadedFile $file, string|array|null $location = null, array $option = []): array|bool|string
{
if (is_array($location)) {
$option = $location;
Expand Down
32 changes: 16 additions & 16 deletions src/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function request(): Request
* @return DB
* @throws ConnectionException
*/
function db(string $name = null, callable $cb = null): DB
function db(?string $name = null, ?callable $cb = null): DB
{
if (func_num_args() == 0) {
return DB::getInstance();
Expand Down Expand Up @@ -195,7 +195,7 @@ function view(string $template, int|array $data = [], int $code = 200): View
* @throws ConnectionException
* @deprecated
*/
function table(string $name, string $connexion = null): QueryBuilder
function table(string $name, ?string $connexion = null): QueryBuilder
{
if (is_string($connexion)) {
db($connexion);
Expand All @@ -213,7 +213,7 @@ function table(string $name, string $connexion = null): QueryBuilder
* @param string|null $name
* @return int
*/
function get_last_insert_id(string $name = null): int
function get_last_insert_id(?string $name = null): int
{
return DB::lastInsertId($name);
}
Expand All @@ -228,7 +228,7 @@ function get_last_insert_id(string $name = null): int
* @return Bow\Database\QueryBuilder
* @throws ConnectionException
*/
function db_table(string $name, string $connexion = null): QueryBuilder
function db_table(string $name, ?string $connexion = null): QueryBuilder
{
if (is_string($connexion)) {
db($connexion);
Expand Down Expand Up @@ -362,7 +362,7 @@ function sep(): string
* @return ?array
* @throws SessionException
*/
function create_csrf_token(int $time = null): ?array
function create_csrf_token(?int $time = null): ?array
{
return Tokenize::csrf($time);
}
Expand Down Expand Up @@ -463,7 +463,7 @@ function verify_csrf(string $token, bool $strict = false): bool
* @return bool
* @throws SessionException
*/
function csrf_time_is_expired(string $time = null): bool
function csrf_time_is_expired(?string $time = null): bool
{
return Tokenize::csrfExpired($time);
}
Expand Down Expand Up @@ -580,7 +580,7 @@ function get_header(string $key): ?string
* @param string|null $path
* @return Redirect
*/
function redirect(string $path = null): Redirect
function redirect(?string $path = null): Redirect
{
$redirect = Redirect::getInstance();

Expand All @@ -600,7 +600,7 @@ function redirect(string $path = null): Redirect
* @param array $parameters
* @return string
*/
function url(string|array $url = null, array $parameters = []): string
function url(string|array|null $url = null, array $parameters = []): string
{
$current = trim(request()->url(), '/');

Expand Down Expand Up @@ -783,9 +783,9 @@ function flash(string $key, string $message): mixed
* @return MailAdapterInterface|bool
*/
function email(
string $view = null,
?string $view = null,
array $data = [],
callable $cb = null
?callable $cb = null
): MailAdapterInterface|bool {
if ($view === null) {
return Mail::getInstance();
Expand Down Expand Up @@ -820,7 +820,7 @@ function raw_email(string $to, string $subject, string $message, array $headers
* @return mixed
* @throws SessionException
*/
function session(array|string $value = null, mixed $default = null): mixed
function session(array|string|null $value = null, mixed $default = null): mixed
{
if ($value == null) {
return Session::getInstance();
Expand Down Expand Up @@ -849,7 +849,7 @@ function session(array|string $value = null, mixed $default = null): mixed
* @return string|array|object|null
*/
function cookie(
string $key = null,
?string $key = null,
mixed $data = null,
int $expiration = 3600
): string|array|object|null {
Expand Down Expand Up @@ -990,7 +990,7 @@ function app_file_system(string $disk): DiskFilesystemService
* @return mixed
* @throws ErrorException
*/
function cache(string $key = null, mixed $value = null, int $ttl = null): mixed
function cache(?string $key = null, mixed $value = null, ?int $ttl = null): mixed
{
$instance = Cache::getInstance();

Expand Down Expand Up @@ -1039,7 +1039,7 @@ function app_now(): Carbon
* @param mixed $hash_value
* @return bool|string
*/
function app_hash(string $data, string $hash_value = null): bool|string
function app_hash(string $data, ?string $hash_value = null): bool|string
{
if (!is_null($hash_value)) {
return Hash::check($data, $hash_value);
Expand All @@ -1058,7 +1058,7 @@ function app_hash(string $data, string $hash_value = null): bool|string
* @return bool|string
* @deprecated
*/
function bow_hash(string $data, string $hash_value = null): bool|string
function bow_hash(string $data, ?string $hash_value = null): bool|string
{
return app_hash($data, $hash_value);
}
Expand All @@ -1074,7 +1074,7 @@ function bow_hash(string $data, string $hash_value = null): bool|string
* @return string|Translator
*/
function app_trans(
string $key = null,
?string $key = null,
array $data = [],
bool $choose = false
): string|Translator {
Expand Down