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 <?php
declare(strict_types=1);
// This is the initialization code that needs to be run before anything else. // This is the initialization code that needs to be run before anything else.
// - define paths // - define paths
// - set up autoloader // - set up autoloader

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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