Skip to content

Commit

Permalink
Fix types related issues introduced with 57f33b4
Browse files Browse the repository at this point in the history
XRevan86 authored and diogogithub committed Nov 16, 2019
1 parent 57f33b4 commit d95381f
Showing 3 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions XMPPHP/Log.php
Original file line number Diff line number Diff line change
@@ -75,10 +75,10 @@ class Log
* @param boolean $printout
* @param int $runlevel (optional)
*/
public function __construct($printout = false, int $runlevel = self::LEVEL_INFO)
public function __construct($printout = false, ?int $runlevel = self::LEVEL_INFO)
{
$this->printout = (bool)$printout;
$this->runlevel = (int)$runlevel;
$this->printout = (bool) $printout;
$this->runlevel = (int) ($runlevel ?? 0);
}

/**
16 changes: 8 additions & 8 deletions XMPPHP/XMLStream.php
Original file line number Diff line number Diff line change
@@ -581,9 +581,9 @@ public function addXPathHandler(string $xpath, string $pointer, ?string $obj = n
*
* @param string $name
* @param string $pointer
* @param string $obj
* @param object $obj
*/
public function addEventHandler(string $name, string $pointer, string $obj)
public function addEventHandler(string $name, string $pointer, object $obj)
{
$this->eventhandlers[] = [$name, $pointer, $obj];
}
@@ -644,12 +644,12 @@ public function processTime($timeout = null): string
/**
* XML start callback
*
* @param string resource $parser
* @param resource $parser
* @param string $name
* @param array $attr
* @see xml_set_element_handler
*/
public function startXML(string $parser, string $name, array $attr): void
public function startXML($parser, string $name, array $attr): void
{
if ($this->been_reset) {
$this->been_reset = false;
@@ -687,13 +687,13 @@ public function startXML(string $parser, string $name, array $attr): void
/**
* XML end callback
*
* @param string resource $parser
* @param resource $parser
* @param string $name
* @throws Exception
* @see xml_set_element_handler
*
*/
public function endXML(string $parser, string $name): void
public function endXML($parser, string $name): void
{
#$this->log->log("Ending $name", Log::LEVEL_DEBUG);
#print "$name\n";
@@ -780,12 +780,12 @@ public function endXML(string $parser, string $name): void

/**
* XML character callback
* @param string resource $parser
* @param resource $parser
* @param string $data
* @see xml_set_character_data_handler
*
*/
public function charXML(string $parser, string $data): void
public function charXML($parser, string $data): void
{
if (array_key_exists($this->xml_depth, $this->xmlobj)) {
$this->xmlobj[$this->xml_depth]->data .= $data;
36 changes: 18 additions & 18 deletions XMPPHP/XMPP.php
Original file line number Diff line number Diff line change
@@ -260,9 +260,9 @@ public function subscribe(string $jid): void
/**
* Message handler
*
* @param string $xml
* @param XMLObj $xml
*/
public function message_handler(string $xml): void
public function message_handler(XMLObj $xml): void
{
if (isset($xml->attrs['type'])) {
$payload['type'] = $xml->attrs['type'];
@@ -280,10 +280,10 @@ public function message_handler(string $xml): void
/**
* Presence handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
public function presence_handler(string $xml): void
public function presence_handler(XMLObj $xml): void
{
$payload['type'] = (isset($xml->attrs['type'])) ? $xml->attrs['type'] : 'available';
$payload['show'] = (isset($xml->sub('show')->data)) ? $xml->sub('show')->data : $payload['type'];
@@ -338,10 +338,10 @@ public function getVCard(?string $jid = null): void
/**
* Features handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function features_handler(string $xml): void
protected function features_handler(XMLObj $xml): void
{
if ($xml->hasSub('starttls') and $this->use_encryption) {
$this->send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>");
@@ -362,10 +362,10 @@ protected function features_handler(string $xml): void
/**
* SASL success handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function sasl_success_handler(string $xml): void
protected function sasl_success_handler(XMLObj $xml): void
{
$this->log->log("Auth success!");
$this->authed = true;
@@ -375,10 +375,10 @@ protected function sasl_success_handler(string $xml): void
/**
* SASL feature handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function sasl_failure_handler(string $xml): void
protected function sasl_failure_handler(XMLObj $xml): void
{
$this->log->log("Auth failed!", Log::LEVEL_ERROR);
$this->disconnect();
@@ -389,10 +389,10 @@ protected function sasl_failure_handler(string $xml): void
/**
* Resource bind handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function resource_bind_handler(string $xml): void
protected function resource_bind_handler(XMLObj $xml): void
{
if ($xml->attrs['type'] == 'result') {
$this->log->log("Bound to " . $xml->sub('bind')->sub('jid')->data);
@@ -409,10 +409,10 @@ protected function resource_bind_handler(string $xml): void
* Roster iq handler
* Gets all packets matching XPath "iq/{jabber:iq:roster}query'
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function roster_iq_handler(string $xml): void
protected function roster_iq_handler(XMLObj $xml): void
{
$status = "result";
$xmlroster = $xml->sub('query');
@@ -446,9 +446,9 @@ protected function roster_iq_handler(string $xml): void
/**
* Session start handler
*
* @param string $xml
* @param XMLObj $xml
*/
protected function session_start_handler(string $xml): void
protected function session_start_handler(XMLObj $xml): void
{
$this->log->log("Session started");
$this->session_started = true;
@@ -458,10 +458,10 @@ protected function session_start_handler(string $xml): void
/**
* TLS proceed handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function tls_proceed_handler(string $xml): void
protected function tls_proceed_handler(XMLObj $xml): void
{
$this->log->log("Starting TLS encryption");
stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);

0 comments on commit d95381f

Please sign in to comment.