If (false)
github.com
github.com
// PHP has a bug that prevents you from creating a byte array via variants PHP_BUG_123_RESOLVED = false;
How is this "improved security"?
https://github.com/search?q=%22if%28false%29%22&type=Code&re...
- PHP 2,333,198 - JavaScript 491,084 - C 306,891 - C++ 198,900 - Java 169,748 - Python 106,708 - HTML 85,903 - Ruby 57,830 - Smalltalk 28,647 - C# 24,813
#ifFalse: is a message that is sent to a boolean and takes a closure as an argument.
[-][[This reminds me of Brainfuck,
where a similar hack can be
used to write comments with
arbitrary contents -- even
containing "]" if you ba-
lance them right.]Couldn't you get away with:
function IV( $size, $ssl = false ) {
if ( $ssl && function_exists( 'openssl_random_pseudo_bytes' ) ) {
return openssl_random_pseudo_bytes( $size, true );
}
return mcrypt_create_iv( $size, MCRYPT_DEV_URANDOM );
}
From the docs: http://it.php.net/manual/en/function.mcrypt-create-iv.php 5.3.0 MCRYPT_DEV_RANDOM and MCRYPT_DEV_URANDOM became available on Windows platforms.Refactoring, especially renaming files, WILL make it next to impossible to find "that one bit of code you know that does the trick", because even with a rgrep or git blame it will not turn up.
As soon as the commit history is >50 commits, it's also not feasible any more to scroll through hundreds of pages of diffs.
Side note: find a way to easily store "intentionally dead" code in a file, in a way that it does not show up in the code, but can be searched at least on the commandline - easy way to get rich. Devs all over the world will love you.
(I'd imagine replacing a block of code e.g. with /* REMEMBERME /, git detecting this block (and inserting a / REMEMBER-ID 12345 */ instead), and git supporting a command like "git show-dead file.c" which shows all the dead code, too.)
It won't, if you use proper commit messages. Once you start doing that, you'll soon discover it will make everything much more discoverable. Apart from that, death to dead code! Having worked on a project where about 10 to 20% of the code was effectively dead (either simply unused, commented out, #ifdef'ed away of if( 0 )'d away) I can assure you I never ever want that again, mainly since the dead parts still turn up in every search/grep/find reference.
The technique itself is useful for debugging, but not much else.
I'd very rarely use this sort of thing, but in this case I'd say it's OK.
It's also common to include TODO, FIXME, or BUG comments into code. Sure, you can put them into issue tracker, but having them directly in code gives more context.