-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Use return types and phpdoc #178
Conversation
Add utilities to composer
Alter Frame::getMessageId() to return either id or message-id as the frame doesn't know what version it is for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like adding native types. It will require a new major version I guess, as adding parameter types can be a breaking change for existing code
Hey @staabm, I am good with making a new major release for this change. If you have time to review and merge this, we can cut a 6.0.0 release |
I will have a closer look in the next view days |
to make sure phpstan reports nullability issues we need either raise the phpstan level (which would also bring in a lot of other non-nullability related errors) or we enable nullability checking separately see https://twitter.com/markusstaab/status/1710201565087256893 |
@@ -90,11 +90,11 @@ public function testAckVersionTwo() | |||
$instance = $this->getProtocol(Version::VERSION_1_2); | |||
|
|||
$actual = $instance->getAckFrame( | |||
new Frame(null, ['message-id' => 'id-value', 'ack' => 'ack-id-value']), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these test-changes related to the type changes, or could be separated because unrelated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github bug
@@ -149,17 +149,17 @@ public function setObserver(ConnectionObserver $observer) | |||
* | |||
* @return FrameFactory | |||
*/ | |||
public function getFactory() | |||
public function getFactory(): ?FrameFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the property is not-nullable
public function getFactory(): ?FrameFactory | |
public function getFactory(): FrameFactory |
maybe we should add a native property type (maybe as a followup; and only for private properties)
@@ -46,7 +46,7 @@ function ($command, array $headers, $body) { | |||
* @param boolean $legacyMode stomp 1.0 mode (headers) | |||
* @return Frame | |||
*/ | |||
public function createFrame($command, array $headers, $body, $legacyMode) | |||
public function createFrame($command, array $headers, $body, $legacyMode): Frame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding return type in non-final classes is BC breaking for subclasses -> we really need a new major.
it might be useful to declare some classes final
in case we don't want people to subclass them (followup PR)
@@ -363,7 +363,7 @@ protected function getConnection() | |||
* | |||
* @return array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be great to add key/value types to array-return types (followup PR)
@@ -199,7 +199,7 @@ public function __construct($brokerUri, $connectionTimeout = 1, array $context = | |||
* | |||
* @param callable|null $waitCallback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having callable signatures would also be awesome (followup PR)
public function getNackFrame(Frame $frame, ?string $transactionId = null, ?bool $requeue = null): Frame | ||
{ | ||
if ($this->getVersion() === Version::VERSION_1_0) { | ||
throw new StompException('Stomp Version 1.0 has no support for NACK Frames.'); | ||
} | ||
$nack = $this->createFrame('NACK'); | ||
$nack = parent::getNackFrame($frame, $transactionId); | ||
if ($requeue !== null) { | ||
$nack->addHeaders(['requeue' => $requeue ? 'true' : 'false']); | ||
} | ||
$nack['transaction'] = $transactionId; | ||
if ($this->hasVersion(Version::VERSION_1_2)) { | ||
$nack['id'] = $frame->getMessageId(); | ||
} else { | ||
$nack['message-id'] = $frame->getMessageId(); | ||
if ($this->hasVersion(Version::VERSION_1_1)) { | ||
$nack['subscription'] = $frame['subscription']; | ||
} | ||
} | ||
|
||
$nack['message-id'] = $frame->getMessageId(); | ||
return $nack; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a change which should be done in a separate PR?
(without the type additions)
What I discovered when starting this is that almost everything allowed Adding types caused these So I'm going to close this and consider removing all the uses of/acceptance of Then try types again. I will consider the other comments in the other PRs |
This is to add some documentation (as I understand it) and types to arguments and functions.
This should have no impact on the code...except possibly for ACK/NACK.
It appears that Apollo sends a "ack" header on MESSAGE frames which is not part of the spec. That seems to have impacted the base
Protocol
class which was looking for thisack
header in theProtocol::getAckFrame
function.Also but unrelated the in
Protocol::getNackFrame
amessage-id
header was being sent on all "nack" messages and was overwriting what may have been set previously.