Phing and pre-processing the source code


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
6 views
Interested in the question of preprocessing the source code of the project using phing.
What is meant
The source code for the view:

protected function _doImportant() {
#ifdef DEBUG
$this->log("doing important stuff now");
#endif
foreach ($this->import as $moreimportant) {
#ifdef DEBUG
$this->log("as I said, important, or $moreimportant");
#endif
}
#ifdef DEBUG
$this->log("finished doing so ach important thing");
#endif
}



After preprocessing, if available/enabled DEBUG Directive

protected function _doImportant() {
$this->log("doing important stuff now");
foreach ($this->import as $moreimportant) {
$this->log("as I said, important, or $moreimportant");
}
$this->log("finished doing so ach important thing");
}



If not:
protected function _doImportant() {
foreach ($this->import as $moreimportant) {

}
}

by | 6 views

2 Answers

0 like 0 dislike
Try to use Replace Regexp for this. The task allows you to implement the search/replace using regexps. Or go to the Ant, there is a class for preprocessing.
by
0 like 0 dislike
1) what is your question? Habr — not Google :)
2) is Not it easier instead of preprocessing to use something like:
\r
\r
const DEBUG = TRUE; protected function _doImportant() { if (self::DEBUG) { $this->log("doing important stuff now"); } foreach ($this->import as $moreimportant) { if (self::DEBUG) { $this->log("as I said, important, or $moreimportant"); } } if (self::DEBUG) { $this->log("finished doing so ach important thing"); } } 

\r
Const DEBUG is in the same class, because you are using $this->log().
\r
Although I have used Log::debug($message), which in case Log::DEBUG == 0, nothing prints. Try to save it — the evil, as any premature optimization.
by
110,608 questions
257,186 answers
0 comments
27,902 users