Req #60625 [Com]: Emit notice for NOP statement

From: Date: Fri, 15 Feb 2019 04:35:06 +0000
Subject: Req #60625 [Com]: Emit notice for NOP statement
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219588@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60625&edit=1

 ID:                 60625
 Comment by:         carusogabriel@php.net
 Reported by:        brad at njoe dot com
 Summary:            Emit notice for NOP statement
 Status:             Open
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 Operating System:   N/A
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

The list: https://3v4l.org/iFoJs


Previous Comments:
------------------------------------------------------------------------
[2019-02-15 04:34:48] carusogabriel@php.net

Interesting one. I found a bigger list of NOP Statements.

------------------------------------------------------------------------
[2011-12-30 17:22:59] 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();
?>
----------------------------------

------------------------------------------------------------------------
[2011-12-29 19:22:33] 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



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=60625&edit=1


Thread (4 messages)

« previous php.bugs (#219588) next »