itsgoingd / clockwork

Clockwork - php dev tools in your browser - server-side component
https://underground.works/clockwork
MIT License
5.7k stars 320 forks source link

Fix deprecation notes on PHP 8.1 #536

Closed alies-dev closed 3 years ago

alies-dev commented 3 years ago

is fixes 2 deprecated notes:

NOTICE: PHP message: PHP Deprecated:  str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vendor/itsgoingd/clockwork/Clockwork/Helpers/StackFrame.php on line 24

NOTICE: PHP message: PHP Deprecated:  strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /var/www/vendor/itsgoingd/clockwork/Clockwork/Helpers/StackFrame.php on line 25
itsgoingd commented 3 years ago

Hey, I think it would be more neat to do these checks inline with ternaries, eg:

return $frame->shortPath ? preg_match('#^/storage/framework/views/[a-z0-9]+\.php$#', $frame->shortPath) : false;
alies-dev commented 3 years ago

@itsgoingd

Hey, I think it would be more neat to do these checks inline with ternaries, eg:

Thanks for the quick response! Honestly, I think early return is more readable and maintainable, but I'll apply your proposal just to merge this PR ASAP. One note: I think it's better to return null instead of false - $viewFrame string|null is better than string|false (nullable scalar vs mixed type):

return $frame->shortPath ? preg_match('#^/storage/framework/views/[a-z0-9]+\.php$#', $frame->shortPath) : null;
alies-dev commented 3 years ago

@itsgoingd

BTW, I was really surprised that the repo uses tabs for indent. Are e going to continue to use it? If so - I would recommend to add .editorconfig file:

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab

Is not - I can create another PR to automate coding style fixing (via phpcs or php-cs-fixer) to fallow PSR standards

itsgoingd commented 3 years ago

Thanks. The closure is a filter function that says whether a value should be returned, that's why false is more appropriate. I will tweak that myself tho.

Yes we are intentionally using tabs and not following all PSR recommendations. I'll accept an .editorconfig PR if you would like to send one.