Skip to content

Commit

Permalink
refactor: Update for PHP v8.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
carlansell94 committed Dec 29, 2024
1 parent c36e42d commit 006ebbb
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/Lib/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ class Category
{
private ?int $category_id = null;
private ?string $category_slug = null;
/** @phpstan-ignore-next-line */
private ?string $category_name = null;
/** @phpstan-ignore-next-line */
private ?int $post_count = null;
/** @phpstan-ignore-next-line */
private ?string $latest_post = null;

public function setUri(int|string $uri): void
Expand Down
14 changes: 10 additions & 4 deletions src/Lib/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@
class Post
{
private ?int $post_id = null;
private ?string $post_slug;
/** @phpstan-ignore-next-line */
private ?string $post_date = null;
/** @phpstan-ignore-next-line */
private ?string $post_title = null;
/** @phpstan-ignore-next-line */
private ?string $post_excerpt = null;
/** @phpstan-ignore-next-line */
private ?string $post_content = null;
/** @phpstan-ignore-next-line */
private ?string $last_updated = null;
/** @phpstan-ignore-next-line */
private PostStatus|int|null $post_status_id = null;
private string $post_slug;
private string $categories;
private string $tags;


public function setId(int $id): void
{
Expand All @@ -29,9 +37,7 @@ public function setPostStatusId(int $id): void

public function setValue(string $key, int|string $value): void
{
if ($value !== null) {
$this->$key = $value;
}
$this->$key = $value;
}

public function getUri(): string
Expand Down
7 changes: 4 additions & 3 deletions src/Lib/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ class Tag
{
private ?int $tag_id = null;
private ?string $tag_slug = null;
/** @phpstan-ignore-next-line */
private ?string $tag_label = null;
/** @phpstan-ignore-next-line */
private ?int $post_count = null;
/** @phpstan-ignore-next-line */
private ?string $latest_post = null;

public function setUri(int|string $uri): void
Expand All @@ -21,9 +24,7 @@ public function setUri(int|string $uri): void

public function setValue(string $key, int|string $value): void
{
if ($value !== null) {
$this->$key = $value;
}
$this->$key = $value;
}

public function getUri(): int|string|false
Expand Down
2 changes: 1 addition & 1 deletion src/Model/CategoryList.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct(
) {
}

public function setLimits(int $limit, int $offset = null): void
public function setLimits(int $limit, ?int $offset = null): void
{
$this->limit = $limit;
$this->offset = $offset;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/PostList.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(
) {
}

public function setLimits(int $limit, int $offset = null): void
public function setLimits(int $limit, ?int $offset = null): void
{
$this->limit = $limit;
$this->offset = $offset;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/TagList.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function sortByCount(): void
$this->sort_by_count = true;
}

public function setLimits(int $limit, int $offset = null): void
public function setLimits(int $limit, ?int $offset = null): void
{
$this->limit = $limit;
$this->offset = $offset;
Expand Down
2 changes: 1 addition & 1 deletion src/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final public static function login(): void
self::updateTimestamp();
}

final public static function failedLogin(string $reason = null): void
final public static function failedLogin(?string $reason = null): void
{
if (isset($_SESSION['login_fails'])) {
$_SESSION['login_fails']++;
Expand Down
8 changes: 8 additions & 0 deletions src/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@

use carlansell94\Liteblog\Config\Config;
use carlansell94\Liteblog\Session\Session;
use carlansell94\Liteblog\Lib\Post;

class View
{
private ?int $page = null;
private ?int $max_page = null;
private ?string $page_title = null;
/** @phpstan-ignore-next-line */
private ?Post $post = null;
private mixed $post_list = null;
private mixed $category_list = null;
private mixed $tag_list = null;
private mixed $categories = null;
protected static ?string $theme_dir = null;
public mixed $elements = null;

public function __construct(
private ?string $template = null,
Expand Down

0 comments on commit 006ebbb

Please sign in to comment.