[Argil-svn] SF.net SVN: argil: [515] branches/experimental
Status: Alpha
Brought to you by:
tswicegood
|
From: <tsw...@us...> - 2007-04-01 18:40:07
|
Revision: 515
http://argil.svn.sourceforge.net/argil/?rev=515&view=rev
Author: tswicegood
Date: 2007-04-01 11:40:08 -0700 (Sun, 01 Apr 2007)
Log Message:
-----------
Add in support for @isNot
Modified Paths:
--------------
branches/experimental/src/Argil/Reflection/Property.php
branches/experimental/tests/Argil/Reflection/PropertyTest.php
Modified: branches/experimental/src/Argil/Reflection/Property.php
===================================================================
--- branches/experimental/src/Argil/Reflection/Property.php 2007-04-01 04:51:45 UTC (rev 514)
+++ branches/experimental/src/Argil/Reflection/Property.php 2007-04-01 18:40:08 UTC (rev 515)
@@ -21,17 +21,26 @@
$doc = $this->getDocComment();
$name = $this->getName();
$value = $object->$name;
- if (preg_match_all('/@is ([a-z]+) (.*)/', $doc, $matches)) {
- foreach ($matches[1] as $key => $spec) {
+ if (preg_match_all('/@(is|isNot) ([a-z]+) (.*)/', $doc, $matches)) {
+ foreach ($matches[2] as $key => $spec) {
$spec = ucfirst($spec);
$reflection = new ReflectionClass('Argil_Specification_' . $spec);
$args = array_merge(
array($value),
- explode(' ', $matches[2][$key])
+ explode(' ', $matches[3][$key])
);
$specObj = $reflection->newInstanceArgs($args);
- if (!$specObj->valid()) {
- return false;
+ switch ($matches[1][$key]) {
+ case 'is' :
+ if (!$specObj->valid()) {
+ return false;
+ }
+ break;
+ case 'isNot' :
+ if ($specObj->valid()) {
+ return false;
+ }
+ break;
}
}
}
Modified: branches/experimental/tests/Argil/Reflection/PropertyTest.php
===================================================================
--- branches/experimental/tests/Argil/Reflection/PropertyTest.php 2007-04-01 04:51:45 UTC (rev 514)
+++ branches/experimental/tests/Argil/Reflection/PropertyTest.php 2007-04-01 18:40:08 UTC (rev 515)
@@ -11,6 +11,11 @@
public $publicProperty;
protected $protectedProperty;
private $privateProperty;
+
+ /**
+ * @isNot length 5 <
+ */
+ public $notLessThanFive;
}
class Argil_Reflection_PropertyTest extends UnitTestCase {
@@ -56,5 +61,12 @@
$object->publicProperty = '1234';
$this->assertFalse($public->isValid($object));
+
+ $object->notLessThanFive = '1234';
+ $attribute = new Argil_Reflection_Property($properties[3]);
+ $this->assertFalse($attribute->isValid($object));
+
+ $object->notLessThanFive = '12345';
+ $this->assertTrue($attribute->isValid($object));
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|