Skip to content

Sentry\Transport\Result should not be internal as it is part of an interface #1894

@etienneroudeix

Description

@etienneroudeix

How do you use Sentry?

Sentry SaaS (sentry.io)

SDK version

4.0.0

Steps to reproduce

Sentry\Transport\Result class should not be flagged as @internal as it is the expected return value for Sentry\Transport\TransportInterface.

When one wishes to implement a custom transport, implementing Sentry\Transport\TransportInterface, it must use Sentry\Transport\Result out of the internal lib.

While it is not actually failing as a PHP error, static analysis tools such as phpstan or psalm are returning errors.


Sample code:

\Sentry\init([
    'transport' => new class implements \Sentry\Transport\TransportInterface
    {

        public function send(Event $event): \Sentry\Transport\Result
        {
            return new Result(\Sentry\Transport\ResultStatus::success(), $event);
        }

        public function close(?int $timeout = null): \Sentry\Transport\Result
        {
            return new Result(\Sentry\Transport\ResultStatus::success(), null);
        }
    }
]);

would trigger in PHPStan

  243    Return type of method send() in anonymous class has typehint with internal class              
         Sentry\Transport\Result.                                                                      
         🪪 return.internalClass                                                                       
  245    Call to method __construct() of internal class Sentry\Transport\Result from outside its root  
         namespace Sentry.                                                                             
         🪪 method.internalClass                                                                       
  245    Instantiation of internal class Sentry\Transport\Result.                                      
         🪪 new.internalClass                                                                          
  248    Return type of method close() in anonymous class has typehint with internal class             
         Sentry\Transport\Result.                                                                      
         🪪 return.internalClass                                                                       
  250    Call to method __construct() of internal class Sentry\Transport\Result from outside its root  
         namespace Sentry.                                                                             
         🪪 method.internalClass                                                                       
  250    Instantiation of internal class Sentry\Transport\Result.                                      
         🪪 new.internalClass

Expected result

Sentry\Transport\Result should not be internal.

Actual result

Sentry\Transport\Result is internal.

Metadata

Metadata

Assignees

Labels

No fields configured for issues without a type.

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions