We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | 'name' => $name, |
| 35 | 35 | 'description' => 'The ID of an object', |
| 36 | 36 | 'type' => Type::nonNull(Type::id()), |
| 37 | - 'resolve' => function ($obj, $args, ResolveInfo $info) use ($idFetcher, $typeName) { |
|
| 37 | + 'resolve' => function($obj, $args, ResolveInfo $info) use ($idFetcher, $typeName) { |
|
| 38 | 38 | return GlobalId::toGlobalId( |
| 39 | 39 | !empty($typeName) ? $typeName : $info->parentType->name, |
| 40 | 40 | is_callable($idFetcher) ? call_user_func_array($idFetcher, [$obj, $info]) : (is_object($obj) ? $obj->id : $obj['id']) |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | 'name' => $name, |
| 33 | 33 | 'description' => 'The raw ID of an object', |
| 34 | 34 | 'type' => Type::nonNull(Type::int()), |
| 35 | - 'resolve' => function ($obj, $args, ResolveInfo $info) use ($idFetcher) { |
|
| 35 | + 'resolve' => function($obj, $args, ResolveInfo $info) use ($idFetcher) { |
|
| 36 | 36 | return is_callable($idFetcher) ? $idFetcher($obj, $info) : $obj->id; |
| 37 | 37 | }, |
| 38 | 38 | ]; |
@@ -13,6 +13,9 @@ |
||
| 13 | 13 | |
| 14 | 14 | trait DIContainerMockTrait |
| 15 | 15 | { |
| 16 | + /** |
|
| 17 | + * @return null|\Symfony\Component\DependencyInjection\ContainerInterface |
|
| 18 | + */ |
|
| 16 | 19 | private function getDIContainerMock(array $services = [], array $parameters = []) |
| 17 | 20 | { |
| 18 | 21 | $container = $this->getMock('Symfony\\Component\\DependencyInjection\\Container', ['get', 'getParameter', 'has']); |
@@ -20,37 +20,37 @@ |
||
| 20 | 20 | public function getFunctions() |
| 21 | 21 | { |
| 22 | 22 | return [ |
| 23 | - new ExpressionFunction('service', function () {}, function (array $variables, $value) { |
|
| 23 | + new ExpressionFunction('service', function() {}, function(array $variables, $value) { |
|
| 24 | 24 | return $variables['container']->get($value); |
| 25 | 25 | }), |
| 26 | 26 | |
| 27 | - new ExpressionFunction('parameter', function () {}, function (array $variables, $value) { |
|
| 27 | + new ExpressionFunction('parameter', function() {}, function(array $variables, $value) { |
|
| 28 | 28 | return $variables['container']->getParameter($value); |
| 29 | 29 | }), |
| 30 | 30 | |
| 31 | - new ExpressionFunction('isTypeOf', function () {}, function (array $variables, $className) { |
|
| 31 | + new ExpressionFunction('isTypeOf', function() {}, function(array $variables, $className) { |
|
| 32 | 32 | return $variables['value'] instanceof $className; |
| 33 | 33 | }), |
| 34 | 34 | |
| 35 | - new ExpressionFunction('resolver', function () {}, function (array $variables, $alias, array $args = []) { |
|
| 35 | + new ExpressionFunction('resolver', function() {}, function(array $variables, $alias, array $args = []) { |
|
| 36 | 36 | return $variables['container']->get('overblog_graphql.resolver_resolver')->resolve([$alias, $args]); |
| 37 | 37 | }), |
| 38 | 38 | |
| 39 | - new ExpressionFunction('mutation', function () {}, function (array $variables, $alias, array $args = []) { |
|
| 39 | + new ExpressionFunction('mutation', function() {}, function(array $variables, $alias, array $args = []) { |
|
| 40 | 40 | return $variables['container']->get('overblog_graphql.mutation_resolver')->resolve([$alias, $args]); |
| 41 | 41 | }), |
| 42 | 42 | |
| 43 | - new ExpressionFunction('globalId', function () {}, function (array $variables, $id, $typeName = null) { |
|
| 43 | + new ExpressionFunction('globalId', function() {}, function(array $variables, $id, $typeName = null) { |
|
| 44 | 44 | $type = !empty($typeName) ? $typeName : $variables['info']->parentType->name; |
| 45 | 45 | |
| 46 | 46 | return GlobalId::toGlobalId($type, $id); |
| 47 | 47 | }), |
| 48 | 48 | |
| 49 | - new ExpressionFunction('fromGlobalId', function () {}, function (array $variables, $globalId) { |
|
| 49 | + new ExpressionFunction('fromGlobalId', function() {}, function(array $variables, $globalId) { |
|
| 50 | 50 | return GlobalId::fromGlobalId($globalId); |
| 51 | 51 | }), |
| 52 | 52 | |
| 53 | - new ExpressionFunction('newObject', function () {}, function (array $variables, $className, array $args = []) { |
|
| 53 | + new ExpressionFunction('newObject', function() {}, function(array $variables, $className, array $args = []) { |
|
| 54 | 54 | return (new \ReflectionClass($className))->newInstanceArgs($args); |
| 55 | 55 | }), |
| 56 | 56 | ]; |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | public function getFunctions() |
| 20 | 20 | { |
| 21 | 21 | return [ |
| 22 | - new ExpressionFunction('hasRole', function () {}, function (array $variables, $role) { |
|
| 22 | + new ExpressionFunction('hasRole', function() {}, function(array $variables, $role) { |
|
| 23 | 23 | return $variables['container']->get('security.authorization_checker')->isGranted($role); |
| 24 | 24 | }), |
| 25 | 25 | |
| 26 | - new ExpressionFunction('hasAnyRole', function () {}, function (array $variables, array $roles) { |
|
| 26 | + new ExpressionFunction('hasAnyRole', function() {}, function(array $variables, array $roles) { |
|
| 27 | 27 | foreach ($roles as $role) { |
| 28 | 28 | if ($variables['container']->get('security.authorization_checker')->isGranted($role)) { |
| 29 | 29 | return true; |
@@ -33,29 +33,29 @@ discard block |
||
| 33 | 33 | return false; |
| 34 | 34 | }), |
| 35 | 35 | |
| 36 | - new ExpressionFunction('isAnonymous', function () {}, function (array $variables) { |
|
| 36 | + new ExpressionFunction('isAnonymous', function() {}, function(array $variables) { |
|
| 37 | 37 | return $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_ANONYMOUSLY'); |
| 38 | 38 | }), |
| 39 | 39 | |
| 40 | - new ExpressionFunction('isRememberMe', function () {}, function (array $variables) { |
|
| 40 | + new ExpressionFunction('isRememberMe', function() {}, function(array $variables) { |
|
| 41 | 41 | return $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED'); |
| 42 | 42 | }), |
| 43 | 43 | |
| 44 | - new ExpressionFunction('isFullyAuthenticated', function () {}, function (array $variables) { |
|
| 44 | + new ExpressionFunction('isFullyAuthenticated', function() {}, function(array $variables) { |
|
| 45 | 45 | return $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY'); |
| 46 | 46 | }), |
| 47 | 47 | |
| 48 | - new ExpressionFunction('isAuthenticated', function () {}, function (array $variables) { |
|
| 48 | + new ExpressionFunction('isAuthenticated', function() {}, function(array $variables) { |
|
| 49 | 49 | return |
| 50 | 50 | $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED') |
| 51 | 51 | || $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY'); |
| 52 | 52 | }), |
| 53 | 53 | |
| 54 | - new ExpressionFunction('hasPermission', function () {}, function (array $variables, $object, $permission) { |
|
| 54 | + new ExpressionFunction('hasPermission', function() {}, function(array $variables, $object, $permission) { |
|
| 55 | 55 | return $variables['container']->get('security.authorization_checker')->isGranted($permission, $object); |
| 56 | 56 | }), |
| 57 | 57 | |
| 58 | - new ExpressionFunction('hasAnyPermission', function () {}, function (array $variables, $object, array $permissions) { |
|
| 58 | + new ExpressionFunction('hasAnyPermission', function() {}, function(array $variables, $object, array $permissions) { |
|
| 59 | 59 | foreach ($permissions as $permission) { |
| 60 | 60 | if ($variables['container']->get('security.authorization_checker')->isGranted($permission, $object)) { |
| 61 | 61 | return true; |
@@ -247,6 +247,9 @@ discard block |
||
| 247 | 247 | return $type; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | + /** |
|
| 251 | + * @param callable $expression |
|
| 252 | + */ |
|
| 250 | 253 | private function resolveAccessAndWrapResolveCallback($expression, callable $resolveCallback = null) |
| 251 | 254 | { |
| 252 | 255 | return function () use ($expression, $resolveCallback) { |
@@ -277,6 +280,10 @@ discard block |
||
| 277 | 280 | case is_array($result) || $result instanceof \ArrayAccess: |
| 278 | 281 | $result = array_filter( |
| 279 | 282 | array_map( |
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * @param callable $object |
|
| 286 | + */ |
|
| 280 | 287 | function ($object) use ($checkAccess) { |
| 281 | 288 | return $checkAccess($object) ? $object : null; |
| 282 | 289 | }, |
@@ -287,6 +294,10 @@ discard block |
||
| 287 | 294 | |
| 288 | 295 | case $result instanceof Connection: |
| 289 | 296 | $result->edges = array_map( |
| 297 | + |
|
| 298 | + /** |
|
| 299 | + * @param callable $edge |
|
| 300 | + */ |
|
| 290 | 301 | function (Edge $edge) use ($checkAccess) { |
| 291 | 302 | $edge->node = $checkAccess($edge->node) ? $edge->node : null; |
| 292 | 303 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | private function resolveTypeCallback($expr) |
| 215 | 215 | { |
| 216 | - return function () use ($expr) { |
|
| 216 | + return function() use ($expr) { |
|
| 217 | 217 | return $this->resolveType($expr); |
| 218 | 218 | }; |
| 219 | 219 | } |
@@ -249,14 +249,14 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | private function resolveAccessAndWrapResolveCallback($expression, callable $resolveCallback = null) |
| 251 | 251 | { |
| 252 | - return function () use ($expression, $resolveCallback) { |
|
| 252 | + return function() use ($expression, $resolveCallback) { |
|
| 253 | 253 | $args = func_get_args(); |
| 254 | 254 | |
| 255 | - $result = null !== $resolveCallback ? call_user_func_array($resolveCallback, $args) : null; |
|
| 255 | + $result = null !== $resolveCallback ? call_user_func_array($resolveCallback, $args) : null; |
|
| 256 | 256 | |
| 257 | 257 | $values = call_user_func_array([$this, 'resolveResolveCallbackArgs'], $args); |
| 258 | 258 | |
| 259 | - $checkAccess = function ($object, $throwException = false) use ($expression, $values) { |
|
| 259 | + $checkAccess = function($object, $throwException = false) use ($expression, $values) { |
|
| 260 | 260 | try { |
| 261 | 261 | $access = $this->resolveUsingExpressionLanguageIfNeeded( |
| 262 | 262 | $expression, |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | case is_array($result) || $result instanceof \ArrayAccess: |
| 278 | 278 | $result = array_filter( |
| 279 | 279 | array_map( |
| 280 | - function ($object) use ($checkAccess) { |
|
| 280 | + function($object) use ($checkAccess) { |
|
| 281 | 281 | return $checkAccess($object) ? $object : null; |
| 282 | 282 | }, |
| 283 | 283 | $result |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | case $result instanceof Connection: |
| 289 | 289 | $result->edges = array_map( |
| 290 | - function (Edge $edge) use ($checkAccess) { |
|
| 290 | + function(Edge $edge) use ($checkAccess) { |
|
| 291 | 291 | $edge->node = $checkAccess($edge->node) ? $edge->node : null; |
| 292 | 292 | |
| 293 | 293 | return $edge; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | return $value; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - return function () use ($value) { |
|
| 314 | + return function() use ($value) { |
|
| 315 | 315 | $args = func_get_args(); |
| 316 | 316 | $result = $this->resolveUsingExpressionLanguageIfNeeded( |
| 317 | 317 | $value, |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | private function resolveUsingExpressionLanguageIfNeeded($expression, array $values = []) |
| 362 | 362 | { |
| 363 | - if (is_string($expression) && 0 === strpos($expression, '@=')) { |
|
| 363 | + if (is_string($expression) && 0 === strpos($expression, '@=')) { |
|
| 364 | 364 | return $this->expressionLanguage->evaluate(substr($expression, 2), $values); |
| 365 | 365 | } |
| 366 | 366 | |
@@ -163,7 +163,7 @@ |
||
| 163 | 163 | private function invokeResolveAccessAndWrapResolveCallback($hasAccess, callable $callback = null) |
| 164 | 164 | { |
| 165 | 165 | if (null === $callback) { |
| 166 | - $callback = function ($value) { |
|
| 166 | + $callback = function($value) { |
|
| 167 | 167 | return $value; |
| 168 | 168 | }; |
| 169 | 169 | } |
@@ -183,7 +183,7 @@ |
||
| 183 | 183 | * |
| 184 | 184 | * @see https://jtreminio.com/2013/03/unit-testing-tutorial-part-3-testing-protected-private-methods-coverage-reports-and-crap/ |
| 185 | 185 | * |
| 186 | - * @param object $object Instantiated object that we will run method on. |
|
| 186 | + * @param ConfigResolver $object Instantiated object that we will run method on. |
|
| 187 | 187 | * @param string $methodName Method name to call |
| 188 | 188 | * @param array $parameters Array of parameters to pass into method. |
| 189 | 189 | * |
@@ -15,7 +15,6 @@ |
||
| 15 | 15 | use Overblog\GraphQLBundle\Relay\Connection\Output\ConnectionBuilder; |
| 16 | 16 | use Overblog\GraphQLBundle\Resolver\ConfigResolver; |
| 17 | 17 | use Overblog\GraphQLBundle\Tests\DIContainerMockTrait; |
| 18 | -use Symfony\Component\ExpressionLanguage\Expression; |
|
| 19 | 18 | |
| 20 | 19 | class ConfigResolverTest extends \PHPUnit_Framework_TestCase |
| 21 | 20 | { |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | public function setUp() |
| 32 | 32 | { |
| 33 | - $this->closureProperty = function () { |
|
| 33 | + $this->closureProperty = function() { |
|
| 34 | 34 | return $this->privatePropertyWithoutGetter; |
| 35 | 35 | }; |
| 36 | 36 | } |