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

Replace HTTP Factory class #141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jakubpilaralmamedia
Copy link

@jakubpilaralmamedia jakubpilaralmamedia commented Jan 4, 2024

Fix: Package php-http/message-factory is abandoned, you should avoid using it. Use psr/http-factory instead.

composer.json Outdated Show resolved Hide resolved
composer.json Outdated
"psr/http-message": "^1.0",
"ramsey/uuid": "^3.7 || ^4.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.4",
"lmc/coding-standard": "^1.3 || ^2.0",
"http-interop/http-factory-guzzle": "^1.2",

Choose a reason for hiding this comment

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

Shouldn't be required oldest possible version with needed features?

Suggested change
"http-interop/http-factory-guzzle": "^1.2",
"http-interop/http-factory-guzzle": "^1.0",

I'm affraid that ^1.2 could be problem if some projects use 1.1.x or 1.0.x versions.

src/Matej.php Show resolved Hide resolved
CHANGELOG.md Outdated
@@ -5,6 +5,9 @@
<!-- There is always Unreleased section on the top. Subsections (Added, Changed, Fixed, Removed) should be added as needed. -->

## Unreleased
### Added
- Fix: Package php-http/message-factory is abandoned, you should avoid using it. Use psr/http-factory instead.
Copy link
Member

Choose a reason for hiding this comment

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

This is not a fix. It replaces underlying HTTP library interfaces, meaning the signatures of public methods will change. This is unfortunately a breaking change.

This also means there should be an UPGRADE document prepared showing a steps to upgrade (see root directory of the repository for previous upgrade document).

Choose a reason for hiding this comment

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

But there is no changes needed. It will works without changes 🤷

@jakubpilaralmamedia jakubpilaralmamedia force-pushed the replace-http-factory-class branch 5 times, most recently from bb6f769 to 0729bad Compare January 16, 2024 10:07
@jakubpilaralmamedia jakubpilaralmamedia force-pushed the replace-http-factory-class branch from 0729bad to f074a25 Compare January 16, 2024 10:11
@@ -26,8 +26,29 @@ public function shouldSendAndDecodeRequest(): void
__DIR__ . '/Fixtures/response-one-successful-command.json'
);

$mockClient = new Client();
$mockClient->addResponse($dummyHttpResponse);
$mockClient = $this->createMock(Psr18Client::class);
Copy link
Member

Choose a reason for hiding this comment

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

I think the Mock client, which is implementation specifically made for unit tests, should be used instead. It is also already part of require-dev.

The assertions are then more readable and understandable then defining mocks like this.

See https://docs.php-http.org/en/latest/clients/mock-client.html

@@ -25,8 +26,10 @@ public function shouldExecuteRequestViaBuilder(): void
__DIR__ . '/Http/Fixtures/response-one-successful-command.json'
);

$mockClient = new Client();
$mockClient->addResponse($dummyHttpResponse);
$mockClient = $this->createMock(Psr18Client::class);
Copy link
Member

Choose a reason for hiding this comment

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

Dtto, use directly the mock client.

@@ -7,6 +7,10 @@
## Unreleased
### Changed
- Require PHP ^7.3
- Drop old version php-http/client-common ^1.6
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Drop old version php-http/client-common ^1.6
- Allow only `php-http/client-common` ^2.0 dependency (drop ^1.6)

- Drop old version php-http/client-common ^1.6

### Added
- Replace abandoned package php-http/message-factory. Using psr/http-factory instead.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Replace abandoned package php-http/message-factory. Using psr/http-factory instead.
- Replace dependency on abandoned `php-http/message-factory` with `psr/http-factory`.

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.

3 participants