Minor fixes & cleanups
This commit is contained in:
parent
a5a91a7fa1
commit
dcf601f3fa
|
@ -216,10 +216,10 @@ class JsonResponseTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testSetComplexCallback()
|
||||
{
|
||||
$response = JsonResponse::fromJsonString('{foo: "bar"}');
|
||||
$response = JsonResponse::create(array('foo' => 'bar'));
|
||||
$response->setCallback('ಠ_ಠ["foo"].bar[0]');
|
||||
|
||||
$this->assertEquals('/**/ಠ_ಠ["foo"].bar[0]({foo: "bar"});', $response->getContent());
|
||||
$this->assertEquals('/**/ಠ_ಠ["foo"].bar[0]({"foo":"bar"});', $response->getContent());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,8 @@ class ReflectionCaster
|
|||
|
||||
if (isset($a[$prefix.'returnType'])) {
|
||||
$v = $a[$prefix.'returnType'];
|
||||
$a[$prefix.'returnType'] = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString();
|
||||
$v = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString();
|
||||
$a[$prefix.'returnType'] = $a[$prefix.'returnType']->allowsNull() ? '?'.$v : $v;
|
||||
}
|
||||
if (isset($a[$prefix.'this'])) {
|
||||
$a[$prefix.'this'] = new CutStub($a[$prefix.'this']);
|
||||
|
@ -168,21 +169,12 @@ class ReflectionCaster
|
|||
'allowsNull' => 'allowsNull',
|
||||
));
|
||||
|
||||
try {
|
||||
if (method_exists($c, 'getType')) {
|
||||
if ($v = $c->getType()) {
|
||||
$a[$prefix.'typeHint'] = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString();
|
||||
}
|
||||
} else {
|
||||
$v = explode(' ', $c->__toString(), 6);
|
||||
if (isset($v[5]) && 0 === strspn($v[4], '.&$')) {
|
||||
$a[$prefix.'typeHint'] = $v[4];
|
||||
}
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
if (preg_match('/^Class ([^ ]++) does not exist$/', $e->getMessage(), $m)) {
|
||||
$a[$prefix.'typeHint'] = $m[1];
|
||||
if (method_exists($c, 'getType')) {
|
||||
if ($v = $c->getType()) {
|
||||
$a[$prefix.'typeHint'] = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString();
|
||||
}
|
||||
} elseif (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $c, $v)) {
|
||||
$a[$prefix.'typeHint'] = $v[1];
|
||||
}
|
||||
if (!isset($a[$prefix.'typeHint'])) {
|
||||
unset($a[$prefix.'allowsNull']);
|
||||
|
|
Reference in New Issue