+ $expectMethod = <<<'EOS'
+ > 19| public function someMethod($someParam)
+ 20| {
+ 21| return 'some method';
+ 22| }
+EOS;
+
+ $expectClosure = <<<'EOS'
+ > 26| return function () {
+ 27| return 'some closure';
+ 28| };
+EOS;
+
+ return [
+ [new \ReflectionClass('Psy\Test\Formatter\Fixtures\SomeClass'), $expectClass],
+ [new \ReflectionObject(new SomeClass()), $expectClass],
+ [new \ReflectionMethod('Psy\Test\Formatter\Fixtures\SomeClass', 'someMethod'), $expectMethod],
+ [new \ReflectionFunction(SomeClass::someClosure()), $expectClosure],
+ ];
+ }
+
+ /**
+ * @dataProvider invalidReflectors
+ * @expectedException \Psy\Exception\RuntimeException
+ */
+ public function testCodeFormatterThrowsExceptionForReflectorsItDoesntUnderstand($reflector)
+ {
+ CodeFormatter::format($reflector);
+ }
+
+ public function invalidReflectors()
+ {
+ $reflectors = [
+ [new \ReflectionExtension('json')],
+ [new \ReflectionParameter(['Psy\Test\Formatter\Fixtures\SomeClass', 'someMethod'], 'someParam')],
+ [new \ReflectionProperty('Psy\Test\Formatter\Fixtures\SomeClass', 'someProp')],
+ ];
+
+ if (version_compare(PHP_VERSION, '7.1.0', '>=')) {
+ $reflectors[] = [new \ReflectionClassConstant('Psy\Test\Formatter\Fixtures\SomeClass', 'SOME_CONST')];
+ }