Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept underscores in getter / setter methods #526

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading