Skip to content

Commit

Permalink
Fix children typo
Browse files Browse the repository at this point in the history
  • Loading branch information
frost-nzcr4 committed Sep 13, 2016
1 parent bed053f commit 70e41c6
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions docs/users/xml_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ developers can get lost in dirty XML manipulations spreaded all over the applica
XML structures are not only unreadable for humans but even for machine.

While an instance of ``JAXLXml`` provide direct access to XML ``name``, ``ns`` and ``text``, it can become painful and
time consuming when trying to retrieve or modify a particular ``attrs`` or ``childrens``. I was fed up of doing
time consuming when trying to retrieve or modify a particular ``attrs`` or ``children``. I was fed up of doing
``getAttributeByName``, ``setAttributeByName``, ``getChild`` etc everytime i had to access common XMPP Stanza attributes.

``XMPPStanza`` is a wrapper on top of ``JAXLXml`` objects. Preserving all the functionalities of base ``JAXLXml``
Expand All @@ -101,7 +101,7 @@ Here is a list of default access patterns:
#. ``ns``
#. ``text``
#. ``attrs``
#. ``childrens``
#. ``children``
#. ``to``
#. ``from``
#. ``id``
Expand Down
2 changes: 1 addition & 1 deletion examples/register_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function wait_for_register_form($event, $args)
echo $instructions->text.PHP_EOL;
}

