Skip to content

Commit 16f6d80

Browse files
SvenRtbgcweiske
authored andcommitted
Use ::class whenever an instance is checked
1 parent 43d27bf commit 16f6d80

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

tests/ArrayTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public function testMapTypedSimpleArray()
5454
);
5555
$this->assertIsArray($sn->typedSimpleArray);
5656
$this->assertCount(3, $sn->typedSimpleArray);
57-
$this->assertInstanceOf('DateTime', $sn->typedSimpleArray[0]);
57+
$this->assertInstanceOf(DateTime::class, $sn->typedSimpleArray[0]);
5858
$this->assertNull($sn->typedSimpleArray[1]);
59-
$this->assertInstanceOf('DateTime', $sn->typedSimpleArray[2]);
59+
$this->assertInstanceOf(DateTime::class, $sn->typedSimpleArray[2]);
6060
$this->assertSame(
6161
'2014-01-02', $sn->typedSimpleArray[0]->format('Y-m-d')
6262
);
@@ -83,7 +83,7 @@ public function testMapArrayJsonNoTypeEnforcement()
8383
$jm = new JsonMapper();
8484
$jm->bEnforceMapType = false;
8585
$sn = $jm->map(array(), new JsonMapperTest_Simple());
86-
$this->assertInstanceOf('JsonMapperTest_Simple', $sn);
86+
$this->assertInstanceOf(JsonMapperTest_Simple::class, $sn);
8787
}
8888

