Skip to content

replace hard locking to Guzzle Stream with PSR StreamInterface - #581

Merged
Philip Gichuhi (Ndiritu) merged 5 commits into
microsoftgraph:devfrom
jasverix:feature/use-psr-stream-interface
Aug 18, 2021
Merged

replace hard locking to Guzzle Stream with PSR StreamInterface#581
Philip Gichuhi (Ndiritu) merged 5 commits into
microsoftgraph:devfrom
jasverix:feature/use-psr-stream-interface

Conversation

@jasverix

@jasverix Jan-Sverre Riksfjord (jasverix) commented Aug 11, 2021

Copy link
Copy Markdown

Guzzle::streamFor() already accepts StreamInterface and does not require Guzzle Stream.

We are using another provider (nyholm) for streams in our project and the requirement for Guzzle Stream is really a blocking issue for us. And we cannot see any reason for that, because Guzzle itself only requires StreamInterface.

Microsoft Reviewers: Open in CodeFlow

Guzzle::streamFor() already accepts StreamInterface and does
not require Guzzle Stream.
@ghost

Deleted user (ghost) commented Aug 11, 2021

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@Ndiritu

Philip Gichuhi (Ndiritu) commented Aug 11, 2021

Copy link
Copy Markdown
Contributor

First, thanks for taking time to improve this library Jan-Sverre Riksfjord (@jasverix)! 🎉

A pointer:
Our models are auto-generated therefore these changes will be made in that repo.

However, we can still discuss the issue you're facing here...

The getters currently return a Psr StreamInterface impl (albeit Guzzle Stream) in all cases I've thought of i.e. GuzzleHttp\Psr7\Utils::streamFor() returns a Guzzle Stream which is Psr compliant

Only issue I see is calling the setter with a Nyholm stream and calling the getter returning a Guzzle stream.

Is there any other way that using the Nyholm stream implementation doesn't work with this library?

I agree with changing our PHPDocs to StreamInterface (both setters and getters) to make things clearer and agree with the if-statement type check changing to StreamInterface

@jasverix

Copy link
Copy Markdown
Author

Hi,

I might have overreacted here. My problem is the attachBody method in the GraphRequest class. I can update this PR and keep only that change.

@jasverix

Copy link
Copy Markdown
Author

I have now fixed the branch. I just did a big replace operation, but my problem is the attachBody method. We are passing a file to OneDrive, and we already have that file as a StreamInterface, but not a Guzzle Stream. Guzzle handles it perfectly, but attachBody had a is_a() check that I've now changed.

@Ndiritu Philip Gichuhi (Ndiritu) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good.

Comment thread composer.json Outdated
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"ext-json": "*"
"ext-json": "*",
"psr/http-client": "^1.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

StreamInterface is defined in psr/http-message

Can we opt to let guzzlehttp/psr7 that is included implicitly with guzzlehttp/guzzle determine the version of psr/http-message that is included?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed to correct package now.

How can we let guzzle determine the version? Right now, we have the exact same version query as guzzle (^1.0).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I can use a string, as you did before, instead of the ::class constant, and remove the package requirement, if you want.

I just, in general, personally like code better than strings, but it will do no big difference in this case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can use a string, as you did before, instead of the ::class constant, and remove the package requirement, if you want.

I just, in general, personally like code better than strings, but it will do no big difference in this case.

I also prefer the ::class constant. We'll be removing the string in v2.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changed to correct package now.

How can we let guzzle determine the version? Right now, we have the exact same version query as guzzle (^1.0).

Thanks for making the change. I agree with setting psr/http-message as a direct dependency instead of letting guzzle define this.

We've had a running discussion on whether to explicitly set guzzlehttp/psr7 & in this case psr/http-message as our direct dependency.

Inviting thoughts from silaskenneth (@SilasKenneth) Michael Mainer (@MIchaelMainer) Mustafa Zengin (@zengin)

@Ndiritu
Philip Gichuhi (Ndiritu) merged commit 2c0e4ff into microsoftgraph:dev Aug 18, 2021
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