|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-03-01 09:13 UTC] requinix@php.net
-Summary: Preporocessor directrives
+Summary: Preprocessor directives
-Status: Open
+Status: Suspended
-Package: *Programming Data Structures
+Package: Scripting Engine problem
[2018-03-01 09:13 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 22:00:01 2025 UTC |
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.