8989
/**
@@ -148,7 +148,7 @@ public function testMapArrayObject()
148148
json_decode('{"pArrayObject":[{"str":"stringvalue"},{"fl":"1.2"}]}'),
149149
new JsonMapperTest_Array()
150150
);
151-
$this->assertInstanceOf('ArrayObject', $sn->pArrayObject);
151+
$this->assertInstanceOf(ArrayObject::class, $sn->pArrayObject);
152152
$this->assertCount(2, $sn->pArrayObject);
153153
$this->assertContainsOnlyInstancesOf(stdClass::class, $sn->pArrayObject);
154154
$this->assertSame('stringvalue', $sn->pArrayObject[0]->str);
@@ -167,7 +167,7 @@ public function testMapTypedArrayObject()
167167
),
168168
new JsonMapperTest_Array()
169169
);
170-
$this->assertInstanceOf('ArrayObject', $sn->pTypedArrayObject);
170+
$this->assertInstanceOf(ArrayObject::class, $sn->pTypedArrayObject);
171171
$this->assertCount(2, $sn->pTypedArrayObject);
172172
$this->assertContainsOnlyInstancesOf(JsonMapperTest_Simple::class, $sn->pTypedArrayObject);
173173
$this->assertSame('stringvalue', $sn->pTypedArrayObject[0]->str);
@@ -186,7 +186,7 @@ public function testMapSimpleArrayObject()
186186
),
187187
new JsonMapperTest_Array()
188188
);
189-
$this->assertInstanceOf('ArrayObject', $sn->pSimpleArrayObject);
189+
$this->assertInstanceOf(ArrayObject::class, $sn->pSimpleArrayObject);
190190
$this->assertCount(2, $sn->pSimpleArrayObject);
191191
$this->assertContainsOnly('int', $sn->pSimpleArrayObject, true);
192192
$this->assertSame(1, $sn->pSimpleArrayObject['eins']);
@@ -202,7 +202,7 @@ public function testMapSimpleArrayAccess()
202202
),
203203
new JsonMapperTest_Array()
204204
);
205-
$this->assertInstanceOf('ArrayAccess', $sn->pArrayAccessCollection);
205+
$this->assertInstanceOf(ArrayAccess::class, $sn->pArrayAccessCollection);
206206
$this->assertSame(1, $sn->pArrayAccessCollection['eins']);
207207
$this->assertSame('two', $sn->pArrayAccessCollection['zwei']);
208208
}
@@ -291,7 +291,7 @@ public function testMapTypedArrayObjectDoesNotExist()
291291
),
292292
new JsonMapperTest_Broken()
293293
);
294-
$this->assertInstanceOf('ArrayObject', $sn->pTypedArrayObjectNoClass);
294+
$this->assertInstanceOf(ArrayObject::class, $sn->pTypedArrayObjectNoClass);
295295
$this->assertCount(1, $sn->pTypedArrayObjectNoClass);
296296
$this->assertInstanceOf(
297297
'ThisClassDoesNotExist', $sn->pTypedArrayObjectNoClass[0]
@@ -389,7 +389,7 @@ public function testObjectMultiverse()
389389
$this->assertCount(1, $sn->pMultiverse[0][0]);
390390

391391
$this->assertInstanceOf(
392-
'JsonMapperTest_Simple', $sn->pMultiverse[0][0][0]
392+
JsonMapperTest_Simple::class, $sn->pMultiverse[0][0][0]
393393
);
394394
$this->assertSame(23, $sn->pMultiverse[0][0][0]->pint);
395395
}
@@ -434,7 +434,7 @@ public function testMapTypedSimpleArrayFromObject()
434434
$this->assertIsArray($sn->typedSimpleArray);
435435
$this->assertCount(1, $sn->typedSimpleArray);
436436
$this->assertArrayHasKey('en-US', $sn->typedSimpleArray);
437-
$this->assertInstanceOf('DateTime', $sn->typedSimpleArray['en-US']);
437+
$this->assertInstanceOf(DateTime::class, $sn->typedSimpleArray['en-US']);
438438
$this->assertSame(
439439
'2014-01-02', $sn->typedSimpleArray['en-US']->format('Y-m-d')
440440
);

tests/NamespaceTest.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ public function testMapArrayNamespace()
99
$mapper = new \JsonMapper();
1010
$json = '{"data":[{"value":"1.2"}]}';
1111
$res = $mapper->map(json_decode($json), new UnitData());
12-
$this->assertInstanceOf('\namespacetest\UnitData', $res);
13-
$this->assertInstanceOf('\namespacetest\Unit', $res->data[0]);
12+
$this->assertInstanceOf(\namespacetest\UnitData::class, $res);
13+
$this->assertInstanceOf(\namespacetest\Unit::class, $res->data[0]);
1414
}
1515

1616
public function testMapSimpleArrayNamespace()
1717
{
1818
$mapper = new \JsonMapper();
1919
$json = '{"units":[{"value":"1.2"}]}';
2020
$res = $mapper->map(json_decode($json), new UnitData());
21-
$this->assertInstanceOf('\namespacetest\UnitData', $res);
22-
$this->assertInstanceOf('\namespacetest\Unit', $res->units[0]);
21+
$this->assertInstanceOf(\namespacetest\UnitData::class, $res);
22+
$this->assertInstanceOf(\namespacetest\Unit::class, $res->units[0]);
2323
}
2424

2525
public function testMapSimpleStringArrayNamespace()
2626
{
2727
$mapper = new \JsonMapper();
2828
$json = '{"messages":["message 1", "message 2"]}';
2929
$res = $mapper->map(json_decode($json), new UnitData());
30-
$this->assertInstanceOf('\namespacetest\UnitData', $res);
30+
$this->assertInstanceOf(\namespacetest\UnitData::class, $res);
3131
$this->assertNotNull($res->messages);
3232
$this->assertCount(2, $res->messages);
3333
}
@@ -37,7 +37,7 @@ public function testMapMixed()
3737
$mapper = new \JsonMapper();
3838
$json = '{"mixed":true}';
3939
$res = $mapper->map(json_decode($json), new UnitData());
40-
$this->assertInstanceOf('\namespacetest\UnitData', $res);
40+
$this->assertInstanceOf(\namespacetest\UnitData::class, $res);
4141
$this->assertTrue($res->mixed);
4242
}
4343

@@ -46,17 +46,17 @@ public function testMapChildClassNamespace()
4646
$mapper = new \JsonMapper();
4747
$json = '{"user":{"name": "John Smith"}}';
4848
$res = $mapper->map(json_decode($json), new UnitData());
49-
$this->assertInstanceOf('\namespacetest\UnitData', $res);
50-
$this->assertInstanceOf('\namespacetest\model\User', $res->user);
49+
$this->assertInstanceOf(\namespacetest\UnitData::class, $res);
50+
$this->assertInstanceOf(\namespacetest\model\User::class, $res->user);
5151
}
5252

5353
public function testMapChildClassConstructorNamespace()
5454
{
5555
$mapper = new \JsonMapper();
5656
$json = '{"user":"John Smith"}';
5757
$res = $mapper->map(json_decode($json), new UnitData());
58-
$this->assertInstanceOf('\namespacetest\UnitData', $res);
59-
$this->assertInstanceOf('\namespacetest\model\User', $res->user);
58+
$this->assertInstanceOf(\namespacetest\UnitData::class, $res);
59+
$this->assertInstanceOf(\namespacetest\model\User::class, $res->user);
6060
}
6161

6262
public function testMapChildObjectArrayNamespace()
@@ -65,8 +65,8 @@ public function testMapChildObjectArrayNamespace()
6565
$json = '{"data":[],"user":{"name": "John Smith"}}';
6666
/* @var \namespacetest\UnitData $res */
6767
$res = $mapper->map(json_decode($json), new UnitData());
68-
$this->assertInstanceOf('\\ArrayObject', $res->data);
69-
$this->assertInstanceOf('\namespacetest\model\User', $res->user);
68+
$this->assertInstanceOf(\ArrayObject::class, $res->data);
69+
$this->assertInstanceOf(\namespacetest\model\User::class, $res->user);
7070
}
7171

