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

fix: declaration for provider name #105

Merged

Conversation

apodgorbunschih
Copy link
Contributor

The implementation is not fulfilling the abstraction definition:
https://github.com/open-feature/php-sdk/blob/4e25be68937dc4ec405366cb6ba726f66fc0e5c8/src/implementation/provider/AbstractProvider.php#L19

protected static string $NAME = 'AbstractProvider';

The implementation is pointing not to a property but to a constant.

protected const NAME = 'SplitProvider';

This is leading to getMetadata method in the implementation to return all the time "AbstractProvider" value

Reproducing the issues:

<?php
abstract class AbstractProvider {
  protected static string $NAME = 'AbstractProvider';
  
  public function getMetadata()
  {
      return static::$NAME;
  }
}

class SplitProvider extends AbstractProvider
{
    protected const NAME = 'SplitProvider';
}

class FlagdProvider extends AbstractProvider
{
    protected const NAME = 'FlagdProvider';
}

$splitProvider = new SplitProvider();
var_dump($splitProvider->getMetadata());


$flagDProvider = new FlagdProvider();
var_dump($flagDProvider->getMetadata());
?>

@apodgorbunschih apodgorbunschih force-pushed the fix/declaration-name-for-providers branch 3 times, most recently from 1c4ab9a to 6f7466c Compare August 1, 2024 08:03
Signed-off-by: Alex Podgorbunschih <[email protected]>
@apodgorbunschih apodgorbunschih force-pushed the fix/declaration-name-for-providers branch from 6f7466c to e5da0dc Compare August 1, 2024 08:05
@apodgorbunschih apodgorbunschih requested a review from aepfli August 2, 2024 07:48
@tcarrio
Copy link
Member

tcarrio commented Aug 5, 2024

This looks good to me, the lazy static binding was merged in the php-sdk but these weren't updated with it.

Thank you @apodgorbunschih!

If the tests for the providers don't cover this already, it will be a good follow-up to ensure it doesn't break again

@apodgorbunschih
Copy link
Contributor Author

@tcarrio Thanks a lot. Let me add the test in this MR, so we will be sure that is returning the correct value 👍

@apodgorbunschih apodgorbunschih force-pushed the fix/declaration-name-for-providers branch from 3230b09 to b23a51a Compare August 5, 2024 07:28
@apodgorbunschih apodgorbunschih force-pushed the fix/declaration-name-for-providers branch from b23a51a to ee7eb2e Compare August 5, 2024 08:22
@beeme1mr beeme1mr merged commit 42919fd into open-feature:main Aug 5, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants