Page MenuHomePhabricator

D14271.diff
No OneTemporary

D14271.diff

diff --git a/src/parser/PhutilTypeSpec.php b/src/parser/PhutilTypeSpec.php
--- a/src/parser/PhutilTypeSpec.php
+++ b/src/parser/PhutilTypeSpec.php
@@ -172,6 +172,15 @@
}
public static function getCommonParentClass($class_a, $class_b) {
+ // Make sure both classes are really classes.
+ try {
+ if (!class_exists($class_a) || !class_exists($class_b)) {
+ return null;
+ }
+ } catch (PhutilMissingSymbolException $ex) {
+ return null;
+ }
+
$ancestors_a = array();
do {
$ancestors_a[] = $class_a;
diff --git a/src/parser/__tests__/PhutilTypeSpecTestCase.php b/src/parser/__tests__/PhutilTypeSpecTestCase.php
--- a/src/parser/__tests__/PhutilTypeSpecTestCase.php
+++ b/src/parser/__tests__/PhutilTypeSpecTestCase.php
@@ -170,7 +170,7 @@
$caught = $ex;
}
- $this->assertTrue($ex instanceof PhutilTypeCheckException);
+ $this->assertTrue($caught instanceof PhutilTypeCheckException);
}
}
@@ -208,7 +208,7 @@
$caught = $ex;
}
- $this->assertTrue($ex instanceof PhutilTypeMissingParametersException);
+ $this->assertTrue($caught instanceof PhutilTypeMissingParametersException);
// Parameter "size" is specified but does not exist.
@@ -224,7 +224,7 @@
$caught = $ex;
}
- $this->assertTrue($ex instanceof PhutilTypeExtraParametersException);
+ $this->assertTrue($caught instanceof PhutilTypeExtraParametersException);
}
public function testRegexValidation() {
@@ -249,7 +249,7 @@
$caught = $ex;
}
- $this->assertTrue($ex instanceof PhutilTypeCheckException);
+ $this->assertTrue($caught instanceof PhutilTypeCheckException);
}
public function testScalarOrListRegexp() {
@@ -288,4 +288,25 @@
$this->assertTrue(true);
}
+ public function testMixedVector() {
+ // This is a test case for an issue where we would not infer the type
+ // of a vector containing a mixture of scalar and nonscalar elements
+ // correctly.
+
+ $caught = null;
+ try {
+ PhutilTypeSpec::checkMap(
+ array(
+ 'key' => array('!', (object)array()),
+ ),
+ array(
+ 'key' => 'list<X>',
+ ));
+ } catch (PhutilTypeCheckException $ex) {
+ $caught = $ex;
+ }
+
+ $this->assertTrue($caught instanceof PhutilTypeCheckException);
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 30, 1:52 PM (5 d, 21 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6736212
Default Alt Text
D14271.diff (2 KB)

Event Timeline