Add strict typing to all files that were missing it. (#60)

Shockingly, this didn't require any code changes. But PHP is more forgiving with "strict typing" than I'd expected. I may go back and clean up function declarations later, but that's not urgent.

Reviewed-on: https://gitea.subcultureofone.org/greg/tkr/pulls/60
Co-authored-by: Greg Sarjeant <greg@subcultureofone.org>
Co-committed-by: Greg Sarjeant <greg@subcultureofone.org>
This commit is contained in:
Greg Sarjeant 2025-08-06 00:14:50 +00:00 committed by greg
parent 1337ffa155
commit 6123757c37
40 changed files with 77 additions and 0 deletions

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
// This is the initialization code that needs to be run before anything else.
// - define paths
// - set up autoloader

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/*
* Initialize fundamental configuration
*/

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class AdminController extends Controller {
// GET handler
// render the admin page

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class AuthController extends Controller {
function showLogin(?string $error = null){
global $app;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class Controller {
// Renders the requested template inside templates/main/php
protected function render(string $childTemplateFile, array $vars = []) {

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
class CssController extends Controller {
public function index() {

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class EmojiController extends Controller {
// Shows the custom emoji management page
public function index(){

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class FeedController extends Controller {
private $ticks;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class HomeController extends Controller {
// GET handler
// renders the homepage view.

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class LogController extends Controller {
private string $storageDir;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class MoodController extends Controller {
public function index(){
global $app;

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
class TickController extends Controller{
public function index(int $id){

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class AtomGenerator extends FeedGenerator {
public function generate(): string {
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
// Abstract base class for feeds.
// Specific feeds (RSS, Atom, etc.) will inherit from this.
// This will wrap the basic generator functionality.

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class RssGenerator extends FeedGenerator {
public function generate(): string {
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class Log {
const LEVELS = [
'DEBUG' => 1,

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class Migrator{
public function __construct(private PDO $db) {}

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/**
* tkr Prerequisites Checker
*

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
// Very simple router class
class Router {
// Define the recognized routes.

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
class Session {
// These can all just be static functions

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class Util {
public static function getClientIp() {
return $_SERVER['HTTP_CLIENT_IP'] ??

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class ConfigModel {
// properties and default values
public string $siteTitle = 'My tkr';

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class CssModel {
public function __construct(private PDO $db) {}

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
// welp this model is overkill
class EmojiModel{
public function __construct(private PDO $db) {}

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class TickModel {
public function __construct(private PDO $db, private ConfigModel $config) {}

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class UserModel {
// properties
public string $username = '';

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class FlashView {
public function renderFlashSection(array $flashMessages): string {
ob_start();

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class MoodView {
private function render_emoji_groups(array $emojiGroups, string $currentMood): string {
$selected_emoji = $currentMood; //user->mood;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
class TicksView {
private $html;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
require_once dirname(dirname(dirname(__DIR__))) . "/config/bootstrap.php";
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class FeedControllerTest extends TestCase

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class HomeControllerTest extends TestCase

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class LogControllerTest extends TestCase

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class TickControllerTest extends TestCase

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class AtomGeneratorTest extends TestCase

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class FeedGeneratorTest extends TestCase

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class RssGeneratorTest extends TestCase

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class LogTest extends TestCase

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

View File

@ -1,5 +1,7 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
* tkr Setup Script
*