Skip to content
This repository was archived by the owner on Apr 1, 2024. It is now read-only.

Commit c120648

Browse files
committed
support 3.29
1 parent 208325e commit c120648

14 files changed

+122
-95
lines changed

.hhconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ disallow_non_arraykey_keys=true
55
disallow_unsafe_comparisons=true
66
decl_override_require_hint=true
77
enable_experimental_tc_features=shape_field_check,sealed_classes
8-
forward_compatibility_level=20180813
8+
forward_compatibility_level=3.29
9+
user_attributes=
10+
disable_primitive_refinement=true

composer.lock

Lines changed: 41 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/ComposableElement.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,25 +541,25 @@ final protected function validateAttributeValue<T>(
541541
}
542542
switch ($decl->getValueType()) {
543543
case XHPAttributeType::TYPE_STRING:
544-
if (!is_string($val)) {
544+
if (!($val is string)) {
545545
$val = XHPAttributeCoercion::CoerceToString($this, $attr, $val);
546546
}
547547
break;
548548

549549
case XHPAttributeType::TYPE_BOOL:
550-
if (!is_bool($val)) {
550+
if (!($val is bool)) {
551551
$val = XHPAttributeCoercion::CoerceToBool($this, $attr, $val);
552552
}
553553
break;
554554

555555
case XHPAttributeType::TYPE_INTEGER:
556-
if (!is_int($val)) {
556+
if (!($val is int)) {
557557
$val = XHPAttributeCoercion::CoerceToInt($this, $attr, $val);
558558
}
559559
break;
560560

561561
case XHPAttributeType::TYPE_FLOAT:
562-
if (!is_float($val)) {
562+
if (!($val is float)) {
563563
$val = XHPAttributeCoercion::CoerceToFloat($this, $attr, $val);
564564
}
565565
break;
@@ -580,12 +580,12 @@ final protected function validateAttributeValue<T>(
580580
}
581581
// Things that are a valid array key without any coercion
582582
if ($class === 'HH\arraykey') {
583-
if (is_int($val) || is_string($val)) {
583+
if (($val is int) || ($val is string)) {
584584
break;
585585
}
586586
}
587587
if ($class === 'HH\num') {
588-
if (is_int($val) || is_float($val)) {
588+
if (($val is int) || ($val is float)) {
589589
break;
590590
}
591591
}
@@ -610,7 +610,7 @@ final protected function validateAttributeValue<T>(
610610
break;
611611

612612
case XHPAttributeType::TYPE_ENUM:
613-
if (!(is_string($val) && $decl->getEnumValues()->contains($val))) {
613+
if (!(($val is string) && $decl->getEnumValues()->contains($val))) {
614614
$enums = 'enum("'.implode('","', $decl->getEnumValues()).'")';
615615
throw new XHPInvalidAttributeException($this, $enums, $attr, $val);
616616
}
@@ -780,7 +780,7 @@ final private function validateChildrenRule(
780780
* __getChildrenDescription.
781781
*/
782782
public function __getChildrenDeclaration(): string {
783-
return (string)self::__xhpReflectionChildrenDeclaration();
783+
return self::__xhpReflectionChildrenDeclaration()->__toString();
784784
}
785785

786786
/**

src/core/ReflectionXHPAttribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getValueClass(): string {
7171
);
7272
$v = $this->extraType;
7373
invariant(
74-
is_string($v),
74+
$v is string,
7575
'Class name for attribute %s is not a string',
7676
$this->getName(),
7777
);

src/core/ReflectionXHPChildrenDeclaration.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function __toString(): string {
7070
if ($this->getType() === XHPChildrenDeclarationType::NO_CHILDREN) {
7171
return 'empty';
7272
}
73-
return (string)$this->getExpression();
73+
return $this->getExpression()->__toString();
7474
}
7575
}
7676

@@ -134,7 +134,7 @@ public function getConstraintString(): string {
134134
:xhp::class2element(get_class($this->context)),
135135
);
136136
$data = $this->data[2];
137-
invariant(is_string($data), 'Expected string data');
137+
invariant($data is string, 'Expected string data');
138138
return $data;
139139
}
140140

@@ -177,11 +177,11 @@ public function __toString(): string {
177177

178178
case XHPChildrenExpressionType::SUB_EXPR_SEQUENCE:
179179
list($e1, $e2) = $this->getSubExpressions();
180-
return $e1.','.$e2;
180+
return $e1->__toString().','.$e2->__toString();
181181

182182
case XHPChildrenExpressionType::SUB_EXPR_DISJUNCTION:
183183
list($e1, $e2) = $this->getSubExpressions();
184-
return $e1.'|'.$e2;
184+
return $e1->__toString().'|'.$e2->__toString();
185185
}
186186
}
187187

@@ -200,7 +200,7 @@ private function __constraintToString(): string {
200200
return '%'.$this->getConstraintString();
201201

202202
case XHPChildrenConstraintType::SUB_EXPR:
203-
return '('.$this->getSubExpression().')';
203+
return '('.$this->getSubExpression()->__toString().')';
204204
}
205205
}
206206
}

src/core/XHP.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,16 @@ final public function jsonSerialize(): string {
9292
final protected static function renderChild(XHPChild $child): string {
9393
if ($child instanceof :xhp) {
9494
return $child->toString();
95-
} else if ($child instanceof XHPUnsafeRenderable) {
95+
}
96+
if ($child instanceof XHPUnsafeRenderable) {
9697
return $child->toHTMLString();
97-
} else if ($child instanceof Traversable) {
98+
}
99+
if ($child instanceof Traversable) {
98100
throw new XHPRenderArrayException('Can not render traversables!');
99-
} else {
100-
return htmlspecialchars((string)$child);
101101
}
102+
103+
/* HH_FIXME[4281] stringish migration */
104+
return htmlspecialchars((string)$child);
102105
}
103106

104107
public static function element2class(string $element): string {

src/core/XHPAttributeCoercion.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function CoerceToString(
6565
mixed $val,
6666
): string {
6767
self::LogCoercion($context, 'string', $attr, $val);
68-
if (is_int($val) || is_float($val) || $val instanceof Stringish) {
68+
if (($val is int) || ($val is float) || $val instanceof Stringish) {
6969
return (string)$val;
7070
}
7171

@@ -79,7 +79,7 @@ public static function CoerceToInt(
7979
): int {
8080
self::LogCoercion($context, 'int', $attr, $val);
8181
if (
82-
(is_string($val) && is_numeric($val) && $val !== '') || is_float($val)
82+
(($val is string) && is_numeric($val) && $val !== '') || ($val is float)
8383
) {
8484
return (int)$val;
8585
}

src/html/RawPcdataElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ abstract class :xhp:raw-pcdata-element extends :xhp:pcdata-element {
2525
protected function stringify(): string {
2626
$buf = $this->renderBaseAttrs().'>';
2727
foreach ($this->getChildren() as $child) {
28-
if (!is_string($child)) {
28+
if (!($child is string)) {
2929
throw new XHPClassException($this, 'Child must be a string');
3030
}
3131
$buf .= $child;

src/html/tags/c/ConditionalComment.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@
1313
* the conditional statement.
1414
*/
1515
class :x:conditional-comment extends :x:primitive {
16-
attribute Stringish if @required;
16+
attribute string if @required;
1717
children (pcdata | :xhp)*;
1818

1919
protected function stringify(): string {
2020
$children = $this->getChildren();
21-
$html = '<!--[if '.(string)$this->:if.']>';
21+
$html = '<!--[if '.$this->:if.']>';
2222
foreach ($children as $child) {
23-
if ($child instanceof :xhp) {
24-
$html .= :xhp::renderChild($child);
25-
} else {
26-
$html .= (string)$child;
27-
}
23+
$html .= :xhp::renderChild($child);
2824
}
2925
$html .= '<![endif]-->';
3026
return $html;

0 commit comments

Comments
 (0)