Fix types related issues introduced with 57f33b4
This commit is contained in:
parent
57f33b4328
commit
d95381f8fb
@ -75,10 +75,10 @@ class Log
|
|||||||
* @param boolean $printout
|
* @param boolean $printout
|
||||||
* @param int $runlevel (optional)
|
* @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->printout = (bool) $printout;
|
||||||
$this->runlevel = (int)$runlevel;
|
$this->runlevel = (int) ($runlevel ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -581,9 +581,9 @@ class XMLStream
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $pointer
|
* @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];
|
$this->eventhandlers[] = [$name, $pointer, $obj];
|
||||||
}
|
}
|
||||||
@ -644,12 +644,12 @@ class XMLStream
|
|||||||
/**
|
/**
|
||||||
* XML start callback
|
* XML start callback
|
||||||
*
|
*
|
||||||
* @param string resource $parser
|
* @param resource $parser
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $attr
|
* @param array $attr
|
||||||
* @see xml_set_element_handler
|
* @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) {
|
if ($this->been_reset) {
|
||||||
$this->been_reset = false;
|
$this->been_reset = false;
|
||||||
@ -687,13 +687,13 @@ class XMLStream
|
|||||||
/**
|
/**
|
||||||
* XML end callback
|
* XML end callback
|
||||||
*
|
*
|
||||||
* @param string resource $parser
|
* @param resource $parser
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @see xml_set_element_handler
|
* @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);
|
#$this->log->log("Ending $name", Log::LEVEL_DEBUG);
|
||||||
#print "$name\n";
|
#print "$name\n";
|
||||||
@ -780,12 +780,12 @@ class XMLStream
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* XML character callback
|
* XML character callback
|
||||||
* @param string resource $parser
|
* @param resource $parser
|
||||||
* @param string $data
|
* @param string $data
|
||||||
* @see xml_set_character_data_handler
|
* @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)) {
|
if (array_key_exists($this->xml_depth, $this->xmlobj)) {
|
||||||
$this->xmlobj[$this->xml_depth]->data .= $data;
|
$this->xmlobj[$this->xml_depth]->data .= $data;
|
||||||
|
@ -260,9 +260,9 @@ class XMPP extends XMLStream
|
|||||||
/**
|
/**
|
||||||
* Message handler
|
* 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'])) {
|
if (isset($xml->attrs['type'])) {
|
||||||
$payload['type'] = $xml->attrs['type'];
|
$payload['type'] = $xml->attrs['type'];
|
||||||
@ -280,10 +280,10 @@ class XMPP extends XMLStream
|
|||||||
/**
|
/**
|
||||||
* Presence handler
|
* Presence handler
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param XMLObj $xml
|
||||||
* @throws Exception
|
* @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['type'] = (isset($xml->attrs['type'])) ? $xml->attrs['type'] : 'available';
|
||||||
$payload['show'] = (isset($xml->sub('show')->data)) ? $xml->sub('show')->data : $payload['type'];
|
$payload['show'] = (isset($xml->sub('show')->data)) ? $xml->sub('show')->data : $payload['type'];
|
||||||
@ -338,10 +338,10 @@ class XMPP extends XMLStream
|
|||||||
/**
|
/**
|
||||||
* Features handler
|
* Features handler
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param XMLObj $xml
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function features_handler(string $xml): void
|
protected function features_handler(XMLObj $xml): void
|
||||||
{
|
{
|
||||||
if ($xml->hasSub('starttls') and $this->use_encryption) {
|
if ($xml->hasSub('starttls') and $this->use_encryption) {
|
||||||
$this->send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>");
|
$this->send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>");
|
||||||
@ -362,10 +362,10 @@ class XMPP extends XMLStream
|
|||||||
/**
|
/**
|
||||||
* SASL success handler
|
* SASL success handler
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param XMLObj $xml
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function sasl_success_handler(string $xml): void
|
protected function sasl_success_handler(XMLObj $xml): void
|
||||||
{
|
{
|
||||||
$this->log->log("Auth success!");
|
$this->log->log("Auth success!");
|
||||||
$this->authed = true;
|
$this->authed = true;
|
||||||
@ -375,10 +375,10 @@ class XMPP extends XMLStream
|
|||||||
/**
|
/**
|
||||||
* SASL feature handler
|
* SASL feature handler
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param XMLObj $xml
|
||||||
* @throws Exception
|
* @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->log->log("Auth failed!", Log::LEVEL_ERROR);
|
||||||
$this->disconnect();
|
$this->disconnect();
|
||||||
@ -389,10 +389,10 @@ class XMPP extends XMLStream
|
|||||||
/**
|
/**
|
||||||
* Resource bind handler
|
* Resource bind handler
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param XMLObj $xml
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function resource_bind_handler(string $xml): void
|
protected function resource_bind_handler(XMLObj $xml): void
|
||||||
{
|
{
|
||||||
if ($xml->attrs['type'] == 'result') {
|
if ($xml->attrs['type'] == 'result') {
|
||||||
$this->log->log("Bound to " . $xml->sub('bind')->sub('jid')->data);
|
$this->log->log("Bound to " . $xml->sub('bind')->sub('jid')->data);
|
||||||
@ -409,10 +409,10 @@ class XMPP extends XMLStream
|
|||||||
* Roster iq handler
|
* Roster iq handler
|
||||||
* Gets all packets matching XPath "iq/{jabber:iq:roster}query'
|
* Gets all packets matching XPath "iq/{jabber:iq:roster}query'
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param XMLObj $xml
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function roster_iq_handler(string $xml): void
|
protected function roster_iq_handler(XMLObj $xml): void
|
||||||
{
|
{
|
||||||
$status = "result";
|
$status = "result";
|
||||||
$xmlroster = $xml->sub('query');
|
$xmlroster = $xml->sub('query');
|
||||||
@ -446,9 +446,9 @@ class XMPP extends XMLStream
|
|||||||
/**
|
/**
|
||||||
* Session start handler
|
* 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->log->log("Session started");
|
||||||
$this->session_started = true;
|
$this->session_started = true;
|
||||||
@ -458,10 +458,10 @@ class XMPP extends XMLStream
|
|||||||
/**
|
/**
|
||||||
* TLS proceed handler
|
* TLS proceed handler
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param XMLObj $xml
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function tls_proceed_handler(string $xml): void
|
protected function tls_proceed_handler(XMLObj $xml): void
|
||||||
{
|
{
|
||||||
$this->log->log("Starting TLS encryption");
|
$this->log->log("Starting TLS encryption");
|
||||||
stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
|
stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
|
||||||
|
Loading…
Reference in New Issue
Block a user