Added declare strict_types.

main
Robert 3 years ago
parent 58763ec0da
commit 72861afc30
  1. 2
      src/bootstrap/Exceptions_common_bool.php
  2. 2
      src/bootstrap/auto_loader.php
  3. 2
      src/bootstrap/common.php
  4. 2
      src/bootstrap/errors.php
  5. 2
      src/bootstrap/filter.php
  6. 2
      src/bootstrap/requires.php
  7. 12
      src/bootstrap/safer_io.php
  8. 2
      src/bootstrap/site_helper.php
  9. 26
      src/bootstrap/validator.php
  10. 2
      src/classes/api.php
  11. 2
      src/classes/app.php
  12. 2
      src/classes/arrays/common.php
  13. 2
      src/classes/arrays/countries.php
  14. 2
      src/classes/arrays/mimes.php
  15. 2
      src/classes/arrays/mocking/address.php
  16. 2
      src/classes/arrays/mocking/phone.php
  17. 2
      src/classes/arrays/mocking/rnd_names.php
  18. 2
      src/classes/arrays/shortn.php
  19. 2
      src/classes/arrays/zipcodes.php
  20. 7
      src/classes/assets.php
  21. 2
      src/classes/bb_code_parser.php
  22. 2
      src/classes/console_app.php
  23. 2
      src/classes/contracts/http_request_options.php
  24. 2
      src/classes/contracts/sessions_interface.php
  25. 2
      src/classes/database/dummy_data.php
  26. 2
      src/classes/database/help_load.php
  27. 2
      src/classes/database/help_save.php
  28. 2
      src/classes/database/paginate.php
  29. 2
      src/classes/database/run_sql.php
  30. 2
      src/classes/database/validation.php
  31. 2
      src/classes/enum/app_environment.php
  32. 2
      src/classes/enum/same_site.php
  33. 2
      src/classes/exceptions/DB_Exception.php
  34. 10
      src/classes/html.php
  35. 2
      src/classes/html_document.php
  36. 2
      src/classes/html_parser.php
  37. 2
      src/classes/json.php
  38. 2
      src/classes/loadall.php
  39. 2
      src/classes/memory_usage.php
  40. 2
      src/classes/page_not_found.php
  41. 2
      src/classes/request.php
  42. 2
      src/classes/router.php
  43. 2
      src/classes/safer_sql.php
  44. 2
      src/classes/security.php
  45. 2
      src/classes/services/cache/file.php
  46. 2
      src/classes/services/cache/redis_db.php
  47. 2
      src/classes/services/emailer.php
  48. 2
      src/classes/services/html_filter.php
  49. 2
      src/classes/services/http_requests/http_curl_request.php
  50. 2
      src/classes/services/liquid_templates.php
  51. 2
      src/classes/services/log.php
  52. 2
      src/classes/services/obsolete/crypto.php
  53. 2
      src/classes/services/obsolete/encryption.php
  54. 2
      src/classes/services/obsolete/http_socket_request.php
  55. 2
      src/classes/services/paragon_crypto/crypto.php
  56. 2
      src/classes/services/paragon_crypto/password_storage.php
  57. 2
      src/classes/services/paragon_crypto/sodium_storage.php
  58. 2
      src/classes/services/sessions.php
  59. 2
      src/classes/services/sessions/file_sessions.php
  60. 2
      src/classes/services/sessions/redis_sessions.php
  61. 2
      src/classes/services/simple_rest.php
  62. 2
      src/classes/services/twilio.php
  63. 2
      src/classes/session_management.php
  64. 2
      src/classes/tag_matches.php
  65. 2
      src/classes/time_zone_selection.php
  66. 2
      src/classes/time_zones.php
  67. 2
      src/classes/traits/csrf_token_functions.php
  68. 2
      src/classes/traits/session_hijacking_functions.php
  69. 2
      src/classes/url_encode.php
  70. 2
      src/classes/view.php
  71. 2
      src/templates/dev_error.php
  72. 2
      src/views/404.php
  73. 4
      src/views/default/broken.php
  74. 2
      src/views/errors.php

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
class Exceptions_common_bool extends \Exception {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @author http://php-fig.org/ <info@php-fig.org>
* @site https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class common {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
define('WORD_WRAP_CHRS', 80); // Letters before Line Wrap on Errors
$root = \tts\site_helper::get_root();
if (!defined('TTS_PROJECT_LOGS_DIR')) {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
if (!defined('HTMLPURIFIER_PREFIX')) {
define('HTMLPURIFIER_PREFIX', TTS_VENDOR . 'ezyang/htmlpurifier/library');
}

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class requires {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* Sanitize Input, Validate data and Escape output.
* 1) In web development to sanitize means that you remove unsafe
* characters from the input. Makes safer DB inserts/selects, etc...!
@ -386,7 +388,7 @@ final class safer_io {
$safer_data[$input_field_name] = $safer_data[$input_field_name][0];
}
}
$safer_html = self::get_safer_html($safer_data[$input_field_name], $a);
if ($safer_html !== false) {
$safer_html_data[$input_field_name] = $safer_html;
@ -396,6 +398,14 @@ final class safer_io {
if (isset($safer_html_data[$input_field_name])) {
$safer_html_data[$input_field_name] = self::t($safer_html_data[$input_field_name], $trim);
}
if ($field_type == FIELD_FILTER::integer_number) {
$safer_data[$input_field_name] = intval($safer_data[$input_field_name]);
}
if ($field_type == FIELD_FILTER::floating_point) {
$safer_data[$input_field_name] = floatval($safer_data[$input_field_name]);
}
}
$errors = (count($rules)) ? \tts\validator::validate($safer_data, $rules, $messages) : [];

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class site_helper {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @link https://www.phptutorial.net/php-tutorial/php-validation/
*/
@ -114,54 +116,54 @@ class validator {
return filter_var($data[$field], FILTER_VALIDATE_EMAIL);
}
private static function is_min(array $data, string $field, int $min): bool {
private static function is_min(array $data, string $field, string $min): bool {
if (!isset($data[$field])) {
return true;
}
return mb_strlen($data[$field]) >= $min;
return mb_strlen($data[$field]) >= intval($min);
}
private static function is_max(array $data, string $field, int $max): bool {
private static function is_max(array $data, string $field, string $max): bool {
if (!isset($data[$field])) {
return true;
}
return mb_strlen($data[$field]) <= $max;
return mb_strlen($data[$field]) <= intval($max);
}
private static function is_greater_than(array $data, string $field, int $min): bool {
private static function is_greater_than(array $data, string $field, string $min): bool {
if (!isset($data[$field])) {
return true;
}
return intval($data[$field]) > $min;
return intval($data[$field]) > intval($min);
}
private static function is_less_than(array $data, string $field, int $max): bool {
private static function is_less_than(array $data, string $field, string $max): bool {
if (!isset($data[$field])) {
return true;
}
return intval($data[$field]) < $max;
return intval($data[$field]) < intval($max);
}
private static function is_number_range(array $data, string $field, int $min, int $max): bool {
private static function is_number_range(array $data, string $field, string $min, string $max): bool {
if (!isset($data[$field])) {
return true;
}
$no = intval($data[$field]);
return $no >= $min && $no <= $max;
return $no >= intval($min) && $no <= intval($max);
}
private static function is_between(array $data, string $field, int $min, int $max): bool {
private static function is_between(array $data, string $field, string $min, string $max): bool {
if (!isset($data[$field])) {
return true;
}
$len = mb_strlen($data[$field]);
return $len >= $min && $len <= $max;
return $len >= intval($min) && $len <= intval($max);
}
private static function is_same(array $data, string $field, string $other): bool {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
class api {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
use Exception;

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace tts\arrays;
class common {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\arrays;
class countries {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\arrays;
class mimes {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\arrays\mocking;
class address {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\arrays\mocking;
class phone {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\arrays\mocking;
class rnd_names {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\arrays;
final class shortn {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\arrays;
class zipcodes {

@ -1,10 +1,16 @@
<?php
declare(strict_types=1);
namespace tts;
final class assets {
public static function get_ver(string $filename): string {
if (self::attempts_root_dir($filename)) {
return "";
}
$safe_file = \tts\security::filter_uri($filename);
if (! file_exists($safe_file)) {
return "?ver=false";
@ -15,7 +21,6 @@ final class assets {
/**
* Check for / or absolute path not belonging to /var/www or PRJ:ROOT
* @param string|null $path
* @param string $open_base_dir_path
* @return bool
*/
private static function attempts_root_dir(?string $path): bool {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @link https://github.com/genert/bbcode/blob/master/src/Parser/BBCodeParser.php
* The MIT License (MIT)

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class console_app {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\interfaces;
final class http_request_options {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\contacts;
interface sessions_interface {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\database;
final class dummy_data {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\database;
class help_load {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\database;
final class help_save {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* FROM site:
* @link https://code.tutsplus.com/tutorials/how-to-paginate-data-with-php--net-2928

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\database;
trait run_sql {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\database;
trait validation {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\enum;
enum app_environment: string {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\enum;
enum same_site: string {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\exceptions;
enum HANDLE_FAILURE: int {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class html {
@ -104,8 +106,12 @@ final class html {
foreach($records as $record) {
echo "\t<tr>{$nl}";
foreach($db_field_names as $field_name) {
$td = $record[$field_name] ?? "";
$cell = ($escape) ? \tts\safer_io::h($td) : $td;
$td = $record[$field_name] ?? "";
if (is_string($td)) {
$cell = ($escape) ? \tts\safer_io::h($td) : $td;
} else {
$cell = (string) $td;
}
echo "\t\t<td>{$cell}</td>{$nl}";
}
echo "\t</tr>{$nl}";

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
/**

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @link https://github.com/genert/bbcode/blob/master/src/Parser/HTMLParser.php
* The MIT License (MIT)

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class json {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class loadall {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class memory_usage {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
class page_not_found {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class request {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @ MIT License
* @copyright (c) 2018, Patrik Mokrý

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @todo This is just for PLAY for now!!!!
* Too many FALSE positives and too many FALSE Negatives!!!

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class security {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services\cache;
class file {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services\cache;
final class redis_db {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services;
class emailer {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services;
final class html_filter {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services\http_requests;
class http_curl_request {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services;
final class liquid_templates {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services;
final class log {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services;
class crypto {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services;
/*

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services\http_requests;
final class http_socket_request {

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/*
* @author Paragon Initiative Enterprises
* @copyright MIT

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services\paragon_crypto;
/*

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @author Robert Strutts, Original works by Paragon Initiative Enterprises
* @license MIT

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services;
class sessions {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services\sessions;
class file_sessions implements \tts\contracts\sessions_interface {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services\sessions;
class redis_sessions implements \tts\contracts\sessions_interface {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services;
class simple_rest {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts\services;
final class twilio {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class session_management {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class tag_matches {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @folked from https://gist.github.com/Xeoncross/1204255
* @site https://gist.github.com/vrdriver/659562a150ba955063ad849e44dac2cc

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class time_zones {

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace tts\traits;
trait csrf_token_functions {

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace tts\traits;
/**

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class url_encode {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace tts;
final class view {

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
if (defined("PROJECT_ASSETS_BASE_REF")) {
$base_ref = PROJECT_ASSETS_BASE_REF;
} else {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
$protocol = "HTTP/1.0";
if ( "HTTP/1.1" == $_SERVER["SERVER_PROTOCOL"] ) {
$protocol = "HTTP/1.1";

@ -1,4 +1,6 @@
<pre>
<?= $ex ?>
<?php var_dump(debug_backtrace()); ?>
<?php
declare(strict_types=1);
var_dump(debug_backtrace()); ?>
</pre>

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
define('PRODUCTION', 600);
define('MAINTENACE', 3600); // 1 hour = 3600 seconds
define('RETRY_AFTER', PRODUCTION);

Loading…
Cancel
Save