Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use strict_types #5830

2 changes: 2 additions & 0 deletions app/Exceptions/AlreadySubscribedException.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not make many PRs with partial changes, so let's start by deciding where we should have that in production (pros and cons) and then apply on everything we have decided (and tested!) at once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any disadvantages or problems. on the contrary, the code is more robust because it does what it says.

Copy link
Member

@Alkarex Alkarex Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will probably add those lines (it is the right time now, that we have just added PHP 7.4 typed properties), but examples of disadvantages are increased risks of crash in production, and tiny impact on performance (due to additional checks at runtime)...


class FreshRSS_AlreadySubscribed_Exception extends Exception {

private string $feedName = '';
Expand Down
2 changes: 2 additions & 0 deletions app/Exceptions/BadUrlException.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

class FreshRSS_BadUrl_Exception extends FreshRSS_Feed_Exception {

public function __construct(string $url) {
Expand Down
1 change: 1 addition & 0 deletions app/Exceptions/ContextException.php
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

/**
* An exception raised when a context is invalid
*/
Expand Down
2 changes: 2 additions & 0 deletions app/Exceptions/FeedNotAddedException.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

class FreshRSS_FeedNotAdded_Exception extends Exception {

private string $url = '';
Expand Down
2 changes: 2 additions & 0 deletions app/Exceptions/ZipException.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

class FreshRSS_Zip_Exception extends Exception {

private int $zipErrorCode = 0;
Expand Down
2 changes: 2 additions & 0 deletions app/Mailers/UserMailer.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Manage the emails sent to the users.
*/
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Auth.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* This class handles all authentication process.
*/
Expand Down
4 changes: 2 additions & 2 deletions app/Models/LogDAO.php
Expand Up @@ -12,9 +12,9 @@ public static function logPath(?string $logFileName = null): string {
public static function lines(?string $logFileName = null): array {
$logs = [];
$handle = @fopen(self::logPath($logFileName), 'r');
if ($handle) {
if ($handle !== false) {
while (($line = fgets($handle)) !== false) {
if (preg_match('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
if (is_int(preg_match('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches))) {
ColonelMoutarde marked this conversation as resolved.
Show resolved Hide resolved
$myLog = new FreshRSS_Log();
$myLog->_date($matches[1]);
$myLog->_level($matches[2]);
Expand Down