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

Library does not depend on specific http client implementation (PSR-18) #79

Closed

Conversation

mateuszsip
Copy link

Hi.
As discussed in #78 PR introduces PSR-18 to this library.

Had to rewrite a lot of stuff to do this, and I am not sure if you'll like it :)
Would love to head what do you think, then we can discuss it and work something out :)

I changed how executors work, introduced request/response builders, managed to get rid of internal request/response implementations.

Unit tests pass, but I couldn't test integration with real service.

TODO:

  • use some tooling to make codestyle consistent (php-cs-fixer?)
  • new infrastructure implementation tests

@maciejlew maciejlew self-requested a review October 2, 2018 06:37
Copy link
Collaborator

@maciejlew maciejlew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bug that causes integration tests to fail. Try to run them, even providing invalid access token, you will see.

You also made a requirements conflict - we still have to support 7.0 for some time.

While working on library we made a decision to mark all non api methods and classes as internal using '@internal' class annotation. Try to fix this and avoid final class keyword.

For more details see code comments.

composer.json Outdated Show resolved Hide resolved
src/Infrastructure/Request/LegacyRequestBuilderFactory.php Outdated Show resolved Hide resolved
$this->uriFactory = $uriFactory;
$this->streamFactory = $streamFactory;

$this->method = RequestMethodInterface::METHOD_GET;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name it and move to 'defaults' method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate? This is default state, you want to have no default state and move initialization to separate defaults method?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep that default state but name it by extracting to method.

src/SmsapiHttpClient.php Outdated Show resolved Hide resolved
src/Infrastructure/Request/RequestBuilderFactory.php Outdated Show resolved Hide resolved
tests/SmsapiClientIntegrationTestCase.php Outdated Show resolved Hide resolved
"dealerdirect/phpcodesniffer-composer-installer": "^0.4"
"dealerdirect/phpcodesniffer-composer-installer": "^0.4",
"php-http/httplug": "2.x-dev@dev",
"php-http/guzzle6-adapter": "dev-patch-psr18@dev",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this package requires php 7.1 (check Travis output for this PR). This client has to provide support for php 7.0 also. It there a way to test it with 7.0?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to think about. This is only for tests, so maybe I can prepare a PR for adapter supporting 7.0 so we can use it instead?

I guess you have a good reason to support 7.0 because it's reaching EOL soon.

I totally missed that during development.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like guzzle itself will end with php 7.0 support, but PR is very wip: https://github.com/guzzle/guzzle/pull/2122/files

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but supporting 7.0 is our bussiness requirement.

@maciejlew
Copy link
Collaborator

maciejlew commented Oct 31, 2018

It seems like you disable proxy feature, see SmsapiClient::setProxy.

@mateuszsip
Copy link
Author

Yes - this is implementation-specific so it would make sense to tell users how to setup proxy with implementation of choice.

Now I'm thinking abbout logging - this should be also something that users handle on their side by decorating client (exactly the same way this is currently implemented, by outside of this lib) - of course we can provide decorator and tell them how to use it. WDYT?

I will rebase this PR in the following days.

@maciejlew
Copy link
Collaborator

Split this PR into smaller chunks. Separate PSR-18 changes from other changes (i.e. HTTP statuses and methods). That will make that PRs more suitable for next reviews. 80+ files to check is really a challenge.

@maciejlew maciejlew closed this Jan 3, 2019
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.

None yet

2 participants