Skip to content

Implement Countable for DomNodeList and DOMNamedNodeMap (Request #74837) #2618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Implement Countable for DomNodeList and DOMNamedNodeMap (Request #74837) #2618

wants to merge 2 commits into from

Conversation

blar
Copy link
Contributor

@blar blar commented Jul 9, 2017

Implement the Interface Countable for DomNodeList and DOMNamedNodeMap (Request #74837)

$document = new DomDocument();
$root = $document->createElement('root');
$document->appendChild($root);
for($i = 0; $i < 5; $i++) {
    $root->setAttribute('attribute-' . $i, 'value-' . $i);
}
for($i = 0; $i < 7; $i++) {
    $item = $document->createElement('item');
    $root->appendChild($item);
}

// Count childnodes
var_dump(count($root->childNodes));
var_dump($root->childNodes->count());
var_dump($root->childNodes->length);

// Count attributes
var_dump(count($root->attributes));
var_dump($root->attributes->count());
var_dump($root->attributes->length);

Does this require a RFC?

@@ -707,6 +707,7 @@ PHP_MINIT_FUNCTION(dom)
dom_nodelist_class_entry = zend_register_internal_class_ex(&ce, NULL);
dom_nodelist_class_entry->get_iterator = php_dom_get_iterator;
zend_class_implements(dom_nodelist_class_entry, 1, zend_ce_traversable);
zend_class_implements(dom_nodelist_class_entry, 1, zend_ce_countable);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to call zend_class_implements once only ...

@krakjoe krakjoe added the Feature label Jul 9, 2017
RETURN_FALSE;
}

RETURN_LONG(count);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is not right here. You're returning a zval * as a zend_long here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you probably want to do is just pass return_value as the second argument to dom_namednodemap_length_read.

}

intern = Z_DOMOBJ_P(id);
if(dom_namednodemap_length_read(intern, &count)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should compare against SUCCESS or FAILURE.

@nikic
Copy link
Member

nikic commented Jul 9, 2017

I believe this does not require an RFC. Can we get an opinion from @sgolemon and @remicollet on landing this in 7.2?

@remicollet
Copy link
Member

I believe this does not require an RFC.

I agree

Can we get an opinion from @sgolemon and @remicollet on landing this in 7.2?

LGTM

@remicollet
Copy link
Member

remicollet commented Jul 10, 2017

Thanks for your contribution.

Squashed and Merged.

@remicollet remicollet closed this Jul 10, 2017
@blar
Copy link
Contributor Author

blar commented Jul 17, 2017

@remicollet May you change my name in the NEWS file from "Andreas Treichel" to "blar"?

weltling added a commit that referenced this pull request May 29, 2021
Excerpt from the release news:

Version 10.37 26-May-2021
-------------------------

A few more bug fixes and tidies. The only change of real note is the removal of
the actual POSIX names regcomp etc. from the POSIX wrapper library because
these have caused issues for some applications (see 10.33 #2 below).

Version 10.36 04-December-2020
------------------------------

Again, mainly bug fixes and tidies. The only enhancements are the addition of
GNU grep's -m (aka --max-count) option to pcre2grep, and also unifying the
handling of substitution strings for both -O and callouts in pcre2grep, with
the addition of $x{...} and $o{...} to allow for characters whose code points
are greater than 255 in Unicode mode.

NOTE: there is an outstanding issue with JIT support for MacOS on arm64
hardware. For details, please see Bugzilla issue #2618.

Signed-off-by: Anatol Belski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants