Skip to content

Conversation

@Litarnus
Copy link
Contributor

@Litarnus Litarnus commented Nov 4, 2025

This PR makes the Client no longer nullable. This means that checks if the client are null are no longer necessary which reduces possible errors.
Also it's easier to retrieve options now, the new NoOpClient will provide options so it's no longer necessary to check if a client exists to get configuration options.

resolves PHP-47

@linear
Copy link

linear bot commented Nov 4, 2025

@Litarnus Litarnus added the 5.x label Nov 4, 2025
@Litarnus Litarnus self-assigned this Nov 4, 2025

if ($client === null) {
// No point in storing breadcrumbs if the client will never send them
if ($client instanceof NullClient) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking that maybe we can extend the ClientInterface with methods like supportsBreadcrumbs or supportAttachments to properly solve this without having to use the instanceof check.

Copy link
Collaborator

@stayallive stayallive Nov 6, 2025

Choose a reason for hiding this comment

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

I am wondering if we can "abuse" the Options for this, we already check $options->getMaxBreadcrumbs(); for example. Setting that to 0 would fix this for de breadcrumbs. And we can add sample_rate's of 0. Not sure that is a bit too hacky.

Because even though I love this PR and the cleanup it brings I also see it now does in some cases do quite some more work to throw away later which is less than idea. But the instanceof check is also not great... guess we also need a NullHub to fix most of that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that the options alone wouldn't cover all cases. For attachments or check-ins we would have to introduce new options that just exist to enable the NoOpClient.

Because even though I love this PR and the cleanup it brings I also see it now does in some cases do quite some more work to throw away later which is less than idea.

Yeah totally, having a nullable client where null means "don't do heavy work" was quite convenient.

But the instanceof check is also not great... guess we also need a NullHub to fix most of that?

It would definitely help us to stop doing pretty much any work but I don't really want to add one right now because we want to get rid of the Hub in the next major anyway.

I don't really have a nice solution for this right now, maybe creating an issue and revisiting it once we got rid of hubs is the best approach, WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah that sounds OK. I don't have the perfect answer either right now. This is a step in the right direction so let's refine on it further later.

@Litarnus Litarnus requested a review from stayallive November 4, 2025 15:24
@Litarnus Litarnus marked this pull request as ready for review November 4, 2025 15:24
cursor[bot]

This comment was marked as outdated.

@Litarnus Litarnus changed the title ref(client): replace nullable client with NullClient ref(client): replace nullable client with NoOpClient Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants