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

example of converting ==|!= to ===|!== #413

Open
wants to merge 34 commits into
base: master
Choose a base branch
from

Conversation

bbannon
Copy link
Contributor

@bbannon bbannon commented Sep 16, 2023

why? because
! empty ( $x ) && $x == 'Y'
can be shortened to
$x === 'Y'
without losing anything.
as $x in
$x === 'Y'
can not be empty, null, undefined, not set, 'zebra' or anything else except 'Y'

Also, some examples of making changed lines comply with developers-guide as far as
line length and spaces around ()s and such.

@craigk5n
Copy link
Owner

I don't think this actually correct as far as avoiding undefined vars.

I tried this script:

<?php
if ( $B === 1 ) {
  echo "B is 1\n";
}
?>

And got this result with PHP 8.2:
PHP Warning: Undefined variable $B in /var/www/html/webcalendar/test.php on line 3

@bbannon
Copy link
Contributor Author

bbannon commented Sep 19, 2023 via email

@craigk5n
Copy link
Owner

What do you get for if ( $b !== 1 ) or if ( $b === '1' )

On Tue, Sep 19, 2023 at 9:06 AM Craig Knudsen @.> wrote: I don't think this actually correct as far as avoiding undefined vars. I tried this script: And got this result with PHP 8.2: PHP Warning: Undefined variable $B in /var/www/html/webcalendar/test.php on line 3 — Reply to this email directly, view it on GitHub <#413 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJ7GLV7ZEX6YRHOXST7Q5DX3GYIPANCNFSM6AAAAAA42XNW7Q . You are receiving this because you authored the thread.Message ID: @.>

I got undefined variable for both of these cases.

@bbannon
Copy link
Contributor Author

bbannon commented Sep 22, 2023 via email

@bbannon
Copy link
Contributor Author

bbannon commented Sep 26, 2023

Well, even if some form of '! empty()' is still required, everything I've read says it's better to use === | !== anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants