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

More specific type for 'port' component of 'parse_url()' #1622

Merged
merged 1 commit into from Aug 16, 2022

Conversation

thg2k
Copy link
Contributor

@thg2k thg2k commented Aug 15, 2022

The port component can only be in the range 0-65535:

<?php
var_dump(parse_url("http://localhost:-1/"));    // false
var_dump(parse_url("http://localhost:0/"));     // [ ... ]
var_dump(parse_url("http://localhost:65535/")); // [ ... ]
var_dump(parse_url("http://localhost:65536/")); // false

@@ -122,17 +122,17 @@ private function cacheReturnTypes(): void
}

$string = new StringType();
$integer = new IntegerType();
$port = new IntegerRangeType(0, 65535);
Copy link
Contributor

Choose a reason for hiding this comment

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

should use IntegerRangeType::fromInterval(...)

Copy link
Contributor

Choose a reason for hiding this comment

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

interesting, brb opening a PR that prevents that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would've never guessed that! Force-pushed with the requested change.

@thg2k
Copy link
Contributor Author

thg2k commented Aug 16, 2022

I'm sorry I just realized I missed a couple of tests, gotta love that CI.

Made another force push to fix that, let me know if there are other outstanding issues.

@ondrejmirtes
Copy link
Member

gotta love that CI.

Yeah, I'm super-proud of that, thanks :)

And thanks for this PR!

@ondrejmirtes ondrejmirtes merged commit 4add218 into phpstan:1.8.x Aug 16, 2022
@thg2k thg2k deleted the pr/parse_url_intrange branch August 16, 2022 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants