Author: Tobias Schlitt
Date: 2006-01-20 09:48:38 +0100 (Fri, 20 Jan 2006)
New Revision: 1986
Log:
- Fix unreported bug: Option values not properly checked for eczConsoleTable,
ezcConsoleOutput.
- Fix unreported bug in ezcConsoleProgressbarOptions that disallowed option
read access.
- Fix notice in ezcConsoleOptionExclusionViolationException.
- Removed deprecated todo from ezcConsoleTable docs.
Modified:
packages/ConsoleTools/trunk/src/exceptions/option_exclusion_violation.php
packages/ConsoleTools/trunk/src/structs/output_options.php
packages/ConsoleTools/trunk/src/structs/progressbar_options.php
packages/ConsoleTools/trunk/src/structs/table_options.php
packages/ConsoleTools/trunk/src/table.php
packages/ConsoleTools/trunk/tests/table_test.php
Modified:
packages/ConsoleTools/trunk/src/exceptions/option_exclusion_violation.php
===================================================================
--- packages/ConsoleTools/trunk/src/exceptions/option_exclusion_violation.php
2006-01-19 16:09:08 UTC (rev 1985)
+++ packages/ConsoleTools/trunk/src/exceptions/option_exclusion_violation.php
2006-01-20 08:48:38 UTC (rev 1986)
@@ -20,7 +20,7 @@
function __construct( ezcConsoleOption $excludingOption, ezcConsoleOption
$excludedOption, $valueRange = null )
{
$message = "The option <{$excludingOption->long}> excludes the option
<{$excludedOption->long}>" ;
- if ( $value !== null )
+ if ( $valueRange !== null )
{
$message .= "to have a value in <{$valueRange}> ";
}
Modified: packages/ConsoleTools/trunk/src/structs/output_options.php
===================================================================
--- packages/ConsoleTools/trunk/src/structs/output_options.php 2006-01-19
16:09:08 UTC (rev 1985)
+++ packages/ConsoleTools/trunk/src/structs/output_options.php 2006-01-20
08:48:38 UTC (rev 1986)
@@ -24,7 +24,7 @@
*
* @var int
*/
- public $verbosityLevel = 1;
+ protected $verbosityLevel = 1;
/**
* Determins, whether text is automatically wrapped after a specific amount
@@ -33,14 +33,14 @@
*
* @var int
*/
- public $autobreak = 0;
+ protected $autobreak = 0;
/**
* Wether to use formatings or not.
*
* @var bool
*/
- public $useFormats = true;
+ protected $useFormats = true;
/**
* Create a new ezcConsoleOutputOptions struct.
@@ -58,6 +58,70 @@
$this->useFormats = $useFormats;
}
+ /**
+ * Property read access.
+ *
+ * @throws ezcBasePropertyNotFoundException if the the desired property is
+ * not found.
+ *
+ * @param string $propertyName Name of the property.
+ * @return mixed Value of the property or null.
+ */
+ public function __get( $propertyName )
+ {
+ if ( isset( $this->$propertyName ) )
+ {
+ return $this->$propertyName;
+ }
+ throw new ezcBasePropertyNotFoundException( $propertyName );
+ }
+
+ /**
+ * Property write access.
+ *
+ * @throws ezcBasePropertyNotFoundException
+ * If a desired property could not be found.
+ * @throws ezcBaseSettingValueException
+ * If a desired property value is out of range.
+ *
+ * @param string $propertyName Name of the property.
+ * @param mixed $val The value for the property.
+ * @return void
+ */
+ public function __set( $propertyName, $val )
+ {
+ switch ( $propertyName )
+ {
+ case 'verbosityLevel':
+ case 'autobreak':
+ if ( !is_int( $val ) || $val < 0 )
+ {
+ throw new ezcBaseSettingValueException( $propertyName,
$val, 'int >= 0' );
+ }
+ break;
+ case 'useFormats':
+ if ( !is_bool( $val ) )
+ {
+ throw new ezcBaseSettingValueException( $propertyName,
$val, 'bool' );
+ }
+ break;
+ default:
+ throw new ezcBaseSettingNotFoundException( $propertyName );
+ }
+ $this->$propertyName = $val;
+ }
+
+ /**
+ * Property isset access.
+ *
+ * @param string $propertyName Name of the property.
+ * @return bool True if the property is set, false otherwise.
+ */
+ public function __isset( $propertyName )
+ {
+ return isset( $this->$propertyName );
+ }
+
}
?>
Modified: packages/ConsoleTools/trunk/src/structs/progressbar_options.php
===================================================================
--- packages/ConsoleTools/trunk/src/structs/progressbar_options.php
2006-01-19 16:09:08 UTC (rev 1985)
+++ packages/ConsoleTools/trunk/src/structs/progressbar_options.php
2006-01-20 08:48:38 UTC (rev 1986)
@@ -85,7 +85,7 @@
*/
public function __get( $propertyName )
{
- if ( isset( $this->$propertyName ) )
+ if ( isset( $this->properties[$propertyName] ) )
{
return $this->properties[$propertyName];
}
Modified: packages/ConsoleTools/trunk/src/structs/table_options.php
===================================================================
--- packages/ConsoleTools/trunk/src/structs/table_options.php 2006-01-19
16:09:08 UTC (rev 1985)
+++ packages/ConsoleTools/trunk/src/structs/table_options.php 2006-01-20
08:48:38 UTC (rev 1986)
@@ -24,7 +24,7 @@
*
* @var mixed
*/
- public $colWidth = 'auto';
+ protected $colWidth = 'auto';
/**
* Wrap style of text contained in strings.
@@ -34,7 +34,7 @@
*
* @var int
*/
- public $colWrap = ezcConsoleTable::WRAP_AUTO;
+ protected $colWrap = ezcConsoleTable::WRAP_AUTO;
/**
* Standard column alignment, applied to cells that have to explicit
@@ -47,42 +47,42 @@
*
* @var int
*/
- public $defaultAlign = ezcConsoleTable::ALIGN_LEFT;
+ protected $defaultAlign = ezcConsoleTable::ALIGN_LEFT;
/**
* Padding characters for side padding between data and lines.
*
* @var string
*/
- public $colPadding = ' ';
+ protected $colPadding = ' ';
/**
* Type of the given table width (fixed or maximal value).
*
* @var int
*/
- public $widthType = ezcConsoleTable::WIDTH_MAX;
+ protected $widthType = ezcConsoleTable::WIDTH_MAX;
/**
* Character to use for drawing vertical lines.
*
* @var string
*/
- public $lineVertical = '-';
+ protected $lineVertical = '-';
/**
* Character to use for drawing hozizontal lines.
*
* @var string
*/
- public $lineHorizontal = '|';
+ protected $lineHorizontal = '|';
/**
* Character to use for drawing line corners.
*
* @var string
*/
- public $corner = '+';
+ protected $corner = '+';
/**
* Standard column content format, applied to cells that have 'default' as
@@ -90,7 +90,7 @@
*
* @var string
*/
- public $defaultFormat = 'default';
+ protected $defaultFormat = 'default';
/**
* Standard border format, applied to rows that have 'default' as the
@@ -98,7 +98,7 @@
*
* @var string
*/
- public $defaultBorderFormat = 'default';
+ protected $defaultBorderFormat = 'default';
/**
* Create a new ezcConsoleProgressbarOptions struct.
@@ -132,7 +132,97 @@
$this->defaultFormat = $defaultFormat;
$this->defaultBorderFormat = $defaultBorderFormat;
}
+
+ /**
+ * Property read access.
+ *
+ * @throws ezcBasePropertyNotFoundException if the the desired property is
+ * not found.
+ *
+ * @param string $propertyName Name of the property.
+ * @return mixed Value of the property or null.
+ */
+ public function __get( $propertyName )
+ {
+ if ( isset( $this->$propertyName ) )
+ {
+ return $this->$propertyName;
+ }
+ throw new ezcBasePropertyNotFoundException( $propertyName );
+ }
+ /**
+ * Property write access.
+ *
+ * @throws ezcBasePropertyNotFoundException
+ * If a desired property could not be found.
+ * @throws ezcBaseSettingValueException
+ * If a desired property value is out of range.
+ *
+ * @param string $propertyName Name of the property.
+ * @param mixed $val The value for the property.
+ * @return void
+ */
+ public function __set( $propertyName, $val )
+ {
+ switch ( $propertyName )
+ {
+ case 'colWidth':
+ if ( !is_array( $val ) && !is_string( $val ) && $val !==
'auto' )
+ {
+ throw new ezcBaseSettingValueException( $propertyName,
$val, 'array(int) or "auto"' );
+ }
+ break;
+ case 'colWrap':
+ if ( $val !== ezcConsoleTable::WRAP_AUTO && $val !==
ezcConsoleTable::WRAP_NONE && $val !== ezcConsoleTable::WRAP_CUT )
+ {
+ throw new ezcBaseSettingValueException( $propertyName,
$val, 'ezcConsoleTable::WRAP_AUTO, ezcConsoleTable::WRAP_NONE,
ezcConsoleTable::WRAP_CUT' );
+ }
+ break;
+ case 'defaultAlign':
+ if ( $val !== ezcConsoleTable::ALIGN_DEFAULT && $val !==
ezcConsoleTable::ALIGN_LEFT && $val !== ezcConsoleTable::ALIGN_CENTER && $val
!== ezcConsoleTable::ALIGN_RIGHT )
+ {
+ throw new ezcBaseSettingValueException( $propertyName,
$val, 'ezcConsoleTable::ALIGN_DEFAULT, ezcConsoleTable::ALIGN_LEFT,
ezcConsoleTable::ALIGN_CENTER, ezcConsoleTable::ALIGN_RIGHT' );
+ }
+ break;
+ case 'colPadding':
+ if ( !is_string( $val ) )
+ {
+ throw new ezcBaseSettingValueException( $propertyName,
$val, 'string' );
+ }
+ break;
+ case 'widthType':
+ if ( $val !== ezcConsoleTable::WIDTH_MAX && $val !==
ezcConsoleTable::WIDTH_FIXED )
+ {
+ throw new ezcBaseSettingValueException( $propertyName,
$val, 'ezcConsoleTable::WIDTH_MAX, ezcConsoleTable::WIDTH_FIXED' );
+ }
+ break;
+ case 'lineVertical':
+ case 'lineHorizontal':
+ case 'corner':
+ if ( !is_string( $val ) && strlen( $val ) !== 1 )
+ {
+ throw new ezcBaseSettingValueException( $propertyName,
$val, 'string, length = 1' );
+ }
+ break;
+ default:
+ throw new ezcBaseSettingNotFoundException( $propertyName );
+ }
+ $this->$propertyName = $val;
+ }
+
+ /**
+ * Property isset access.
+ *
+ * @param string $propertyName Name of the property.
+ * @return bool True if the property is set, false otherwise.
+ */
+ public function __isset( $propertyName )
+ {
+ return isset( $this->$propertyName );
+ }
+
+
}
?>
Modified: packages/ConsoleTools/trunk/src/table.php
===================================================================
--- packages/ConsoleTools/trunk/src/table.php 2006-01-19 16:09:08 UTC (rev
1985)
+++ packages/ConsoleTools/trunk/src/table.php 2006-01-20 08:48:38 UTC (rev
1986)
@@ -416,8 +416,6 @@
* @throws ezcBaseValueException
* If a the value for a property is out of range.
* @return void
- *
- * @todo Remove deprectaed "cols" setting!
*/
public function __set( $key, $val )
{
Modified: packages/ConsoleTools/trunk/tests/table_test.php
===================================================================
--- packages/ConsoleTools/trunk/tests/table_test.php 2006-01-19 16:09:08 UTC
(rev 1985)
+++ packages/ConsoleTools/trunk/tests/table_test.php 2006-01-20 08:48:38 UTC
(rev 1986)
@@ -258,6 +258,10 @@
// Set options
foreach ( $options as $key => $val )
{
+ if ( $key == 'lineFormatHead' )
+ {
+ continue;
+ }
$table->options->$key = $val;
}
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components