From 06028fad3c6af49da975e0d33a16e5bddfdb1326 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Sun, 28 Jul 2024 19:24:07 +0200 Subject: [PATCH] Add return statements for PhutilChannelChannel::readBytes()/writeBytes() Summary: PHPStan complains that `Method PhutilChannelChannel::readBytes() should return string but return statement is missing.` and `Method PhutilChannelChannel::writeBytes() should return int but return statement is missing.` All other subclasses of `PhutilChannel` implementing these two methods either provide a return value or directly throw an exception. `PhutilChannelChannel` throws an exception for both methods but hadn't explicitly declared that as a `return` statement. Test Plan: Run static code analysis; read/grep the code. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Differential Revision: https://we.phorge.it/D25754 --- src/channel/PhutilChannelChannel.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/channel/PhutilChannelChannel.php b/src/channel/PhutilChannelChannel.php index 1ab99e30..3b0cb437 100644 --- a/src/channel/PhutilChannelChannel.php +++ b/src/channel/PhutilChannelChannel.php @@ -53,10 +53,12 @@ abstract class PhutilChannelChannel extends PhutilChannel { protected function readBytes($length) { $this->throwOnRawByteOperations(); + return ''; // Never returned but makes static code analyzers happy } protected function writeBytes($bytes) { $this->throwOnRawByteOperations(); + return -1; // Never returned but makes static code analyzers happy } protected function getReadSockets() {