Skip to content

Commit d3988e9

Browse files
Report 4.2.0 from QueryPath::VERSION and deprecate the version constants
VERSION and VERSION_MAJOR were left at 3.2.2 and 3 through the whole 4.x line. Set them to the latest release, deprecate them in favour of Composer's InstalledVersions API, and add tests that tie VERSION to the newest release heading in CHANGELOG.md so they cannot drift again. Add the missing 4.2.0 changelog section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b41810e commit d3988e9

3 files changed

Lines changed: 24 additions & 15 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ QueryPath Changelog
3838
- Fix `writeHTML()` throwing `QueryPath\ParseException` instead of `QueryPath\IOException` when the file cannot be written, as `writeXML()` and `writeHTML5()` do (issue #92). `IOException` extends `ParseException`, so existing `catch (ParseException $e)` blocks still catch it
3939
- Fix `css()` merging the inline styles of every matched element and writing the combined result back to all of them. The new declarations are now merged into each element's own `style` attribute (issue #77)
4040
- Fix `not()` keeping only the given nodes, instead of removing them, when passed an `SplObjectStorage` such as `get(null, true)` returns (issue #75)
41+
- Fix `QueryPath::VERSION` and `QueryPath::VERSION_MAJOR` still reporting `3.2.2` and `3`. They now report `4.2.0` and `4`, and both are deprecated in favour of `\Composer\InstalledVersions::getPrettyVersion('gravitypdf/querypath')`, which cannot drift from the installed version (issue #83)
42+
43+
# 4.2.0
44+
45+
- Add PHP 8.5 support
4146

4247
# 4.1.0
4348

‎src/QueryPath.php‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,18 @@ class QueryPath
9999
/**
100100
* The version string for this version of QueryPath.
101101
*
102-
* Standard releases will be of the following form: <MAJOR>.<MINOR>[.<PATCH>][-STABILITY].
103-
*
104-
* Examples:
105-
* - 2.0
106-
* - 2.1.1
107-
* - 2.0-alpha1
108-
*
109-
* Developer releases will always be of the form dev-<DATE>.
110-
*
111102
* @since 2.0
103+
* @deprecated Use \Composer\InstalledVersions::getPrettyVersion('gravitypdf/querypath') (Composer 2).
112104
*/
113-
public const VERSION = '3.2.2';
105+
public const VERSION = '4.2.0';
114106

115107
/**
116108
* Major version number.
117109
*
118-
* Examples:
119-
* - 3
120-
* - 4
121-
*
122110
* @since 3.0.1
111+
* @deprecated Use \Composer\InstalledVersions::getPrettyVersion('gravitypdf/querypath') (Composer 2).
123112
*/
124-
public const VERSION_MAJOR = 3;
113+
public const VERSION_MAJOR = 4;
125114

126115
/**
127116
* This is a stub HTML 4.01 document.

‎tests/QueryPath/QueryPathTest.php‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ public function testEnable()
4545

4646
$this->assertTrue($qp->grrrrrrr());
4747
}
48+
49+
public function testVersionMajorMatchesVersion()
50+
{
51+
$this->assertSame((int) explode('.', QueryPath::VERSION)[0], QueryPath::VERSION_MAJOR);
52+
}
53+
54+
/**
55+
* Releasing turns "# Unreleased changes" into a version heading, so VERSION must be bumped alongside it.
56+
*/
57+
public function testVersionMatchesLatestChangelogRelease()
58+
{
59+
preg_match('/^# (\d+\.\d+\.\d+)$/m', file_get_contents(__DIR__ . '/../../CHANGELOG.md'), $matches);
60+
61+
$this->assertSame($matches[1], QueryPath::VERSION);
62+
}
4863
}
4964

5065
class DummyExtension implements Extension

0 commit comments

Comments
 (0)