foreach ($query->childrens as $k => $child) {
foreach ($query->children as $k => $child) {
if ($child->name != 'instructions') {
$form[$child->name] = readline($child->name.":");
}
Expand Down
12 changes: 6 additions & 6 deletions src/JAXL/core/jaxl_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function c($name, $ns = null, array $attrs = array(), $text = null)
{
$node = new JAXLXml($name, $ns, $attrs, $text);
$node->parent = &$this->rover;
$this->rover->childrens[] = &$node;
$this->rover->children[] = &$node;
$this->rover = &$node;
return $this;
}
Expand All @@ -208,7 +208,7 @@ public function c($name, $ns = null, array $attrs = array(), $text = null)
public function cnode($node)
{
$node->parent = &$this->rover;
$this->rover->childrens[] = &$node;
$this->rover->children[] = &$node;
$this->rover = &$node;
return $this;
}
Expand Down Expand Up @@ -241,7 +241,7 @@ public function top()
*/
public function exists($name, $ns = null, array $attrs = array())
{
foreach ($this->childrens as $child) {
foreach ($this->children as $child) {
if ($ns) {
if ($child->name == $name && $child->ns == $ns && $child->match_attrs($attrs)) {
return $child;
Expand All @@ -263,12 +263,12 @@ public function exists($name, $ns = null, array $attrs = array())
*/
public function update($name, $ns = null, array $attrs = array(), $text = null)
{
foreach ($this->childrens as $k => $child) {
foreach ($this->children as $k => $child) {
if ($child->name == $name) {
$child->ns = $ns;
$child->attrs($attrs);
$child->text = $text;
$this->childrens[$k] = $child;
$this->children[$k] = $child;
break;
}
}
Expand All @@ -293,7 +293,7 @@ public function to_string($parent_ns = null)
}
$xml .= '>';

foreach ($this->childrens as $child) {
foreach ($this->children as $child) {
$xml .= $child->to_string($this->ns);
}

Expand Down
2 changes: 1 addition & 1 deletion src/JAXL/core/jaxl_xml_access.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ abstract class JAXLXmlAccess
public $text = null;

/** @var JAXLXml[] */
public $childrens = array();
public $children = array();
}
10 changes: 5 additions & 5 deletions src/JAXL/jaxl.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ public function handle_auth_mechs($stanza, $mechanisms)
// extract available mechanisms
$mechs = array();
if ($mechanisms) {
foreach ($mechanisms->childrens as $mechanism) {
foreach ($mechanisms->children as $mechanism) {
$mechs[$mechanism->text] = true;
}
}
Expand Down Expand Up @@ -734,13 +734,13 @@ public function handle_iq($stanza)

// catch roster list
if ($stanza->type == 'result' && ($query = $stanza->exists('query', 'jabber:iq:roster'))) {
foreach ($query->childrens as $child) {
foreach ($query->children as $child) {
if ($child->name == 'item') {
$jid = $child->attrs['jid'];
$subscription = $child->attrs['subscription'];

$groups = array();
foreach ($child->childrens as $group) {
foreach ($child->children as $group) {
if ($group->name == 'group') {
$groups[] = $group->text;
}
Expand Down Expand Up @@ -828,7 +828,7 @@ public function handle_other($event, $args)
public function handle_domain_info($stanza)
{
$query = $stanza->exists('query', XEP0030::NS_DISCO_INFO);
foreach ($query->childrens as $k => $child) {
foreach ($query->children as $k => $child) {
if ($child->name == 'identity') {
//echo 'identity '.
// 'category:' . (isset($child->attrs['category']) ? $child->attrs['category'] : 'NULL').
Expand All @@ -845,7 +845,7 @@ public function handle_domain_info($stanza)
public function handle_domain_items($stanza)
{
$query = $stanza->exists('query', XEP0030::NS_DISCO_ITEMS);
foreach ($query->childrens as $k => $child) {
foreach ($query->children as $k => $child) {
if ($child->name == 'item') {
//echo 'item '.
// 'jid:'.(isset($child->attrs['jid']) ? $child->attrs['jid'] : 'NULL').
Expand Down
2 changes: 1 addition & 1 deletion src/JAXL/xep/xep_0114.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function logged_in($stanza)
public function logged_out($stanza)
{
if ($stanza->name == "error" && $stanza->ns == XMPP::NS_XMPP) {
$reason = $stanza->childrens[0]->name;
$reason = $stanza->children[0]->name;
$this->jaxl->handle_auth_failure($reason);
$this->jaxl->send_end_stream();
return array("logged_out", 0);
Expand Down
8 changes: 4 additions & 4 deletions src/JAXL/xmpp/xmpp_stanza.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public function __construct($name, array $attrs = array(), $ns = XMPP::NS_JABBER
unset($this->attrs);
$this->text = null;
unset($this->text);
$this->childrens = null;
unset($this->childrens);
$this->children = null;
unset($this->children);

if ($name instanceof JAXLXml) {
$this->xml = $name;
Expand All @@ -117,7 +117,7 @@ public function __get($prop)
case 'ns':
case 'text':
case 'attrs':
case 'childrens':
case 'children':
return $this->xml->$prop;
break;

Expand Down Expand Up @@ -174,7 +174,7 @@ public function __set($prop, $val)
case 'ns':
case 'text':
case 'attrs':
case 'childrens':
case 'children':
return $this->xml->$prop = $val;
break;

Expand Down
2 changes: 1 addition & 1 deletion src/JAXL/xmpp/xmpp_stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ public function wait_for_sasl_response($event, $args)
$stanza = $args[0];

if ($stanza->name == 'failure' && $stanza->ns == XMPP::NS_SASL) {
$reason = $stanza->childrens[0]->name;
$reason = $stanza->children[0]->name;
//JAXLLogger::debug("sasl failed with reason ".$reason."");
$this->handle_auth_failure($reason);
return "logged_out";
Expand Down
2 changes: 1 addition & 1 deletion tests/JAXLXmlStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function xml_end_cb($node)
public function xml_stanza_cb($node)
{
$this->assertEquals('features', $node->name);
$this->assertEquals(1, count($node->childrens));
$this->assertEquals(1, count($node->children));
}

public function test_xml_stream_callbacks()
Expand Down
2 changes: 1 addition & 1 deletion tests/XMPPStanzaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function checkJAXLXmlAccess(JAXLXmlAccess $xml_or_stanza, $test_data)
$this->assertEquals($test_data['ns'], $xml_or_stanza->ns);
$this->assertEquals($test_data['attrs'], $xml_or_stanza->attrs);
$this->assertEquals($test_data['text'], $xml_or_stanza->text);
$this->assertEquals(array(), $xml_or_stanza->childrens);
$this->assertEquals(array(), $xml_or_stanza->children);
return true;
}
}

0 comments on commit 70e41c6

Please sign in to comment.