@@ -73,7 +73,7 @@ public function authorize(mixed $resource, ?string $action = null): void
7373 }
7474
7575 if (is_object ($ resource )) {
76- $ name = get_class ( $ resource) ;
76+ $ name = $ resource::class ;
7777 } elseif (is_string ($ resource )) {
7878 $ name = $ resource ;
7979 } else {
@@ -131,7 +131,7 @@ protected function performCheck(
131131 }
132132
133133 $ identity = $ this ->getIdentity ($ request );
134- if ($ identity === null ) {
134+ if (! $ identity instanceof IdentityInterface ) {
135135 return $ this ->getService ($ request )->{$ method }(null , $ action , $ resource );
136136 }
137137
@@ -156,7 +156,7 @@ public function applyScope(mixed $resource, ?string $action = null, mixed ...$op
156156 $ action = $ this ->getDefaultAction ($ request );
157157 }
158158 $ identity = $ this ->getIdentity ($ request );
159- if ($ identity === null ) {
159+ if (! $ identity instanceof IdentityInterface ) {
160160 return $ this ->getService ($ request )->applyScope (null , $ action , $ resource );
161161 }
162162
@@ -233,7 +233,7 @@ protected function getService(ServerRequestInterface $request): AuthorizationSer
233233 $ serviceAttribute = $ this ->getConfig ('serviceAttribute ' );
234234 $ service = $ request ->getAttribute ($ serviceAttribute );
235235 if (!$ service instanceof AuthorizationServiceInterface) {
236- $ type = is_object ( $ service ) ? get_class ( $ service ) : gettype ($ service );
236+ $ type = get_debug_type ($ service );
237237 throw new InvalidArgumentException (sprintf (
238238 'Expected that `%s` would be an instance of %s, but got %s ' ,
239239 $ serviceAttribute ,
@@ -261,7 +261,7 @@ protected function getIdentity(ServerRequestInterface $request): ?IdentityInterf
261261 return $ identity ;
262262 }
263263 if (!$ identity instanceof IdentityInterface) {
264- $ type = is_object ( $ identity ) ? get_class ( $ identity ) : gettype ($ identity );
264+ $ type = get_debug_type ($ identity );
265265 throw new InvalidArgumentException (sprintf (
266266 'Expected that `%s` would be an instance of %s, but got %s ' ,
267267 $ identityAttribute ,
@@ -328,7 +328,7 @@ protected function getDefaultAction(ServerRequest $request): string
328328 return $ action ;
329329 }
330330 if (!is_string ($ name )) {
331- $ type = is_object ( $ name ) ? get_class ( $ name ) : gettype ($ name );
331+ $ type = get_debug_type ($ name );
332332 $ message = sprintf ('Invalid action type for `%s`. Expected `string` or `null`, got `%s`. ' , $ action , $ type );
333333 throw new UnexpectedValueException ($ message );
334334 }
0 commit comments