Skip to content

Commit

Permalink
Add more use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
valendesigns committed Feb 16, 2019
1 parent c337980 commit 1404c5d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
20 changes: 2 additions & 18 deletions phpcompat/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,10 @@ func Parse(e tide.PhpcsFilesMessage) (Compatibility, error) {
reported,
majorMinor,
}
} else if e.Source == "PHPCompatibility.PHP.EmptyNonVariable.Found" {
} else {
version := PreviousVersion(versions[0])
low, high, majorMinor, reported := GetVersionParts(version, "5.2.0")

breaks = &CompatibilityRange{
low,
high,
reported,
majorMinor,
}
} else {
low, high, majorMinor, reported := GetVersionParts(versions[0], versions[0])

breaks = &CompatibilityRange{
low,
high,
Expand Down Expand Up @@ -199,14 +190,7 @@ func Parse(e tide.PhpcsFilesMessage) (Compatibility, error) {
majorMinor,
}
case "not supported since":
low, high, majorMinor, reported := GetVersionParts(versions[0], versions[0])

breaks = &CompatibilityRange{
low,
high,
reported,
majorMinor,
}
fallthrough
case "available since":
if breaks != nil {
breaks.Low = "5.2.1"
Expand Down
5 changes: 5 additions & 0 deletions phpcompat/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ var (
Source: "PHPCompatibility.PHP.ValidIntegers.InvalidOctalIntegerFound",
Type: "ERROR",
},
"PHPCompatibility.PHP.LanguageConstructs.NewEmptyNonVariableFound": {
Message: "Only variables can be passed to empty() prior to PHP 5.5.",
Source: "PHPCompatibility.PHP.LanguageConstructs.NewEmptyNonVariableFound",
Type: "ERROR",
},
"PHPCompatibility.PHP.EmptyNonVariable.Found": {
Message: "Only variables can be passed to empty() prior to PHP 5.5.",
Source: "PHPCompatibility.PHP.EmptyNonVariable.Found",
Expand Down
7 changes: 7 additions & 0 deletions phpcompat/phpcompat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ func TestBreaksVersions(t *testing.T) {
},
[]string{"7.0", "7.1", "7.2"},
},
{
"PHPCompatibility.PHP.LanguageConstructs.NewEmptyNonVariableFound",
args{
testMessages["PHPCompatibility.PHP.LanguageConstructs.NewEmptyNonVariableFound"],
},
[]string{"5.2", "5.3", "5.4"},
},
{
"PHPCompatibility.PHP.EmptyNonVariable.Found",
args{
Expand Down

0 comments on commit 1404c5d

Please sign in to comment.