From 225b742291f2b5567ba6145119f13f8fda862911 Mon Sep 17 00:00:00 2001 From: Xymph Date: Fri, 27 Aug 2021 14:06:31 +0200 Subject: [PATCH] Fix exception message for $keyNames in WikiPage::getAllSections() --- CHANGELOG.md | 2 ++ USAGE.md | 2 +- Wikimate.php | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23ddcda..4548163 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and may require changes in applications that invoke these methods:_ #### Fixed * Fixed one error return value in `WikiPage::setText()` ([#129]) +* Fixed exception type/message for `$keyNames` parameter to `WikiPage::getAllSections()` ([#133]) #### Removed @@ -184,3 +185,4 @@ and may require changes in applications that invoke these methods:_ [#130]: https://github.com/hamstar/Wikimate/pull/130 [#131]: https://github.com/hamstar/Wikimate/pull/131 [#132]: https://github.com/hamstar/Wikimate/pull/132 +[#133]: https://github.com/hamstar/Wikimate/pull/133 diff --git a/USAGE.md b/USAGE.md index ac8820b..f06a5cf 100644 --- a/USAGE.md +++ b/USAGE.md @@ -127,7 +127,7 @@ Array ) ``` -An Exception is thrown if an unsupported value is supplied for the $keyNames parameter. +An `UnexpectedValueException` is thrown if an unsupported value is supplied for the `$keyNames` parameter. #### Writing... diff --git a/Wikimate.php b/Wikimate.php index ab2829d..e1b7508 100644 --- a/Wikimate.php +++ b/Wikimate.php @@ -891,7 +891,7 @@ public function __construct($title, $wikimate) { $this->wikimate = $wikimate; $this->title = $title; - $this->sections = new stdClass(); + $this->sections = new \stdClass(); $this->text = $this->getText(true); if ($this->invalid) { @@ -1206,7 +1206,7 @@ public function getSection($section, $includeHeading = false, $includeSubsection * @param boolean $includeHeading False to get section text only * @param integer $keyNames Modifier for the array key names * @return array Array of sections - * @throw Exception If $keyNames is not a supported constant + * @throw UnexpectedValueException If $keyNames is not a supported constant */ public function getAllSections($includeHeading = false, $keyNames = self::SECTIONLIST_BY_INDEX) { @@ -1220,7 +1220,7 @@ public function getAllSections($includeHeading = false, $keyNames = self::SECTIO $array = array_keys($this->sections->byName); break; default: - throw new Exception('Unexpected parameter $keyNames given to WikiPage::getAllSections()'); + throw new \UnexpectedValueException("Unexpected keyNames parameter ($keyNames) passed to WikiPage::getAllSections()"); break; }