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

[5.3] Code cleanup #44586

Open
wants to merge 1 commit into
base: 5.3-dev
Choose a base branch
from
Open

Conversation

janschoenherr
Copy link
Contributor

@janschoenherr janschoenherr commented Dec 5, 2024

Summary of Changes

  • Remove unnecessary type casts
  • Simplify boolean expressions
  • Unwrap sprintf() calls with single argument
  • Replace switch statements with single branch with if statements
  • Use str_*() functions
  • Replace calls like dirname(__FILE__) with __DIR__

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@@ -52,13 +52,13 @@ public function thumb($template, $clientId = 0)
$template->xmldata = TemplatesHelper::parseXMLTemplateFile($client->id === 0 ? JPATH_ROOT : JPATH_ROOT . '/administrator', $template->name);
}

if ((isset($template->xmldata->inheritable) && (bool) $template->xmldata->inheritable) || isset($template->xmldata->parent)) {
if (isset($template->xmldata->parent) && (string) $template->xmldata->parent !== '' && file_exists(JPATH_ROOT . '/media/templates/' . $client->name . '/' . (string) $template->xmldata->parent . '/images/template_thumbnail.png')) {
if ((isset($template->xmldata->inheritable) && $template->xmldata->inheritable) || isset($template->xmldata->parent)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it not better to cast the value of inheritable to a boolean. This ensures that any non-boolean value is explicitly converted to true or false otherwise the value is evaluated in its original type ???

Copy link
Contributor Author

@janschoenherr janschoenherr Dec 5, 2024

Choose a reason for hiding this comment

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

It's implicitly coerced to boolean, that's why the type cast is redundant. See https://www.php.net/manual/en/language.types.type-juggling.php

@janschoenherr janschoenherr force-pushed the patch-18 branch 3 times, most recently from c9d4371 to b3b5b05 Compare December 5, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants