Skip to content

Commit

Permalink
Typed class constants (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
spaze authored Feb 16, 2024
2 parents 42ab88f + 3b0c979 commit 991115b
Show file tree
Hide file tree
Showing 51 changed files with 169 additions and 169 deletions.
2 changes: 1 addition & 1 deletion site/app/Admin/Presenters/PulsePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class PulsePresenter extends BasePresenter
{

private const NEW_DISCLOSURES = 3;
private const int NEW_DISCLOSURES = 3;


public function __construct(
Expand Down
8 changes: 4 additions & 4 deletions site/app/Application/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
class Bootstrap
{

private const MODE_DEVELOPMENT = 'development';
private const SITE_DIR = __DIR__ . '/../..';
private const DEBUG = '--debug';
private const COLORS = '--colors';
private const string MODE_DEVELOPMENT = 'development';
private const string SITE_DIR = __DIR__ . '/../..';
private const string DEBUG = '--debug';
private const string COLORS = '--colors';


public static function boot(): Container
Expand Down
2 changes: 1 addition & 1 deletion site/app/Application/Locale/LocaleLinkGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class LocaleLinkGenerator
{

private const DEFAULT_PARAMS = '*';
private const string DEFAULT_PARAMS = '*';


/**
Expand Down
16 changes: 8 additions & 8 deletions site/app/Application/Routing/RouterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
class RouterFactory
{

private const MODULE_ADMIN = 'Admin';
private const MODULE_API = 'Api';
private const MODULE_HEARTBLEED = 'Webleed';
private const MODULE_PULSE = 'Pulse';
private const MODULE_UPC = 'UpcKeys';
private const MODULE_WWW = 'Www';
private const string MODULE_ADMIN = 'Admin';
private const string MODULE_API = 'Api';
private const string MODULE_HEARTBLEED = 'Webleed';
private const string MODULE_PULSE = 'Pulse';
private const string MODULE_UPC = 'UpcKeys';
private const string MODULE_WWW = 'Www';

/**
* Module names mapped to hostnames.
*/
private const HOSTS = [
private const array HOSTS = [
self::MODULE_ADMIN => 'admin',
self::MODULE_API => 'api',
self::MODULE_HEARTBLEED => 'heartbleed',
Expand All @@ -32,7 +32,7 @@ class RouterFactory
self::MODULE_WWW => 'www',
];

private const ROOT_ONLY = '';
private const string ROOT_ONLY = '';

/** @var array<string, array<string, array<string, string>>> */
private array $translatedPresenters = [];
Expand Down
4 changes: 2 additions & 2 deletions site/app/Application/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
readonly class Theme
{

private const DARK = 'dark';
private const string DARK = 'dark';

private const LIGHT = 'bright';
private const string LIGHT = 'bright';


public function __construct(
Expand Down
4 changes: 2 additions & 2 deletions site/app/CompanyInfo/CompanyRegisterRegisterUz.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
readonly class CompanyRegisterRegisterUz implements CompanyRegister
{

private const DAY_ONE = '1993-01-01';
private const string DAY_ONE = '1993-01-01';

private const COUNTRY_CODE = 'sk';
private const string COUNTRY_CODE = 'sk';


public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion site/app/DateTime/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DateTime
/**
* Same as DATE_RFC3339_EXTENDED except it uses microseconds (`.u`) instead of milliseconds (`.v`).
*/
public const DATE_RFC3339_MICROSECONDS = 'Y-m-d\TH:i:s.uP';
public const string DATE_RFC3339_MICROSECONDS = 'Y-m-d\TH:i:s.uP';


public function getDaysFromString(string $interval): int
Expand Down
22 changes: 11 additions & 11 deletions site/app/DateTime/DateTimeFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
readonly class DateTimeFormatter
{

private const DATE_DAY = 'day';
private const DATE_MONTH = 'month';
private const string DATE_DAY = 'day';
private const string DATE_MONTH = 'month';

private const NO_INTERVAL = 1;
private const INTERVAL = 2;
private const INTERVAL_BOUNDARY = 3;
private const INTERVAL_BOUNDARIES = 4;
private const int NO_INTERVAL = 1;
private const int INTERVAL = 2;
private const int INTERVAL_BOUNDARY = 3;
private const int INTERVAL_BOUNDARIES = 4;

private const INTERVAL_FORMAT_START = 1;
private const INTERVAL_FORMAT_SEPARATOR = 2;
private const INTERVAL_FORMAT_END = 3;
private const int INTERVAL_FORMAT_START = 1;
private const int INTERVAL_FORMAT_SEPARATOR = 2;
private const int INTERVAL_FORMAT_END = 3;

private const LOCAL_DATE_FORMAT = [
private const array LOCAL_DATE_FORMAT = [
'en_US' => [
self::DATE_DAY => [
self::NO_INTERVAL => 'MMMM d, y',
Expand Down Expand Up @@ -92,7 +92,7 @@
],
];

private const COMPARISON_FORMAT = [
private const array COMPARISON_FORMAT = [
self::DATE_DAY => [
self::NO_INTERVAL => 'Ymd',
self::INTERVAL => 'Ym',
Expand Down
2 changes: 1 addition & 1 deletion site/app/EasterEgg/CrLfUrlInjections.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
readonly class CrLfUrlInjections
{

private const COOKIE_NAME = 'crlfinjection';
private const string COOKIE_NAME = 'crlfinjection';


public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion site/app/EasterEgg/FourOhFourButFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
readonly class FourOhFourButFound
{

private const TEMPLATES = [
private const array TEMPLATES = [
'/etc/passwd' => __DIR__ . '/templates/etcPasswd.html',
];

Expand Down
6 changes: 3 additions & 3 deletions site/app/EasterEgg/WinterIsComing.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
class WinterIsComing
{

private const EMAILS = [
private const array EMAILS = [
'[email protected]',
'[email protected]',
'[email protected]',
];

private const HOSTS = [
private const array HOSTS = [
'burpcollaborator.net',
'mailrez.com',
'mailto.plus',
'ourtimesupport.com',
'ssemarketing.net',
];

private const STREETS = [
private const array STREETS = [
'34 Watts road',
];

Expand Down
2 changes: 1 addition & 1 deletion site/app/Feed/Exports.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
readonly class Exports
{

private const ITEMS = 5;
private const int ITEMS = 5;

private Cache $cache;

Expand Down
8 changes: 4 additions & 4 deletions site/app/Form/TrainingDateFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
readonly class TrainingDateFormFactory
{

private const STANDARD = 'Standardní';
private const CUSTOM = 'Na zakázku';
private const REPLACED = 'Nahrazené';
private const DISCONTINUED = 'Ukončené';
private const string STANDARD = 'Standardní';
private const string CUSTOM = 'Na zakázku';
private const string REPLACED = 'Nahrazené';
private const string DISCONTINUED = 'Ukončené';


public function __construct(
Expand Down
4 changes: 2 additions & 2 deletions site/app/Formatter/TexyPhraseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
readonly class TexyPhraseHandler
{

private const TRAINING_ACTION = 'Www:Trainings:training';
private const COMPANY_TRAINING_ACTION = 'Www:CompanyTrainings:training';
private const string TRAINING_ACTION = 'Www:Trainings:training';
private const string COMPANY_TRAINING_ACTION = 'Www:CompanyTrainings:training';


public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion site/app/Makefile/Makefile.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class Makefile
{

private const PHONY_TARGET = '.PHONY';
private const string PHONY_TARGET = '.PHONY';

/** @var array<string, list<int>> target => lines */
private array $targetDefinitions = [];
Expand Down
4 changes: 2 additions & 2 deletions site/app/Media/SupportedImageFileFormats.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
class SupportedImageFileFormats
{

private const SUPPORTED_MAIN_IMAGES = [
private const array SUPPORTED_MAIN_IMAGES = [
'image/gif' => 'gif',
'image/png' => 'png',
'image/jpeg' => 'jpg',
];

private const SUPPORTED_ALTERNATIVE_IMAGES = [
private const array SUPPORTED_ALTERNATIVE_IMAGES = [
'image/webp' => 'webp',
];

Expand Down
4 changes: 2 additions & 2 deletions site/app/Media/VideoThumbnails.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
readonly class VideoThumbnails
{

private const VIDEO_THUMBNAIL_WIDTH = 320;
private const VIDEO_THUMBNAIL_HEIGHT = 180;
private const int VIDEO_THUMBNAIL_WIDTH = 320;
private const int VIDEO_THUMBNAIL_HEIGHT = 180;


public function __construct(
Expand Down
16 changes: 8 additions & 8 deletions site/app/Pulse/Passwords/PasswordsSorting.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
class PasswordsSorting
{

private const COMPANY_A_Z = 'a-z';
private const COMPANY_Z_A = 'z-a';
private const RATING_A_F = 'rating-a-f';
private const RATING_F_A = 'rating-f-a';
private const NEWEST_DISCLOSURES_FIRST = 'newest-disclosures-first';
private const NEWEST_DISCLOSURES_LAST = 'newest-disclosures-last';
private const NEWLY_ADDED_FIRST = 'newly-added-first';
private const NEWLY_ADDED_LAST = 'newly-added-last';
private const string COMPANY_A_Z = 'a-z';
private const string COMPANY_Z_A = 'z-a';
private const string RATING_A_F = 'rating-a-f';
private const string RATING_F_A = 'rating-f-a';
private const string NEWEST_DISCLOSURES_FIRST = 'newest-disclosures-first';
private const string NEWEST_DISCLOSURES_LAST = 'newest-disclosures-last';
private const string NEWLY_ADDED_FIRST = 'newly-added-first';
private const string NEWLY_ADDED_LAST = 'newly-added-last';

/** @var array<string, string> */
private array $sorting = [
Expand Down
12 changes: 6 additions & 6 deletions site/app/Pulse/Passwords/Rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
class Rating
{

private const SLOW_HASHES = [
private const array SLOW_HASHES = [
'argon2',
'bcrypt',
'pbkdf2',
'scrypt',
];

private const INSECURE = [
private const array INSECURE = [
'plaintext',
'encrypted',
];

private const VISIBLE_DISCLOSURES = [
private const array VISIBLE_DISCLOSURES = [
'docs',
'faq',
'signup-page',
];

private const INVISIBLE_DISCLOSURES = [
private const array INVISIBLE_DISCLOSURES = [
'blog',
'site-independent',
'facebook-independent',
Expand All @@ -42,7 +42,7 @@ class Rating
'comment',
];

private const RATING = [
private const array RATING = [
RatingGrade::A->name => 'Site uses a slow hashing function, this is disclosed "on-site", in the docs, FAQ, etc.',
RatingGrade::B->name => 'A slow hashing function is used but such info is "invisible", hidden in a blog post or a talk, or on social media.',
RatingGrade::C->name => 'Passwords hashed with an unsuitable function but at least they are salted and stretched with multiple iterations.',
Expand All @@ -51,7 +51,7 @@ class Rating
RatingGrade::F->name => 'Passwords stored in plaintext, in their original, readable form, or passwords encrypted instead of hashed.',
];

private const RECOMMENDATIONS = [
private const array RECOMMENDATIONS = [
RatingGrade::A->name => null,
RatingGrade::B->name => 'Publish storage and hashing info details "visibly":[link:Pulse:PasswordsStorages:Rating#on-site] (e.g. in the docs or FAQ), then let me know.',
RatingGrade::C->name => 'Start using "&quot;slow&quot; hashes":[link:Pulse:PasswordsStorages:Rating#slow-hashes], don\'t forget to "re-hash existing passwords":[blog:upgrading-existing-password-hashes], publish hashing info "visibly":[link:Pulse:PasswordsStorages:Rating#on-site], then let me know.',
Expand Down
2 changes: 1 addition & 1 deletion site/app/Pulse/Sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
readonly class Sites
{

public const ALL = 'all';
public const string ALL = 'all';


public function __construct(
Expand Down
4 changes: 2 additions & 2 deletions site/app/Talks/Slides/TalkSlides.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
class TalkSlides
{

private const SLIDE_MAX_WIDTH = 800;
private const SLIDE_MAX_HEIGHT = 450;
private const int SLIDE_MAX_WIDTH = 800;
private const int SLIDE_MAX_HEIGHT = 450;

/** @var list<string> */
private array $deleteFiles = [];
Expand Down
4 changes: 2 additions & 2 deletions site/app/Test/TestCaseRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
class TestCaseRunner
{

private const INCLUDE_SKIPPED_ENV_VAR_NAME = 'TEST_CASE_RUNNER_INCLUDE_SKIPPED';
private const INCLUDE_SKIPPED_ENV_VAR_VALUE = '1';
private const string INCLUDE_SKIPPED_ENV_VAR_NAME = 'TEST_CASE_RUNNER_INCLUDE_SKIPPED';
private const string INCLUDE_SKIPPED_ENV_VAR_VALUE = '1';


/**
Expand Down
2 changes: 1 addition & 1 deletion site/app/Tls/CertificateMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class CertificateMonitor implements CliArgsProvider
{

private const NO_IPV6 = '--no-ipv6';
private const string NO_IPV6 = '--no-ipv6';

private bool $hasErrors = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TrainingApplicationFormSpam
/**
* Must be lowercase string, we need `ctype_lower()` to return true in case the field is missing.
*/
private const FIELD_MISSING_VALUE = 'missing';
private const string FIELD_MISSING_VALUE = 'missing';


public function check(stdClass $values): void
Expand Down
2 changes: 1 addition & 1 deletion site/app/Training/Dates/TrainingDateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
readonly class TrainingDateFactory
{

private const LAST_FREE_SEATS_THRESHOLD_DAYS = 7;
private const int LAST_FREE_SEATS_THRESHOLD_DAYS = 7;


public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion site/app/Training/Dates/TrainingDates.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class TrainingDates
{

private const DATA_RETENTION = 30;
private const int DATA_RETENTION = 30;

/** @var list<TrainingDate>|null */
private ?array $pastWithPersonalData = null;
Expand Down
2 changes: 1 addition & 1 deletion site/app/Training/Files/TrainingFilesStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TrainingFilesStorage
/**
* Files directory, does not end with a slash.
*/
private const FILES_DIR = __DIR__ . '/../../../files/trainings';
private const string FILES_DIR = __DIR__ . '/../../../files/trainings';


/**
Expand Down
Loading

0 comments on commit 991115b

Please sign in to comment.