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

optimized some ignore rules in the phpstan-baseline.neon #456

Conversation

TheNorthMemory
Copy link
Contributor

  • Improved the codes and comments, cleanup the ignore rules in the phpstan-baseline.neon;
  • The pcre.backtrack_limit settings may be affected the function preg_split's behavior. While there were a customized value (less than 5), it can caused the Header::parse and Header::normalize working incorrectly. Optimize codes for this case.

$limited = ini_get('pcre.backtrack_limit');
ini_set('pcre.backtrack_limit', '4');
$things = ['"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"'];
self::assertSame(['"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"'], Psr7\Header::normalize($things));
Copy link
Contributor

Choose a reason for hiding this comment

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

This assertion is bogus. However the backtrack limit is a good reason to not rely on regular expressions here. See: #447

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. Rely on the regular expression may not a good idea. For example, parsing the new Permissions-Policy's value, eg: Permissions-Policy: fullscreen=(self "https://example.com" "https://another.example.com"), geolocation=*, camera=(), there were the parentheses, self, none, empty string and double quotes strings, it shall be so hard to do that.

src/Uri.php Outdated Show resolved Hide resolved
src/Uri.php Outdated Show resolved Hide resolved
src/Uri.php Outdated Show resolved Hide resolved
src/Utils.php Outdated Show resolved Hide resolved
src/StreamWrapper.php Outdated Show resolved Hide resolved
src/UploadedFile.php Outdated Show resolved Hide resolved
@TheNorthMemory TheNorthMemory changed the title cleanup the ignore rules in phpstan-baseline.neon optimized some ignore rules in the phpstan-baseline.neon Dec 8, 2021
src/StreamWrapper.php Outdated Show resolved Hide resolved
src/Uri.php Outdated Show resolved Hide resolved
src/Uri.php Outdated Show resolved Hide resolved
src/UriNormalizer.php Outdated Show resolved Hide resolved
@GrahamCampbell
Copy link
Member

There are a lot of changes here, and it's not clear if any bugs are actually fixed. Since there are merge conflicts, we're not able to merge at this time. Please feel free to re-submit a PR fixing a specific bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants