-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from boesing/feature/allow-int-for-string-plac…
…eholder Feature: introduce option to disallow integers for string placeholders
- Loading branch information
Showing
12 changed files
with
237 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ptance/PrintfInvalidArgumentForSpecifierWithDisallowedIntegerForStringPlaceholder.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Feature: Integer is not allowed to be passed to printf string placeholder when option is set | ||
|
||
Background: | ||
Given I have the following config | ||
""" | ||
<?xml version="1.0"?> | ||
<psalm errorLevel="1" findUnusedPsalmSuppress="true"> | ||
<projectFiles> | ||
<directory name="."/> | ||
</projectFiles> | ||
<issueHandlers> | ||
<UnusedFunctionCall> | ||
<errorLevel type="suppress"> | ||
<directory name="."/> | ||
</errorLevel> | ||
</UnusedFunctionCall> | ||
</issueHandlers> | ||
<plugins> | ||
<pluginClass class="Boesing\PsalmPluginStringf\Plugin"> | ||
<experimental> | ||
<ReportPossiblyInvalidArgumentForSpecifier allowIntegerForString="no"/> | ||
</experimental> | ||
</pluginClass> | ||
</plugins> | ||
</psalm> | ||
""" | ||
And I have the following code preamble | ||
""" | ||
<?php declare(strict_types=1); | ||
""" | ||
|
||
Scenario: template requires string but integer is passed | ||
Given I have the following code | ||
""" | ||
printf('%s', 1); | ||
sprintf('%s', 1); | ||
""" | ||
When I run Psalm | ||
Then I see these errors | ||
| Type | Message | | ||
| PossiblyInvalidArgument | Argument 1 inferred as "1" does not match (any of) the suggested type(s) "string" | | ||
| PossiblyInvalidArgument | Argument 1 inferred as "1" does not match (any of) the suggested type(s) "string" | | ||
And I see no other errors |