Skip to content

Commit

Permalink
Accept underscores in getter / setter methods
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Jun 11, 2024
1 parent ae2a668 commit 682ca15
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Regenerate classes:
./vendor/bin/soap-client generate:clientfactory --config=config/soap-client.php
```

**Note:** The generated code might have slightly changed for your project.
Validate if you are still using the correct methods in your implementation.

Change the engine inside your (generated) ClientFactory:

```php
Expand Down
8 changes: 4 additions & 4 deletions spec/Phpro/SoapClient/CodeGenerator/Util/NormalizerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ function it_generates_property_methods()
{
$this->generatePropertyMethod('get', 'prop1')->shouldReturn('getProp1');
$this->generatePropertyMethod('set', 'prop1')->shouldReturn('setProp1');
$this->generatePropertyMethod('get', 'prop1_test*./')->shouldReturn('getProp1Test');
$this->generatePropertyMethod('get', 'prop1_test*./')->shouldReturn('getProp1_test');
$this->generatePropertyMethod('get', 'UpperCased')->shouldReturn('getUpperCased');
$this->generatePropertyMethod('get', 'my-./*prop_123')->shouldReturn('getMyProp123');
$this->generatePropertyMethod('get', 'My-./*prop_123')->shouldReturn('getMyProp123');
$this->generatePropertyMethod('get', 'My-./final*prop_123')->shouldReturn('getMyFinalProp123');
$this->generatePropertyMethod('get', 'my-./*prop_123')->shouldReturn('getMyProp_123');
$this->generatePropertyMethod('get', 'My-./*prop_123')->shouldReturn('getMyProp_123');
$this->generatePropertyMethod('get', 'My-./final*prop_123')->shouldReturn('getMyFinalProp_123');
$this->generatePropertyMethod('get', 'final')->shouldReturn('getFinal');
$this->generatePropertyMethod('set', 'Final')->shouldReturn('setFinal');
$this->generatePropertyMethod('set', '_')->shouldReturn('set_');
Expand Down
2 changes: 1 addition & 1 deletion src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public static function isKnownType(string $type): bool
*/
public static function generatePropertyMethod(string $prefix, string $property): string
{
$normalized = $property === '_' ? $property : self::camelCase($property, '{[^a-z0-9]+}i');
$normalized = $property === '_' ? $property : self::camelCase($property, '{[^a-z0-9_]+}i');

return strtolower($prefix).ucfirst($normalized);
}
Expand Down

0 comments on commit 682ca15

Please sign in to comment.