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:
parent
1337ffa155
commit
6123757c37
@ -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
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize fundamental configuration
|
* Initialize fundamental configuration
|
||||||
*/
|
*/
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
@ -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 = []) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
class CssController extends Controller {
|
class CssController extends Controller {
|
||||||
public function index() {
|
public function index() {
|
||||||
|
@ -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(){
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
class FeedController extends Controller {
|
class FeedController extends Controller {
|
||||||
private $ticks;
|
private $ticks;
|
||||||
|
|
||||||
|
@ -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.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
class LogController extends Controller {
|
class LogController extends Controller {
|
||||||
private string $storageDir;
|
private string $storageDir;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -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){
|
||||||
|
@ -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";
|
||||||
|
@ -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.
|
||||||
|
@ -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";
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
class Log {
|
class Log {
|
||||||
const LEVELS = [
|
const LEVELS = [
|
||||||
'DEBUG' => 1,
|
'DEBUG' => 1,
|
||||||
|
@ -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) {}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tkr Prerequisites Checker
|
* tkr Prerequisites Checker
|
||||||
*
|
*
|
||||||
|
@ -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.
|
||||||
|
@ -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
|
||||||
|
@ -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'] ??
|
||||||
|
@ -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';
|
||||||
|
@ -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) {}
|
||||||
|
|
||||||
|
@ -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) {}
|
||||||
|
@ -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) {}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
class UserModel {
|
class UserModel {
|
||||||
// properties
|
// properties
|
||||||
public string $username = '';
|
public string $username = '';
|
||||||
|
@ -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();
|
||||||
|
@ -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;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
class TicksView {
|
class TicksView {
|
||||||
private $html;
|
private $html;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tkr Setup Script
|
* tkr Setup Script
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user