Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHPStan & Fix existing errors (no backwards-compatibility breaks) #3

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ foreach ($domains as $domain) {
}
```

## Contributing

When contributing to this project, you can run the following quality checks:

```bash
$ vendor/bin/phpstan
```

## License

The MIT License (MIT)
Expand All @@ -223,4 +231,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
"guzzlehttp/psr7": "^1.7",
"psr/log": "^1.1",
"spatie/enum": "^3.6",
"guzzlehttp/guzzle": ">=6"
"guzzlehttp/guzzle": ">=6",
"illuminate/pagination": "^5.8|^6.0|^7.0|^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"php-http/mock-client": "^1.4",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan": "^0.12.81",
"phpunit/phpunit": "^8.5",
"squizlabs/php_codesniffer": "^3.5",
"monolog/monolog": "^2.1",
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 0
paths:
- src
6 changes: 4 additions & 2 deletions src/Managers/FolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class FolderManager extends AbstractManager implements FolderManagerInterface, L
*
* @param int $page
* @param int $perPage
* @param array $filters

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the interface it should be array|null

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No right? Because you cannot literally pass null?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has a default value, but not a type on the method itself.
So if you ignore the docblock you can pass in literally anything 😉

* @return \DnsMadeEasy\Pagination\Paginator|mixed
* @throws \DnsMadeEasy\Exceptions\Client\Http\HttpException
* @throws \ReflectionException
*/
public function paginate(int $page = 1, int $perPage = 20)
public function paginate(int $page = 1, int $perPage = 20, $filters = [])
{
$response = $this->client->get($this->getBaseUri());
$data = json_decode((string)$response->getBody());
Expand Down Expand Up @@ -79,4 +81,4 @@ protected function transformConciseApiData(object $data): object
'label' => $data->label,
];
}
}
}