Login | Register
My pages Projects Community openCollabNet

Discussions > dev > [phing-dev] Handling of (possibly boolean) attribute values is broken

phing
Discussion topic

Back to topic list

[phing-dev] Handling of (possibly boolean) attribute values is broken

Author mpigulla
Full name Matthias Pigulla
Date 2011-06-21 07:04:50 PDT
Message Dear all,

a few bugs (#633, #495, #376, #383) seem to stem from a similar problem, namely IntrospectionHelper's attempt to convert "special" strings like "true", "false", "y" , "n", "f", ... into booleans prior to calling the underlying task's setter.

This leads to strange behaviours that are documented in the aforementioned bugs. One particular edge case (without bug report) is that
<property name="f" value="path/to/a/file" />
does not work because the PropertyTask will be handed (bool) false as property name.

At the same time, this magic is not applied f. e. when loading properties from a file. That is, having <property name="foo" value="true" /> and loading from a properties file with "foo = true" will not lead to the same results.

I think only the Tasks themselves can make meaningful decisions whether a particular attribute is expected to be a boolean value or not. In other words, we should not apply any magic apart from property ${} expansion when configuring Tasks.

As we're already using some Reflection in IntrospectionHelper, Tasks could then adhere to a particular convention when it comes to booleans.

Example #1: The setter could be "haveXXX" instead of "setXXX". "have"... would be a hint for the IntrospectionHelper that a boolean cast is desired.
Example #2: There is already support for some special classes in IntrospectionHelper, namely PhingFile, Path and Reference. We could make up a "PhingBoolean" class that Tasks require (via type hint) in the setter and could then read from like

... function setAttribute(PhingBoolean $b) { $this->attribute = $b->bool(); }

Either way would require some re-work of the existing tasks (even if minimal) and might introduce a BC break for 3rd party tasks.

BTW, this resembles fixes like http://www.phing.inf​o/trac/changeset/664​ that have been made ad-hoc in the past in cases where problems/bugs were reported.

Opinions? Lead decisions? :-)

-mp.

« Previous message in topic | 1 of 5 | Next message in topic »

Messages

Show all messages in topic

[phing-dev] Handling of (possibly boolean) attribute values is broken mpigulla Matthias Pigulla 2011-06-21 07:04:50 PDT
     Re: [phing-dev] Handling of (possibly boolean) attribute values is broken mrook Michiel Rook 2011-06-21 08:22:20 PDT
         AW: [phing-dev] Handling of (possibly boolean) attribute values is broken mpigulla Matthias Pigulla 2011-06-21 08:30:21 PDT
         AW: [phing-dev] Handling of (possibly boolean) attribute values is broken mpigulla Matthias Pigulla 2011-06-21 09:27:04 PDT
             Re: AW: [phing-dev] Handling of (possibly boolean) attribute values is broken mrook Michiel Rook 2011-06-21 13:11:09 PDT
Messages per page: