# classes/phing/tasks/system/IfTask.php

## \ElseIfTask
jump to top

"Inner" class for IfTask.

This class has same basic structure as the IfTask, although of course it doesn't support <else> tags.

Extends from
  \ConditionBase
author
  Andreas Aderhold
copyright
  © 2001,2002 THYRELL. All rights reserved
package
  phing.tasks.system
version
  $Revision: 557 $

### Properties

`$thenTasks= 'null'`
Default value `null` Details

Type

### Methods

`addThen( $t ) :`
Parameters

Name | Type | Description
--- | --- | ---
$t |  |

`evaluate( ) : boolean`
Returns

Type | Description
--- | ---
boolean |

`main( ) :`

## \IfTask
jump to top

Perform some tasks based on whether a given condition holds true or not.

This task is heavily based on the Condition framework that can be found in Ant 1.4 and later, therefore it cannot be used in conjunction with versions of Ant prior to 1.4.

This task doesn't have any attributes, the condition to test is specified by a nested element - see the documentation of your `<condition>` task (see the online documentation for example) for a complete list of nested elements.

Just like the `<condition>` task, only a single condition can be specified - you combine them using `<and>` or `<or>` conditions.

In addition to the condition, you can specify three different child elements, `<elseif>`, `<then>` and `<else>`. All three subelements are optional. Both `<then>` and `<else>` must not be used more than once inside the if task. Both are containers for Ant tasks, just like Ant's `<parallel>` and `<sequential>` tasks - in fact they are implemented using the same class as Ant's `<sequential>` task.

The `<elseif>` behaves exactly like an `<if>` except that it cannot contain the `<else>` element inside of it. You may specify as may of these as you like, and the order they are specified is the order they are evaluated in. If the condition on the `<if>` is false, then the first `<elseif>` who's conditional evaluates to true will be executed. The `<else>` will be executed only if the `<if>` and all `<elseif>` conditions are false.

Use the following task to define the `<if>` task before you use it the first time:

      <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />

### Crude Example

`<if> <then> </then> <else> </else> </if>`

`<if> </then>`

<elseif> <then> </then> </elseif>

<else> </else> </if>

Extends from
  \ConditionBase
author
  Stefan Bodewig
copyright
  © 2001,2002 THYRELL. All rights reserved
package
  phing.tasks.system
version
  $Revision: 557 $

### Properties

`$elseIfTasks= 'array'`
Default value `array` Details

Type

`$elseTasks= 'null'`
Default value `null` Details

Type

`$thenTasks= 'null'`
Default value `null` Details

Type

### Methods

`addElse( $e ) :`
A nested <else> element - a container of tasks that will be run if the condition doesn't hold true.

Not required.

Parameters

Name | Type | Description
--- | --- | ---
$e |  |

`addElseIf( $ei ) :`
Parameters

Name | Type | Description
--- | --- | ---
$ei |  |

`addThen( $t ) :`
A nested <then> element - a container of tasks that will be run if the condition holds true.

Not required.

Parameters

Name | Type | Description
--- | --- | ---
$t |  |

`main( ) :`
Documentation was generated by DocBlox 0.13.1.