Req #76036 [NEW]: Preporocessor directrives
| From: | obadja dot hauser at gmail dot com | Date: | Thu, 01 Mar 2018 08:44:20 +0000 |
| Subject: | Req #76036 [NEW]: Preporocessor directrives | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-214158@lists.php.net to get a copy of this message | ||
From: obadja dot hauser at gmail dot com
Operating system: ALL
PHP version: Irrelevant
Package: *Programming Data Structures
Bug Type: Feature/Change Request
Bug description:Preporocessor directrives
Description:
------------
In some cases can i need this feature.
I think, this was a possible way to made code to running with modern
features PHP >= 7 and on old Versions. Or to write fine granular code.
Or transparence and clearer code.
The preprocessor directives should recognized following:
- #<preprocessor type> <preprocessor identifier> <
- <preprocessor type>: #IF, #IFNOT followed by #ENDIF. Between ca #ELSE
or/and #ELSEIF
- <preprocessor identifier>: PHPVAR (PHP Version), OSVAR (OS Version),
OS (OS Name), HTTPSRV (Webserver Name) and CLI (if true if running via
cli command). It should possible to concatenate with AND.
- <comparer>: <,<=,>,>=,= (= if the default comparer an is not needed to
write it)
- <compare value>: will always interpreted as string or number for the
compare var
Is there this feature planned or on your todo list :)
Test script:
---------------
My idea was so, e.g. class function:
#IF PHPVER >= 8.0
public function getAndCatchMethod(string $methodname) : callable on
throws \MyException
#ELSE
public function getAndCatchMethod(string $methodname) : callable
#ENDIF
{
return [$this, $methodname];
}
Expected result:
----------------
Code dynamical builded on preprocessor directives.
#IF PHPVER >= 8.0
public function getMagic(string $value = '') : callable on throws
\MyException
{
# this new killer feature will catching the Exception automatically
to given Exception Class without to need try..catch, if method called
;)
return [$this, $methodname];
}
Class->getAndCatchMethod('test')
MyException::catch() {}
#ELSE
public function getAndCatchMethod(string $methodname) : callable
{
# regular exception catching
return [$this, $methodname];
}
try { Class->getAndCatchMethod('test') } catch (...) { }
Actual result:
--------------
Nothing. This will not working at this time.
--
Edit bug report at https://bugs.php.net/bug.php?id=76036&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76036&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76036&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76036&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76036&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76036&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76036&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76036&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76036&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76036&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76036&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76036&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76036&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76036&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76036&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76036&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76036&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76036&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76036&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76036&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76036&r=mysqlcfg