php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60625 Emit notice for NOP statement
Submitted: 2011-12-29 19:22 UTC Modified: 2011-12-30 17:22 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: brad at njoe dot com Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
48 - 32 = ?
Subscribe to this entry?

 
 [2011-12-29 19:22 UTC] brad at njoe dot com
Description:
------------
As a matter of convenience for PHP programmers, would it be possible to somehow 
detect NOP-type statements (see example below) and create a new notice to notify 
the programmer of their presence?

When writing embedded code, NOP statements are often handy (or even required). 
However, in something as high-level as PHP, I can't see any situation where one 
would need such statements. Thus, whenever they DO occur it's most likely by 
accident (again see example below).

Test script:
---------------
<?php

"This string was meant to be sent as output, but I forgot to echo it!";
1+1;
$variable;

?>

Expected result:
----------------
Notice: Statement has no effect in (path) on line 3

Notice: Statement has no effect in (path) on line 4

Notice: Statement has no effect in (path) on line 5


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-30 17:22 UTC] brad at njoe dot com
Another example I recently thought of that could elicit the proposed notice 
would be:

----------------------------------
<?php
function returnHello() {
    return "Hello, world!";
}

/* Function return value discarded; this is essentially
   equivalent to line #3 in the above test script (just
   wrapped in a function return) */
returnHello();
?>
----------------------------------
 [2019-02-15 04:34 UTC] carusogabriel@php.net
Interesting one. I found a bigger list of NOP Statements.
 [2019-02-15 04:35 UTC] carusogabriel@php.net
The list: https://3v4l.org/iFoJs
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC