Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/php/lib/Base/TBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
#[\AllowDynamicProperties]
abstract class TBase
{
public static $tmethod = [
/** @var array<int, string> */
public static array $tmethod = [
TType::BOOL => 'Bool',
TType::BYTE => 'Byte',
TType::I16 => 'I16',
Expand Down
16 changes: 8 additions & 8 deletions lib/php/lib/ClassLoader/ThriftClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ class ThriftClassLoader
{
/**
* Namespaces path
* @var array
*
* @var array<string, list<string>>
*/
protected $namespaces = [];
protected array $namespaces = [];

/**
* Thrift definition paths
* @var array
*
* @var array<string, list<string>>
*/
protected $definitions = [];
protected array $definitions = [];

/**
* Do we use APCu cache ?
* @var boolean
*/
protected $apcu = false;
protected bool $apcu = false;

/**
* APCu Cache prefix
* @var string
*/
protected $apcu_prefix;
protected ?string $apcu_prefix;

/**
* Set autoloader to use APCu cache
Expand Down
3 changes: 2 additions & 1 deletion lib/php/lib/Exception/TApplicationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

class TApplicationException extends TException
{
public static $tspec = [
/** @var array<int, array{var: string, type: int}> */
public static array $tspec = [
1 => [
'var' => 'message',
'type' => TType::STRING,
Expand Down
3 changes: 2 additions & 1 deletion lib/php/lib/Exception/TException.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public function __construct($p1 = null, $p2 = 0)
}
}

public static $tmethod = [
/** @var array<int, string> */
public static array $tmethod = [
TType::BOOL => 'Bool',
TType::BYTE => 'Byte',
TType::I16 => 'I16',
Expand Down
10 changes: 2 additions & 8 deletions lib/php/lib/Factory/TBinaryProtocolFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,8 @@
*/
class TBinaryProtocolFactory implements TProtocolFactory
{
/**
* @var bool
*/
private $strictRead = false;
/**
* @var bool
*/
private $strictWrite = false;
private bool $strictRead = false;
private bool $strictWrite = false;

/**
* @param bool $strictRead
Expand Down
6 changes: 2 additions & 4 deletions lib/php/lib/Protocol/JSON/ListContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@

class ListContext extends BaseContext
{
private $first = true;
private $protocol;
private bool $first = true;

public function __construct($protocol)
public function __construct(private TJSONProtocol $protocol)
{
$this->protocol = $protocol;
}

public function write()
Expand Down
10 changes: 5 additions & 5 deletions lib/php/lib/Protocol/JSON/LookaheadReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@

namespace Thrift\Protocol\JSON;

use Thrift\Protocol\TJSONProtocol;

class LookaheadReader
{
private $hasData = false;
private $data = [];
private $protocol;
private bool $hasData = false;
private string $data = '';

public function __construct($protocol)
public function __construct(private TJSONProtocol $protocol)
{
$this->protocol = $protocol;
}

public function read()
Expand Down
8 changes: 3 additions & 5 deletions lib/php/lib/Protocol/JSON/PairContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@

class PairContext extends BaseContext
{
private $first = true;
private $colon = true;
private $protocol = null;
private bool $first = true;
private bool $colon = true;

public function __construct($protocol)
public function __construct(private TJSONProtocol $protocol)
{
$this->protocol = $protocol;
}

public function write()
Expand Down
6 changes: 2 additions & 4 deletions lib/php/lib/Protocol/SimpleJSON/ListContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@

class ListContext extends Context
{
protected $first = true;
private $protocol;
protected bool $first = true;

public function __construct($protocol)
public function __construct(private TSimpleJSONProtocol $protocol)
{
$this->protocol = $protocol;
}

public function write()
Expand Down
7 changes: 4 additions & 3 deletions lib/php/lib/Protocol/SimpleJSON/MapContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@

namespace Thrift\Protocol\SimpleJSON;

use Thrift\Protocol\TSimpleJSONProtocol;

class MapContext extends StructContext
{
protected $isKey = true;
private $protocol;
protected bool $isKey = true;

public function __construct($protocol)
public function __construct(TSimpleJSONProtocol $protocol)
{
parent::__construct($protocol);
}
Expand Down
8 changes: 3 additions & 5 deletions lib/php/lib/Protocol/SimpleJSON/StructContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@

class StructContext extends Context
{
protected $first = true;
protected $colon = true;
private $protocol;
protected bool $first = true;
protected bool $colon = true;

public function __construct($protocol)
public function __construct(private TSimpleJSONProtocol $protocol)
{
$this->protocol = $protocol;
}

public function write()
Expand Down
4 changes: 2 additions & 2 deletions lib/php/lib/Protocol/TBinaryProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class TBinaryProtocol extends TProtocol
public const VERSION_MASK = 0xffff0000;
public const VERSION_1 = 0x80010000;

protected $strictRead = false;
protected $strictWrite = true;
protected bool $strictRead = false;
protected bool $strictWrite = true;

public function __construct($trans, $strictRead = false, $strictWrite = true)
{
Expand Down
20 changes: 12 additions & 8 deletions lib/php/lib/Protocol/TCompactProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class TCompactProtocol extends TProtocol

public const MAX_VARINT_BYTES = 10; // ceil(64/7); matches protobuf wire format

protected static $ctypes = [
/** @var array<int, int> */
protected static array $ctypes = [
TType::STOP => TCompactProtocol::COMPACT_STOP,
TType::BOOL => TCompactProtocol::COMPACT_TRUE, // used for collection
TType::BYTE => TCompactProtocol::COMPACT_BYTE,
Expand All @@ -82,7 +83,8 @@ class TCompactProtocol extends TProtocol
TType::UUID => TCompactProtocol::COMPACT_UUID,
];

protected static $ttypes = [
/** @var array<int, int> */
protected static array $ttypes = [
TCompactProtocol::COMPACT_STOP => TType::STOP,
TCompactProtocol::COMPACT_TRUE => TType::BOOL, // used for collection
TCompactProtocol::COMPACT_FALSE => TType::BOOL,
Expand All @@ -99,12 +101,14 @@ class TCompactProtocol extends TProtocol
TCompactProtocol::COMPACT_UUID => TType::UUID,
];

protected $state = TCompactProtocol::STATE_CLEAR;
protected $lastFid = 0;
protected $boolFid = null;
protected $boolValue = null;
protected $structs = [];
protected $containers = [];
protected int $state = TCompactProtocol::STATE_CLEAR;
protected ?int $lastFid = 0;
protected ?int $boolFid = null;
protected ?bool $boolValue = null;
/** @var list<array{0: int, 1: int}> */
protected array $structs = [];
/** @var list<int> */
protected array $containers = [];

// Some varint / zigzag helper methods
public function toZigZag($n, $bits)
Expand Down
5 changes: 3 additions & 2 deletions lib/php/lib/Protocol/TJSONProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ private function getTypeIDForTypeName($name)
return $result;
}

/** @var list<BaseContext> */
private array $contextStack = [];
private $context;
private $reader;
private BaseContext $context;
private LookaheadReader $reader;

private function pushContext($c)
{
Expand Down
4 changes: 1 addition & 3 deletions lib/php/lib/Protocol/TMultiplexedProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ class TMultiplexedProtocol extends TProtocolDecorator

/**
* The name of service.
*
* @var string
*/
private $serviceName;
private string $serviceName;

/**
* Constructor of <code>TMultiplexedProtocol</code> class.
Expand Down
4 changes: 1 addition & 3 deletions lib/php/lib/Protocol/TProtocolDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ abstract class TProtocolDecorator extends TProtocol
{
/**
* Instance of protocol, to which all operations will be forwarded.
*
* @var TProtocol
*/
private $concreteProtocol;
private TProtocol $concreteProtocol;

/**
* Constructor of <code>TProtocolDecorator</code> class.
Expand Down
5 changes: 3 additions & 2 deletions lib/php/lib/Protocol/TSimpleJSONProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class TSimpleJSONProtocol extends TProtocol
public const NAME_LIST = "lst";
public const NAME_SET = "set";

protected $writeContext = null;
protected $writeContextStack = [];
protected ?Context $writeContext = null;
/** @var list<Context|null> */
protected array $writeContextStack = [];

/**
* Push a new write context onto the stack.
Expand Down
8 changes: 3 additions & 5 deletions lib/php/lib/Server/TForkingServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ class TForkingServer extends TServer
{
/**
* Flag for the main serving loop
*
* @var bool
*/
private $stop = false;
private bool $stop = false;

/**
* List of children.
*
* @var array
* @var array<int, TTransport>
*/
protected $children = [];
protected array $children = [];

/**
* Listens for new client using the supplied
Expand Down
23 changes: 6 additions & 17 deletions lib/php/lib/Server/TServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,29 @@ abstract class TServer
protected $processor;

/**
* Server transport to be used for listening
* and accepting new clients
*
* @var TServerTransport
* Server transport to be used for listening and accepting new clients
*/
protected $transport;
protected TServerTransport $transport;

/**
* Input transport factory
*
* @var TTransportFactoryInterface
*/
protected $inputTransportFactory;
protected TTransportFactoryInterface $inputTransportFactory;

/**
* Output transport factory
*
* @var TTransportFactoryInterface
*/
protected $outputTransportFactory;
protected TTransportFactoryInterface $outputTransportFactory;

/**
* Input protocol factory
*
* @var TProtocolFactory
*/
protected $inputProtocolFactory;
protected TProtocolFactory $inputProtocolFactory;

/**
* Output protocol factory
*
* @var TProtocolFactory
*/
protected $outputProtocolFactory;
protected TProtocolFactory $outputProtocolFactory;

/**
* Sets up all the factories, etc
Expand Down
14 changes: 4 additions & 10 deletions lib/php/lib/Server/TServerSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,24 @@ class TServerSocket extends TServerTransport
/**
* Handle for the listener socket
*
* @var resource
* @var resource|null
*/
protected $listener;

/**
* Port for the listener to listen on
*
* @var int
*/
protected $port;
protected int $port;

/**
* Timeout when listening for a new client
*
* @var int
*/
protected $acceptTimeout = 30000;
protected int $acceptTimeout = 30000;

/**
* Host to listen on
*
* @var string
*/
protected $host;
protected string $host;

/**
* ServerSocket constructor
Expand Down
Loading
Loading