diff --git a/src/Util/ClassSourceManipulator.php b/src/Util/ClassSourceManipulator.php index 69e26765a..045ad25df 100644 --- a/src/Util/ClassSourceManipulator.php +++ b/src/Util/ClassSourceManipulator.php @@ -253,8 +253,7 @@ public function addAccessorMethod(string $propertyName, string $methodName, $ret public function addGetter(string $propertyName, $returnType, bool $isReturnTypeNullable, array $commentLines = []): void { - $methodName = 'get'.Str::asCamelCase($propertyName); - + $methodName = ('bool' === $returnType ? 'is' : 'get').Str::asCamelCase($propertyName); $this->addCustomGetter($propertyName, $methodName, $returnType, $isReturnTypeNullable, $commentLines); } diff --git a/tests/Util/ClassSourceManipulatorTest.php b/tests/Util/ClassSourceManipulatorTest.php index 732261026..cc072bf44 100644 --- a/tests/Util/ClassSourceManipulatorTest.php +++ b/tests/Util/ClassSourceManipulatorTest.php @@ -100,6 +100,14 @@ public function getAddGetterTests() 'User_simple.php', ]; + yield 'normal_getter_add_bool' => [ + 'legacy/User_simple.php', + 'fooProp', + 'bool', + [], + 'User_simple_bool.php', + ]; + yield 'getter_no_props_comments' => [ 'User_no_props.php', 'fooProp', diff --git a/tests/Util/fixtures/add_getter/User_simple_bool.php b/tests/Util/fixtures/add_getter/User_simple_bool.php new file mode 100644 index 000000000..1b0eb7c41 --- /dev/null +++ b/tests/Util/fixtures/add_getter/User_simple_bool.php @@ -0,0 +1,28 @@ +id; + } + + public function isFooProp(): ?bool + { + return $this->fooProp; + } +}