Skip to content

Commit b8b4902

Browse files
Leverage PHP8's get_debug_type()
1 parent 9fd6923 commit b8b4902

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

MarkingStore/MethodMarkingStore.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getMarking(object $subject): Marking
5151
$method = 'get'.ucfirst($this->property);
5252

5353
if (!method_exists($subject, $method)) {
54-
throw new LogicException(sprintf('The method "%s::%s()" does not exist.', \get_class($subject), $method));
54+
throw new LogicException(sprintf('The method "%s::%s()" does not exist.', get_debug_type($subject), $method));
5555
}
5656

5757
$marking = $subject->{$method}();
@@ -81,7 +81,7 @@ public function setMarking(object $subject, Marking $marking, array $context = [
8181
$method = 'set'.ucfirst($this->property);
8282

8383
if (!method_exists($subject, $method)) {
84-
throw new LogicException(sprintf('The method "%s::%s()" does not exist.', \get_class($subject), $method));
84+
throw new LogicException(sprintf('The method "%s::%s()" does not exist.', get_debug_type($subject), $method));
8585
}
8686

8787
$subject->{$method}($marking, $context);

Metadata/GetMetadataTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public function getMetadata(string $key, $subject = null)
4343
return $metadataBag[$key] ?? null;
4444
}
4545

46-
throw new InvalidArgumentException(sprintf('Could not find a MetadataBag for the subject of type "%s".', \is_object($subject) ? \get_class($subject) : \gettype($subject)));
46+
throw new InvalidArgumentException(sprintf('Could not find a MetadataBag for the subject of type "%s".', get_debug_type($subject)));
4747
}
4848
}

Registry.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ public function get(object $subject, string $workflowName = null)
5252
}
5353

5454
if (!$matched) {
55-
throw new InvalidArgumentException(sprintf('Unable to find a workflow for class "%s".', \get_class($subject)));
55+
throw new InvalidArgumentException(sprintf('Unable to find a workflow for class "%s".', get_debug_type($subject)));
5656
}
5757

5858
if (2 <= \count($matched)) {
5959
$names = array_map(static function (WorkflowInterface $workflow): string {
6060
return $workflow->getName();
6161
}, $matched);
6262

63-
throw new InvalidArgumentException(sprintf('Too many workflows (%s) match this subject (%s); set a different name on each and use the second (name) argument of this method.', implode(', ', $names), \get_class($subject)));
63+
throw new InvalidArgumentException(sprintf('Too many workflows (%s) match this subject (%s); set a different name on each and use the second (name) argument of this method.', implode(', ', $names), get_debug_type($subject)));
6464
}
6565

6666
return $matched[0];

Tests/Metadata/InMemoryMetadataStoreTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testGetMetadata()
7878
public function testGetMetadataWithUnknownType()
7979
{
8080
$this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException');
81-
$this->expectExceptionMessage('Could not find a MetadataBag for the subject of type "boolean".');
81+
$this->expectExceptionMessage('Could not find a MetadataBag for the subject of type "bool".');
8282
$this->store->getMetadata('title', true);
8383
}
8484
}

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^7.2.5"
23+
"php": "^7.2.5",
24+
"symfony/polyfill-php80": "^1.15"
2425
},
2526
"require-dev": {
2627
"psr/log": "~1.0",

0 commit comments

Comments
 (0)