Skip to content

Commit 8fd7808

Browse files
committed
Add MajorMinorVersion to PhpVersion objects
1 parent ef8fd1d commit 8fd7808

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

PhpManager/private/PhpVersion.ps1

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
class PhpVersion : System.IComparable
22
{
3+
<#
4+
The major.minor version of PHP
5+
#>
6+
[ValidateNotNull()]
7+
[ValidateLength(1, [int]::MaxValue)]
8+
[string] $MajorMinorVersion
39
<#
410
The version of PHP, without the alpha/beta/RC state
511
#>
@@ -8,6 +14,12 @@
814
[ValidateLength(1, [int]::MaxValue)]
915
$Version
1016
<#
17+
The version of PHP, possibly including the alpha/beta/RC state
18+
#>
19+
[ValidateNotNull()]
20+
[ValidateLength(1, [int]::MaxValue)]
21+
[string] $FullVersion
22+
<#
1123
The unstability level, if any (alpha, beta, RC)
1224
#>
1325
[string]
@@ -18,12 +30,6 @@
1830
#>
1931
[Nullable[int]] $UnstabilityVersion
2032
<#
21-
the version of PHP, possibly including the alpha/beta/RC state
22-
#>
23-
[ValidateNotNull()]
24-
[ValidateLength(1, [int]::MaxValue)]
25-
[string] $FullVersion
26-
<#
2733
A string used to display the details of the version
2834
#>
2935
[ValidateNotNull()]
@@ -76,8 +82,8 @@
7682
} else {
7783
$this.UnstabilityLevel = $null
7884
}
79-
$dv = $this.Version
80-
$cv = $this.Version
85+
$dv = $data.Version
86+
$cv = $data.Version
8187
switch ($this.UnstabilityLevel) {
8288
'' {
8389
$cv += '.9999999'
@@ -98,8 +104,11 @@
98104
throw 'Unrecognized UnstabilityLevel'
99105
}
100106
}
107+
$cv = [System.Version] $cv
108+
$this.MajorMinorVersion = '{0}.{1}' -f $cv.Major,$cv.Minor
109+
$this.Version = $data.Version
101110
$this.FullVersion = $dv
102-
$this.ComparableVersion = [System.Version] $cv
111+
$this.ComparableVersion = $cv
103112
$this.Architecture = $data.Architecture
104113
$this.ThreadSafe = $data.ThreadSafe
105114
$this.VCVersion = $data.VCVersion

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,23 @@ You can also specify a directory: the command will display the details of the PH
147147
Get-Php C:\PHP
148148
```
149149

150+
Sample Output:
151+
152+
```
153+
Folder : C:\PHP
154+
ExecutablePath : C:\PHP\php.exe
155+
ExtensionsPath : C:\PHP\ext
156+
MajorMinorVersion : 7.4
157+
Version : 7.4.0
158+
FullVersion : 7.4.0RC6
159+
UnstabilityLevel : RC
160+
UnstabilityVersion : 6
161+
DisplayName : PHP 7.4.0RC6 x86 (32-bit) Thread-Safe
162+
Architecture : x86
163+
ThreadSafe : True
164+
VCVersion : 15
165+
```
166+
150167
### Getting `php.ini` configuration keys
151168

152169
Use the `Get-PhpIniKey` command to retrieve the value of a configuration in the `php.ini` file used by a PHP installation.

test/tests/Install-Get-Update-Uninstall-Php.Tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
$initialPhpVersion.GetType().FullName | Should -BeExactly 'PhpVersionInstalled'
1414
$initialPhpVersion.Version | Should -BeOfType [string]
1515
$initialPhpVersion.Version | Should -BeExactly '7.1.0'
16+
$initialPhpVersion.MajorMinorVersion | Should -BeExactly '7.1'
1617
$initialPhpVersion.ComparableVersion | Should -BeOfType [version]
1718
$initialPhpVersion.UnstabilityLevel | Should -BeNullOrEmpty
1819
$initialPhpVersion.UnstabilityVersion | Should -BeNullOrEmpty

0 commit comments

Comments
 (0)