Skip to content

Commit dfee2ee

Browse files
committed
Some style fixes
1 parent 5b337e9 commit dfee2ee

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

lib/PHPCfg/Types/Helper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ public static function fromOpType(Op\Type $type): Type
282282
return static::union(...array_map(fn($sub) => static::fromOpType($sub), $type->subtypes))->simplify();
283283
}
284284
if ($type instanceof Op\Type\Intersection) {
285-
return static::intersection(...array_map(fn($sub) => static::fromOpType($sub), $type->subtypes)
285+
return static::intersection(
286+
...array_map(fn($sub) => static::fromOpType($sub), $type->subtypes)
286287
)->simplify();
287288
}
288289
throw new LogicException("Unknown type " . $type->getType());

lib/PHPCfg/Types/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public function equals(Type $type): bool
235235
if ($type->type === Type::TYPE_OBJECT) {
236236
if ($type->userType === null && $this->userType === null) {
237237
// not reachable since top $type === $this check catches
238-
} elseif ($type->userType !== null XOR $this->userType !== null) {
238+
} elseif ($type->userType !== null xor $this->userType !== null) {
239239
// One is typed, the other isn't
240240
return false;
241241
}

test/Types/TypeTest.php

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testToString($decl, $result)
4646
{
4747
$this->assertEquals($decl, (string) $result);
4848
}
49-
49+
5050
public function testHasSubTypes()
5151
{
5252
$this->assertFalse((new Type(Type::TYPE_LONG))->hasSubTypes());
@@ -67,7 +67,7 @@ public static function provideTestAllowsNull()
6767
Helper::union(Helper::int(), Helper::null(), Helper::string()),
6868
Helper::union(Helper::int(), Helper::null())
6969
), false];
70-
}
70+
}
7171

7272
#[DataProvider("provideTestAllowsNull")]
7373
public function testAllowsNull(Type $type, $isAllowed)
@@ -86,28 +86,42 @@ public static function provideTestSimplification()
8686
yield ["empty intersection", new Type(Type::TYPE_INTERSECTION, []), Helper::void()];
8787

8888
// Nested same complex types
89-
yield ["nested same union", new Type(Type::TYPE_UNION, [
90-
new Type(Type::TYPE_UNION, [Helper::int()])
91-
]), Helper::int()];
92-
yield ["nested same intersection", new Type(Type::TYPE_INTERSECTION, [
93-
new Type(Type::TYPE_INTERSECTION, [Helper::int()])
94-
]), Helper::int()];
89+
yield [
90+
"nested same union",
91+
new Type(Type::TYPE_UNION, [
92+
new Type(Type::TYPE_UNION, [Helper::int()]),
93+
]),
94+
Helper::int(),
95+
];
96+
yield [
97+
"nested same intersection",
98+
new Type(Type::TYPE_INTERSECTION, [
99+
new Type(Type::TYPE_INTERSECTION, [Helper::int()]),
100+
]),
101+
Helper::int(),
102+
];
95103

96104
// Nested different complex types
97-
yield ["nested intersection unions", new Type(Type::TYPE_UNION, [
98-
new Type(Type::TYPE_INTERSECTION, [Helper::int(), Helper::float()]),
99-
new Type(Type::TYPE_INTERSECTION, [Helper::string(), Helper::float()])
100-
]), Helper::union(
101-
Helper::intersection(Helper::int(), Helper::float()),
102-
Helper::intersection(Helper::string(), Helper::float())
103-
)];
105+
yield [
106+
"nested intersection unions",
107+
new Type(Type::TYPE_UNION, [
108+
new Type(Type::TYPE_INTERSECTION, [Helper::int(), Helper::float()]),
109+
new Type(Type::TYPE_INTERSECTION, [Helper::string(), Helper::float()]),
110+
]),
111+
Helper::union(
112+
Helper::intersection(Helper::int(), Helper::float()),
113+
Helper::intersection(Helper::string(), Helper::float())
114+
),
115+
];
104116

105117
// Nested same complex types. Tests elimination of duplicated types
106-
yield ["nested intersection unions", new Type(Type::TYPE_UNION, [
118+
yield [
119+
"nested intersection unions",
120+
new Type(Type::TYPE_UNION, [
107121
new Type(Type::TYPE_INTERSECTION, [Helper::int(), Helper::float()]),
108-
new Type(Type::TYPE_INTERSECTION, [Helper::int(), Helper::float()])
109-
]),
110-
Helper::intersection(Helper::int(), Helper::float())
122+
new Type(Type::TYPE_INTERSECTION, [Helper::int(), Helper::float()]),
123+
]),
124+
Helper::intersection(Helper::int(), Helper::float()),
111125
];
112126
}
113127

0 commit comments

Comments
 (0)