diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2020-06-14 19:40:02 +0100 |
---|---|---|
committer | Timo Tijhof <krinklemail@gmail.com> | 2020-07-02 03:05:59 +0100 |
commit | 91c73f6bac9922925883937fa1279d42c22dd429 (patch) | |
tree | 590488cef25b32e2c98bc954df0d86c4bdd009f3 /includes/resourceloader/VueComponentParser.php | |
parent | 3b3027a6e1399ea41ec7bede3d42c784f81d3418 (diff) | |
download | mediawikicore-91c73f6bac9922925883937fa1279d42c22dd429.tar.gz mediawikicore-91c73f6bac9922925883937fa1279d42c22dd429.zip |
resourceloader: Add some typehints and misc clean up
* Add a void return hint to methods that are not meant to return
anything. This helps catch accidental return statements in the
future, lets Phan better understand how methods are meant to be
used, and might also allow PHP to better optimise the compiled
code form (speculation).
I did not, however, add it to publicly extended methods as that
might mess with strict mode.
* Remove the internal getResourceLoader() method from MessageBlobStore.
This has been redundant since 3edaa0b37c1e2684.
The method was protected, and not considered stable to subclass
for extensions. Hence not a breaking change.
* Add Throwable typehint to formatException() and friends.
This is the narrowest one I could add given that the methods
called from here already enforce the same typehint.
Update the doc to match for now. There isn't a reason right now
to limit this only to Exception, and given this is the method
and not the catch statement itself, does not change behaviour.
* Remove unused ResourceLoader->getHookContainer().
Added within 1.35 cycle, safe to remove.
* Remove unexpected `@since` for `@internal` getHookRunner().
* Remove redundant `@internal` from ResourceLoaderMwUrlModule
methods, which itself is already `@internal`.
Change-Id: I68d33ff6feca7ef95282a7ff03eb9332adfde31c
Diffstat (limited to 'includes/resourceloader/VueComponentParser.php')
-rw-r--r-- | includes/resourceloader/VueComponentParser.php | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/includes/resourceloader/VueComponentParser.php b/includes/resourceloader/VueComponentParser.php index b62ed8cf02a4..7a2aa1befca6 100644 --- a/includes/resourceloader/VueComponentParser.php +++ b/includes/resourceloader/VueComponentParser.php @@ -37,7 +37,6 @@ use RemexHtml\TreeBuilder\TreeBuilder; * @since 1.35 */ class VueComponentParser { - /** * Parse a Vue single file component, and extract the script, template and style parts. * @@ -130,7 +129,7 @@ class VueComponentParser { * @param array $allowedAttributes Attributes the node is allowed to have * @throws Exception If the node has an attribute it's not allowed to have */ - private function validateAttributes( DOMNode $node, array $allowedAttributes ) { + private function validateAttributes( DOMNode $node, array $allowedAttributes ) : void { if ( $allowedAttributes ) { foreach ( $node->attributes as $attr ) { if ( !in_array( $attr->name, $allowedAttributes ) ) { @@ -152,7 +151,7 @@ class VueComponentParser { * @param DOMNode $templateNode The <template> node * @throws Exception If the contents of the <template> node are invalid */ - private function validateTemplateTag( DOMNode $templateNode ) { + private function validateTemplateTag( DOMNode $templateNode ) : void { // Verify that the <template> tag only contains one tag, and put it in $rootTemplateNode // We can't use ->childNodes->length === 1 here because whitespace shows up as text nodes, // and comments are also allowed. |