Commit graph

40 commits

Author SHA1 Message Date
divinity76
761b9a44f8 Fix return value in stub file for DOMNodeList::item
Not explicitly documenting the possibility of returning DOMElement causes
the Intelephense linter (a popular PHP linter with ~9 million downloads:
https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client)
to think this code is bad:

  $xp->query("whatever")->item(0)->getAttribute("foo");

DOMNode does not have getAttribute (while DOMElement does).
Documenting the DOMElement return type should fix Intelephense's linter.

Closes GH-11342.
2023-05-29 18:49:26 +02:00
Máté Kocsis
8168d312f9
Fix a few more classsynopsis generation issues
Closes GH-7480
2021-09-22 23:09:43 +02:00
Máté Kocsis
25cbd08470
Make a few unuseful DOMEntity properties readonly (#7406) 2021-08-26 10:37:45 +02:00
Máté Kocsis
cdf2f3eb16
DOMCharacterData::$data and DOMAttr::$value are writable 2021-08-25 09:25:22 +02:00
Nikita Popov
ca94d55a19 Mark DOM classes as not serializable 2021-08-10 14:22:26 +02:00
Máté Kocsis
da2cd931e5
Fix another DOMNameSpaceNode casing issue 2021-08-05 09:05:33 +02:00
Máté Kocsis
23b1c4a982
Migrate to PHP-Parser 4.12.0 and regenerate some arginfos 2021-07-22 09:40:16 +02:00
Nikita Popov
239446c5cf Merge branch 'PHP-8.0'
* PHP-8.0:
  dom_import_simplexml() cannot return null
2021-07-21 11:14:03 +02:00
Nikita Popov
a0893865b3 dom_import_simplexml() cannot return null 2021-07-21 11:13:37 +02:00
Nikita Popov
1602db2d3f Fix return type of DOMNodeList::item()
It can also return DOMNameSpaceNode :(
2021-07-21 09:56:35 +02:00
Máté Kocsis
d9838e5453
Declare tentative return types for ext/dom (#6985) 2021-07-20 09:26:36 +02:00
Nikita Popov
c2a58ab07d Throw DomException for DOM out-of-memory error conditions
A number of error conditions in DOM can only occur if libxml2 runs
out of memory, at least as far as I can see. In such cases we
currently do a silent "return false", which violates the DOM spec,
and which code is very unlikely to handle sensibly.

Switch these to throw a DomException with INVALID_STATE_ERR type.
This error type is chosen because we use for similar checks
elsewhere, for example:
a733b1ada7/ext/dom/documentfragment.c (L45-L48)

This changes some of the more obvious cases I spotted, but there are probably more.

Closes GH-7049.
2021-07-19 14:43:31 +02:00
Nikita Popov
b9893c2a18 Actually add the tentative type marker... 2021-07-16 16:33:47 +02:00
Nikita Popov
cad6144d18 Add minimial tentative types to dom
Just for implementations of Countable. These (no longer) suffer
from an overly broad return type.
2021-07-16 16:32:12 +02:00
Nikita Popov
4cf0269e4e DOMNamedNodeMap::count() cannot return false 2021-07-16 16:27:53 +02:00
Nikita Popov
f089e8afbd DOMNodeList::count() cannot return false
Refactor the implementation to make this obvious, and make use
of early returns.
2021-07-16 16:22:52 +02:00
Máté Kocsis
7da2151f7a
Declare typed properties in ext/dom
Closes GH-7013
2021-05-26 12:23:43 +02:00
Máté Kocsis
a5e938dc86
Declare dynamic properties in ext/dom
Closes GH-6644
2021-05-18 15:12:35 +02:00
Máté Kocsis
bf0f6aaf18
Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Máté Kocsis
45fa7596dc
Add missing classes to stubs 2021-02-09 22:38:06 +01:00
Máté Kocsis
99b08ac281
Implicitly enable function entry generation when class entry generation is enabled
Closes GH-6675
2021-02-09 13:37:24 +01:00
Nikita Popov
e32d5e8fe7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make createDocument() $namespace nullable
2021-02-09 12:29:50 +01:00
Nikita Popov
3549f48edc Make createDocument() $namespace nullable
According to the DOM specification, this argument should be
nullable. It's also supposed to be a required argument, but
not changing that at this point.
2021-02-09 12:28:28 +01:00
Nikita Popov
cfb94b22d5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make getElementsByTagNameNS $namespace nullable
2021-02-09 12:20:56 +01:00
Nikita Popov
ab92ffee22 Make getElementsByTagNameNS $namespace nullable
According to the DOM specification, this argument is supposed to
be nullable.
2021-02-09 12:19:44 +01:00
Máté Kocsis
5f21062054
Generate class entries for a few extensions
Relates to GH-6644
2021-02-03 09:24:09 +01:00
Máté Kocsis
1954e59758
Add support for generating class entries from stubs
Closes GH-6289

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-01-26 11:50:36 +01:00
Máté Kocsis
9cec093b7f
Add support for generating methodsynopses from stubs
Closes GH-6367
2020-12-28 14:44:43 +01:00
Nikita Popov
27e250880b Fix bug #80537
This is an unavoidable breaking change to both the type and
parameter name.

The assertion that was supposed to prevent this was overly lax
and accepted any object type for string parameters.
2020-12-21 10:21:50 +01:00
George Peter Banyard
8fef83dd3c Promote warnings to error in DOM extension
Closes GH-5418
2020-09-22 19:12:32 +01:00
Máté Kocsis
c76910cd96
Display types in stubs more uniformly
In preparation for generating method signatures for the manual.

This change gets rid of bogus false|null return types, a few unnecessary trailing backslashes, and settles on using ? when possible for nullable types.
2020-09-16 21:19:36 +02:00
Máté Kocsis
2803c8fb8d
Add all the missing parameter types to stubs
Closes GH-5955
2020-08-13 14:47:18 +02:00
Benjamin Eberlei
8a6bc6767d Consolidate Parameter Names For ext/dom
Co-authored-by: Thomas Weinert <thomas@weinert.info>
2020-07-27 21:42:33 +02:00
Nikita Popov
d625c29df7 Remove spurious return true from DOMXPath::registerPhpFunctions()
Only one of three identical cases returned true, and the function
is documented to return void. Remove the outlier.
2020-07-17 16:11:30 +02:00
Nikita Popov
d449d1dbbf Use string|array type in DOMXPath::registerPhpFunctions() 2020-07-17 16:10:49 +02:00
Máté Kocsis
30067894fc
Update outdated arginfo hashes 2020-06-30 16:02:11 +02:00
Nikita Popov
ff19ec2df3 Introduce InternalIterator
Userland classes that implement Traversable must do so either
through Iterator or IteratorAggregate. The same requirement does
not exist for internal classes: They can implement the internal
get_iterator mechanism, without exposing either the Iterator or
IteratorAggregate APIs. This makes them usable in get_iterator(),
but incompatible with any Iterator based APIs.

A lot of internal classes do this, because exposing the userland
APIs is simply a lot of work. This patch alleviates this issue by
providing a generic InternalIterator class, which acts as an
adapater between get_iterator and Iterator, and can be easily
used by many internal classes. At the same time, we extend the
requirement that Traversable implies Iterator or IteratorAggregate
to internal classes as well.

Closes GH-5216.
2020-06-24 15:31:41 +02:00
Nikita Popov
c9b9f525a9 Include stub hash in generated arginfo files
The hash is used to check whether the arginfo file needs to be
regenerated. PHP-Parser will only be downloaded if this is actually
necessary.

This ensures that release artifacts will never try to regenerate
stubs and thus fetch PHP-Parser, as long as you do not modify any
files.

Closes GH-5739.
2020-06-24 09:55:19 +02:00
Máté Kocsis
3ebce8e9fc
Fix UNKNOWN default values in various extensions
Closes GH-5514
2020-05-05 19:08:20 +02:00
Máté Kocsis
dfd0acf0d7
Generate method entries for ext/dom
Closes GH-5374
2020-04-13 00:13:11 +02:00