Skip to content

Commit 9a296d7

Browse files
authored
Fix strlen null error in PHP 8.3 (#14)
* Check for null in resource ID before trying to get the string length. * Removing workflow (no phpunit tests).
1 parent 019977e commit 9a296d7

File tree

3 files changed

+8
-104
lines changed

3 files changed

+8
-104
lines changed

.changelogs/fix_php-83-warning.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
significance: patch
2+
type: fixed
3+
links:
4+
- "#13"
5+
attributions:
6+
- "@jv-mtrz"
7+
entry: Fixing null strlen error in PHP 8.3.

.github/workflows/test-phpunit.yml

Lines changed: 0 additions & 103 deletions
This file was deleted.

src/Commands/Restful/Runner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private static function get_supported_commands( $route, $route_data ) {
145145
$parsed_args = preg_match_all( '#\([^\)]+\)#', $route, $matches );
146146
$resource_id = ! empty( $matches[0] ) ? array_pop( $matches[0] ) : null;
147147
$trimmed_route = rtrim( $route );
148-
$is_singular = $resource_id === substr( $trimmed_route, - strlen( $resource_id ) );
148+
$is_singular = $resource_id === substr( $trimmed_route, - strlen( $resource_id ?? '' ) );
149149

150150
// List a collection
151151
if ( array( 'GET' ) == $endpoint['methods']

0 commit comments

Comments
 (0)