Merge branch '2.7' into 2.8
* 2.7: Minor fixes & cleanups
This commit is contained in:
commit
7f56c22076
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,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']);
|
||||
@ -228,21 +229,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
Block a user