Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion linux/phpvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ _phpvm_levenshtein() {
}

# Canonical command list (includes aliases) for suggestions.
_PHPVM_COMMANDS="install use list ls current uninstall remove which ini deps ext composer wp-cli fix-ini auto hook upgrade update version help"
_PHPVM_COMMANDS="install use list ls current uninstall remove which doctor ini deps ext composer wp-cli fix-ini auto hook upgrade update version help"

# Unknown command: suggest the nearest match instead of dumping the full help.
_phpvm_unknown() {
Expand Down
6 changes: 6 additions & 0 deletions tests/linux/commands.bats
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ EOF
[[ "$output" != *"Did you mean"* ]]
}

@test "unknown: suggests doctor for a doctor typo" {
run phpvm doctro
[ "$status" -ne 0 ]
[[ "$output" == *"Did you mean 'doctor'?"* ]]
}

# ---------- partial version resolution ----------

@test "resolve: full x.y.z passes through without network" {
Expand Down
5 changes: 5 additions & 0 deletions tests/windows/PureFunctions.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ Describe 'Invoke-Unknown' {
$out | Should -Match "is not a phpvm command"
$out | Should -Not -Match "Did you mean"
}

It 'Suggests doctor for a doctor typo' {
$out = Invoke-Unknown 'doctro' 6>&1 | Out-String
$out | Should -Match "Did you mean 'doctor'\?"
}
}

Describe 'Get-PHPZipHash' {
Expand Down
8 changes: 3 additions & 5 deletions windows/phpvm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1165,9 +1165,7 @@ function Ext-Info ([string]$extName) {
if (extension_loaded('$extName')) {
`$r = new ReflectionExtension('$extName');
echo 'Name : ' . `$r->getName() . PHP_EOL;
`$version = `$r->getVersion();
if (`$version -eq `$null) { `$version = 'n/a'; }
echo 'Version : ' . `$version . PHP_EOL;
echo 'Version : ' . (`$r->getVersion() ?? 'n/a') . PHP_EOL;
`$classes = `$r->getClassNames();
if (`$classes) echo 'Classes : ' . implode(', ', `$classes) . PHP_EOL;
} else {
Expand Down Expand Up @@ -1592,7 +1590,6 @@ function Invoke-Cacert ([string]$sub) {
}


# Read-only health check. Never mutates state - every finding points at the
# True when the ini's extension_dir points at the active version's ext folder.
# `current` is a junction to versions\<cur>, so the versions\<cur>\ext and
# current\ext spellings name the same directory - accept either rather than
Expand All @@ -1604,6 +1601,7 @@ function Test-ExtDirMatch ([string]$iniExtDir, [string]$cur) {
return ($acceptable -icontains $iniExtDir.TrimEnd('\'))
}

# Read-only health check. Never mutates state - every finding points at the
# command that fixes it. Exit-code-neutral: it's a report, not a gate.
function Invoke-Doctor {
Write-Host ""
Expand Down Expand Up @@ -1751,7 +1749,7 @@ function Get-Levenshtein ([string]$a, [string]$b) {
# Unknown command: suggest the nearest match instead of dumping the full help.
function Invoke-Unknown ([string]$cmd) {
$cmds = @("install","use","list","ls","current","uninstall","remove",
"which","ini","fix-ini","cacert","ext","composer","wp-cli","auto","hook",
"which","ini","fix-ini","cacert","doctor","ext","composer","wp-cli","auto","hook",
"upgrade","update","version","help")
$best = ""; $bestd = 99
foreach ($c in $cmds) {
Expand Down
Loading