Version 1 by Eric Coker
on Aug 28, 2009 12:12.

compared with
Current by Thomas Weidner
on Nov 24, 2009 11:23.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (34)

View Page History
{info:title=New Proposal Template}
This page has been created from a template that uses "zones." To proceed:
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

# Edit the page
# Replace sample content within each zone-data tag with your own content
# Remove this notice
# Save the page
# When you are ready for community review, move this page to the [Ready for Review] section on the edit page.

{note:title=No placeholders allowed!}
Please do not create placeholders. Wait until you have sufficient content to replace all sample data in the proposal template before creating your proposal document.
{note}
{info}

{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Magic Zend_Filter_Bool
{zone-data}

{zone-data:proposer-list}
[My Name|mailto:noreply@zend.com]
[~retrorocket]
{zone-data}

{zone-data}

{zone-data:revision}
1.0 - 1 January 28 August 2008: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_Magic is a simple component that reads my mind and generates code dynamically to do what I want.
Zend_Filter_Bool converts common representations of boolean values in multiple types and string formats to a strongly-typed boolean value.
{zone-data}

{zone-data:references}
* [Harry Houdini Wikipedia Entry|http://en.wikipedia.org/wiki/Harry_Houdini]
* [MagicTricks.com|http://www.magictricks.com/]
* [PHP:Booleans|http://us3.php.net/manual/en/language.types.boolean.php]
* [Zend_Filter|http://framework.zend.com/manual/en/zend.filter.html]
{zone-data}

{zone-data:requirements}
Most requirements take the form of "foo will do ...." or "foo will not support ...", although different words and sentence structure might be used. Adding functionality to your proposal is requirements creep (bad), unless listed below. Discuss major changes with your team first, and then open a "feature improvement" issue against this component.

* This component *will* correctly reads a developers mind for intent and generate the right configuration file.
* The generated config file *will not* support XML, but will provide an extension point in the API.
* This component *will* use no more memory than twice the size of all data it contains.
* This component *will* include a factory method.
* This component *will not* allow subclassing. (i.e. when reviewed, we expect to see "final" keyword in code)
* This component *will* only generate data exports strictly complying with RFC 12345.
* This component *will* validate input data against formats supported by ZF component Foo.
* This component *will not* save any data using Zend_Cache or the filesystem. All transient data *will be* saved using Zend_Session.
* This component *will* convert input values into formatted and strongly-typed output.
{zone-data}

{zone-data:dependencies}
* Zend_Exception Zend_Filter
{zone-data}

{zone-data:operation}
The component is instantiated with a mind-link that ...
The {{(bool)}} and {{(boolean)}} casts in PHP consider {{NULL}} and empty strings to be
{{FALSE}}, and any value that is not specifically {{FALSE}} to be {{TRUE}}. Zend_Filter_Bool is intended as an alternative to casting for applications where such assumptions will cause logic errors.

A different set of needs is addressed by filtering as opposed to casting to boolean:
* It is not always appropriate to assume intent regarding empty or unset input. If a default value is desired, it should be defined by setting the [Zend_Filter_Input::DEFAULT_VALUE|http://framework.zend.com/manual/en/zend.filter.input.html#zend.filter.input.metacommands.default] metacommand, or by checking/validating for a {{NULL}} value from the results of this filter.
* It is helpful to filter for valid boolean literals used by some databases that would not be recognized when casting.

The following values are considered {{FALSE}}:
* the boolean {{FALSE}} itself
* numeric values that equal 0 such as 0 or 0.0
* numeric strings that can be cast to the integer 0 such as "0.0" or "00"
* the string "false" (any capitalization allowed)
* the string "f" (any capitalization allowed)
* the string "no" (any capitalization allowed)
* the string "n" (any capitalization allowed)
* the string "off" (any capitalization allowed)

The following values are considered {{TRUE}}:
* the boolean {{TRUE}} itself
* numeric values that equal 1 such as 1 or 1.0
* numeric strings that can be cast to the integer 1 such as "1.0" or "01"
* the string "true" (any capitalization allowed)
* the string "t" (any capitalization allowed)
* the string "yes" (any capitalization allowed)
* the string "y" (any capitalization allowed)
* the string "on" (any capitalization allowed)

The filter will output {{NULL}} upon attempting to process any value not listed above.
{zone-data}

{zone-data:milestones}
Describe some intermediate state of this component in terms of design notes, additional material added to this page, and / code. Note any significant dependencies here, such as, "Milestone #3 can not be completed until feature Foo has been added to ZF component XYZ." Milestones will be required for acceptance of future proposals. They are not hard, and many times you will only need to think of the first three below.
* Milestone 1: [design notes will be published here|http://framework.zend.com/wiki/x/sg]
* Milestone 2: Working prototype checked into the incubator supporting use cases #1, #2, ...
* Milestone 1: \[DONE\] Proposal finished
* Milestone 2: Proposal accepted
* Milestone 3: Working prototype checked into the incubator supporting use cases #3 and #4.
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.

If a milestone is already done, begin the description with "\[DONE\]", like this:
* Milestone #: \[DONE\] Unit tests ...
{zone-data}

{zone-data:class-list}
* Zend_Magic_Exception Zend_Filter_Bool
* Zend_Magic (factory class)
* Zend_Magic_MindProbe
* Zend_Magic_MindProbe_Intent
* Zend_Magic_Action
* Zend_Magic_CodeGen
{zone-data}

{zone-data:use-cases}
||UC-01||
$filter = new Zend_Filter_Bool();
print $filter(true);
// outputs TRUE

... (see good use cases book)
||UC-02||
$filter = new Zend_Filter_Bool();
print $filter(1);
// outputs TRUE

||UC-03||
$filter = new Zend_Filter_Bool();
print $filter('1');
// outputs TRUE

||UC-04||
$filter = new Zend_Filter_Bool();
print $filter('1.0');
// outputs TRUE

||UC-05||
$filter = new Zend_Filter_Bool();
print $filter('01');
// outputs TRUE

||UC-06||
$filter = new Zend_Filter_Bool();
print $filter('true');
// outputs TRUE

||UC-07||
$filter = new Zend_Filter_Bool();
print $filter('t');
// outputs TRUE

||UC-08||
$filter = new Zend_Filter_Bool();
print $filter('yes');
// outputs TRUE

||UC-09||
$filter = new Zend_Filter_Bool();
print $filter('y');
// outputs TRUE

||UC-10||
$filter = new Zend_Filter_Bool();
print $filter('on');
// outputs TRUE

||UC-11||
$filter = new Zend_Filter_Bool();
print $filter(false);
// outputs FALSE

||UC-12||
$filter = new Zend_Filter_Bool();
print $filter(0);
// outputs FALSE

||UC-13||
$filter = new Zend_Filter_Bool();
print $filter('0');
// outputs FALSE

||UC-14||
$filter = new Zend_Filter_Bool();
print $filter('0.0');
// outputs FALSE

||UC-15||
$filter = new Zend_Filter_Bool();
print $filter('00');
// outputs FALSE

||UC-16||
$filter = new Zend_Filter_Bool();
print $filter('false');
// outputs FALSE

||UC-17||
$filter = new Zend_Filter_Bool();
print $filter('f');
// outputs FALSE

||UC-18||
$filter = new Zend_Filter_Bool();
print $filter('no');
// outputs FALSE

||UC-19||
$filter = new Zend_Filter_Bool();
print $filter('n');
// outputs FALSE

||UC-20||
$filter = new Zend_Filter_Bool();
print $filter('off');
// outputs FALSE

||UC-21||
$filter = new Zend_Filter_Bool();
print $filter(null);
// outputs NULL

||UC-22||
$filter = new Zend_Filter_Bool();
print $filter('');
// outputs NULL

||UC-23||
$filter = new Zend_Filter_Bool();
print $filter('unhandled input');
// outputs NULL

{zone-data}

{zone-data:skeletons}
{code}
class Zend_Magic_Exception extends Zend_Exception {}
class Zend_Filter_Bool implements Zend_Filter_Interface
{
class Zend_Magic {
/**
* @param mixed $value
* @return bool|null
*/
public function filter($value);
... }
{code}
{zone-data}

{zone-template-instance}
{zone-template-instance}]]></ac:plain-text-body></ac:macro>