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

Make GuzzleException extend Throwable whereever it's available #2273

Merged
merged 1 commit into from Apr 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 17 additions & 10 deletions src/Exception/GuzzleException.php
@@ -1,13 +1,20 @@
<?php
namespace GuzzleHttp\Exception;

/**
* @method string getMessage()
* @method \Throwable|null getPrevious()
* @method mixed getCode()
* @method string getFile()
* @method int getLine()
* @method array getTrace()
* @method string getTraceAsString()
*/
interface GuzzleException {}
use Throwable;

if (interface_exists(Throwable::class)) {
Copy link

@kronthto kronthto Nov 14, 2019

Choose a reason for hiding this comment

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

interface_exists has a second parameter autoload that defaults to true: https://www.php.net/manual/en/function.interface-exists.php

Can we explicitely pass this as false? It makes no sense imo to try autoloading a SPL class/interface, and causes issues with bad autoloader implementations that include/require everything passed to them even if such a file does not exist.

I can make a PR if needed.

Copy link
Member

Choose a reason for hiding this comment

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

pr welcome

interface GuzzleException extends Throwable {}
} else {
/**
* @method string getMessage()
* @method \Throwable|null getPrevious()
* @method mixed getCode()
* @method string getFile()
* @method int getLine()
* @method array getTrace()
* @method string getTraceAsString()
*/
interface GuzzleException {}
}