7272
public function testMapEmpty()
@@ -84,18 +84,18 @@ public function testMapCustomArrayObjectWithChildType()
8484
$mapper = new \JsonMapper();
8585
$json = '{"users":[{"user":"John Smith"}]}';
8686
$res = $mapper->map(json_decode($json), new UnitData());
87-
$this->assertInstanceOf('\namespacetest\UnitData', $res);
88-
$this->assertInstanceOf('\namespacetest\model\UserList', $res->users);
89-
$this->assertInstanceOf('\namespacetest\model\User', $res->users[0]);
87+
$this->assertInstanceOf(\namespacetest\UnitData::class, $res);
88+
$this->assertInstanceOf(\namespacetest\model\UserList::class, $res->users);
89+
$this->assertInstanceOf(\namespacetest\model\User::class, $res->users[0]);
9090
}
9191

9292
public function testMapCustomArrayObject()
9393
{
9494
$mapper = new \JsonMapper();
9595
$json = '{"aodata":["foo"]}';
9696
$res = $mapper->map(json_decode($json), new UnitData());
97-
$this->assertInstanceOf('\namespacetest\UnitData', $res);
98-
$this->assertInstanceOf('\namespacetest\model\MyArrayObject', $res->aodata);
97+
$this->assertInstanceOf(\namespacetest\UnitData::class, $res);
98+
$this->assertInstanceOf(\namespacetest\model\MyArrayObject::class, $res->aodata);
9999
$this->assertSame('foo', $res->aodata[0]);
100100
}
101101

@@ -108,9 +108,9 @@ public function testSetterNamespacedTypeHint()
108108
$mapper = new \JsonMapper();
109109
$json = '{"namespacedTypeHint":"Foo"}';
110110
$res = $mapper->map(json_decode($json), new UnitData());
111-
$this->assertInstanceOf('\namespacetest\UnitData', $res);
111+
$this->assertInstanceOf(\namespacetest\UnitData::class, $res);
112112
$this->assertInstanceOf(
113-
'\othernamespace\Foo', $res->internalData['namespacedTypeHint']
113+
\othernamespace\Foo::class, $res->internalData['namespacedTypeHint']
114114
);
115115
$this->assertSame(
116116
'Foo', $res->internalData['namespacedTypeHint']->name

tests/ObjectTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testMapObject()
3333
new JsonMapperTest_Simple()
3434
);
3535
$this->assertIsObject($sn->simple);
36-
$this->assertInstanceOf('JsonMapperTest_Simple', $sn->simple);
36+
$this->assertInstanceOf(JsonMapperTest_Simple::class, $sn->simple);
3737
$this->assertSame('stringvalue', $sn->simple->str);
3838
}
3939

@@ -45,7 +45,7 @@ public function testMapObjectByClassName()
4545
JsonMapperTest_Simple::class
4646
);
4747
$this->assertIsObject($sn->simple);
48-
$this->assertInstanceOf('JsonMapperTest_Simple', $sn->simple);
48+
$this->assertInstanceOf(JsonMapperTest_Simple::class, $sn->simple);
4949
$this->assertSame('stringvalue', $sn->simple->str);
5050
}
5151

@@ -56,7 +56,7 @@ public function testMapDateTime()
5656
json_decode('{"datetime":"2014-04-01T00:00:00+02:00"}'),
5757
new JsonMapperTest_Object()
5858
);
59-
$this->assertInstanceOf('DateTime', $sn->datetime);
59+
$this->assertInstanceOf(DateTime::class, $sn->datetime);
6060
$this->assertSame(
6161
'2014-04-01T00:00:00+02:00',
6262
$sn->datetime->format('c')
@@ -111,7 +111,7 @@ public function testStrictTypeCheckingObject()
111111
);
112112

113113
$this->assertIsObject($sn->pPlainObject);
114-
$this->assertInstanceOf('JsonMapperTest_PlainObject', $sn->pPlainObject);
114+
$this->assertInstanceOf(JsonMapperTest_PlainObject::class, $sn->pPlainObject);
115115
$this->assertSame('abc', $sn->pPlainObject->pStr);
116116
}
117117

tests/OtherTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testMapOnlySetterTypeHint()
6666

6767
$this->assertIsObject($sn->internalData['typehint']);
6868
$this->assertInstanceOf(
69-
'JsonMapperTest_Simple', $sn->internalData['typehint']
69+
JsonMapperTest_Simple::class, $sn->internalData['typehint']
7070
);
7171
$this->assertSame(
7272
'stringvalue', $sn->internalData['typehint']->str
@@ -86,7 +86,7 @@ public function testMapOnlySetterDocblock()
8686
);
8787
$this->assertIsObject($sn->internalData['docblock']);
8888
$this->assertInstanceOf(
89-
'JsonMapperTest_Simple', $sn->internalData['docblock']
89+
JsonMapperTest_Simple::class, $sn->internalData['docblock']
9090
);
9191
$this->assertSame(
9292
'stringvalue', $sn->internalData['docblock']->str
@@ -105,7 +105,7 @@ public function testMapOnlySetterNoType()
105105
);
106106
$this->assertIsObject($sn->internalData['notype']);
107107
$this->assertInstanceOf(
108-
'stdClass', $sn->internalData['notype']
108+
stdClass::class, $sn->internalData['notype']
109109
);
110110
$this->assertSame(
111111
'stringvalue', $sn->internalData['notype']->str

0 commit comments

Comments
 (0)