Skip to content
Browse files

the toBool() cast helper may now throw errors, so we need to catch these

git-svn-id: http://svn.php.net/repository/pear/packages/CodeGen_PECL/trunk@234525 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 8146562 commit 4106ff8643c80dea82e69a403abe785008a6a23e Hartmut Holzgraefe committed Apr 26, 2007
Showing with 69 additions and 21 deletions.
  1. +69 −21 PECL/ExtensionParser.php
View
90 PECL/ExtensionParser.php
@@ -285,7 +285,12 @@ function tagstart_resources_resource($attr)
}
if (isset($attr["alloc"])) {
- $err = $this->helper->setAlloc($this->toBool($attr["alloc"]));
+ $value = $this->toBool($attr["alloc"], "alloc");
+ if (PEAR::isError($value)) {
+ return $value;
+ }
+
+ $err = $this->helper->setAlloc($value);
if (PEAR::isError($err)) {
return $err;
}
@@ -880,12 +885,24 @@ function tagstart_class($attr)
// TODO: make sure a class is not abstract and final at the same time
- if (isset($attr["final"]) && $this->toBool($attr["final"])) {
- $class->isFinal();
+ if (isset($attr["final"])) {
+ $value = $this->toBool($attr["final"], "final");
+ if (PEAR::isError($value)) {
+ return $value;
+ }
+ if ($value) {
+ $class->isFinal();
+ }
}
- if (isset($attr["abstract"]) && $this->toBool($attr["abstract"])) {
- $class->isAbstract();
+ if (isset($attr["abstract"]))
+ $value = $this->toBool($attr["abstract"], "abstract");
+ if (PEAR::isError($value)) {
+ return $value;
+ }
+ if ($value) {
+ $class->isAbstract();
+ }
}
if (isset($attr["if"])) {
@@ -960,8 +977,14 @@ function tagstart_class_property($attr)
}
}
- if (isset($attr["static"]) && $this->toBool($attr["static"])) {
- $prop->isStatic();
+ if (isset($attr["static"])) {
+ $value = $this->toBool($attr["static"], "static");
+ if (PEAR::isError($value)) {
+ return $value;
+ }
+ if ($value) {
+ $prop->isStatic();
+ }
}
if (isset($attr["if"])) {
@@ -1025,8 +1048,15 @@ function tagend_class_payload($attr, $data)
return PEAR::raiseError("type attribute missing for class payload");
}
$this->helper->setPayloadType($attr["type"]);
-
- $alloc = isset($attr["alloc"]) ? $this->toBool($attr["alloc"]): true;
+
+ if (isset($attr["alloc"])) {
+ $alloc = $this->toBool($attr["alloc"], "alloc");
+ if (PEAR::isError($value)) {
+ return $value;
+ }
+ } else {
+ $alloc = true;
+ }
$this->helper->setPayloadAlloc($alloc);
}
@@ -1068,23 +1098,41 @@ function tagstart_class_function($attr)
}
}
- if (isset($attr["static"]) && $this->toBool($attr["static"])) {
- $err = $method->isStatic();
- if (PEAR::isError($err)) {
- return $err;
+ if (isset($attr["static"])) {
+ $value = $this->toBool($attr["static"], "static");
+ if (PEAR::isError($value)) {
+ return $value;
+ }
+ if ($value) {
+ $err = $method->isStatic();
+ if (PEAR::isError($err)) {
+ return $err;
+ }
}
}
- if (isset($attr["abstract"]) && $this->toBool($attr["abstract"])) {
- $err = $method->isAbstract();
- if (PEAR::isError($err)) {
- return $err;
+ if (isset($attr["abstract"])) {
+ $value = $this->toBool($attr["abstract"], "abstract");
+ if (PEAR::isError($value)) {
+ return $value;
+ }
+ if ($value) {
+ $err = $method->isAbstract();
+ if (PEAR::isError($err)) {
+ return $err;
+ }
}
}
- if (isset($attr["final"]) && $this->toBool($attr["final"])) {
- $err = $method->isFinal();
- if (PEAR::isError($err)) {
- return $err;
+ if (isset($attr["final"])) {
+ $value = $this->toBool($attr["final"], "final");
+ if (PEAR::isError($value)) {
+ return $value;
+ }
+ if ($value) {
+ $err = $method->isFinal();
+ if (PEAR::isError($err)) {
+ return $err;
+ }
}
}

0 comments on commit 4106ff8

Please sign in to comment.
Something went wrong with that request. Please try again.