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

Release 1.0.0-alpha4 #399

Merged
merged 661 commits into from
Oct 25, 2022
Merged

Release 1.0.0-alpha4 #399

merged 661 commits into from
Oct 25, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Oct 25, 2022

Release checklist

Update website

General

  • Verify, and if necessary, update the version constraints for dependencies in the composer.json - N/A
  • Verify that any new functions have type declarations whenever possible.
  • Add changelog for the release - PR Changelog for PHPCSUtils 1.0.0-alpha4 #398
    ✏️ Remember to add a release link at the bottom and to adjust the link for "Unreleased"!

Release

  • Merge this PR
  • Make sure all CI builds are green.
  • Verify that the website regenerated correctly.
  • Tag the release (careful, GH defaults to develop!).
  • Create a release from the tag (careful, GH defaults to develop!) & copy & paste the changelog to it.
    ✏️ Don't forget to copy the link collection from the bottom of the changelog!
  • Close the milestone
  • Open a new milestone for the next release
  • If any open PRs/issues which were milestoned for this release did not make it into the release, update their milestone.
  • Fast-forward develop to be equal to stable

Publicize

  • Tweet about the release.
  • Inform the primary dependants of this repo (PHPCSExtra, WordPressCS, PHPCompatibility and VariableAnalysis) about the release.

jrfnl and others added 30 commits June 28, 2022 11:43
…ionnametokens-sync-with-upsteam

BCTokens::functionNameTokens(): sync with upstream
…vers-tags

Tests: simplify the `@covers` tags in a couple of test files
Keep the order of the methods alphabetic.
Follow up to PR 327. This simplifies the code a little.
…change for `parent`

Upstream PR squizlabs/PHP_CodeSniffer 3546, which is included in PHPCS 3.7.0, changed the tokenization of the `parent` keyword in `new parent()` from `T_STRING` to `T_PARENT`.

This has consequences for the `PassedParameters::hasParameters()` method and associated methods:
* The `Collections::parameterPassingTokens()` method will now need to include the `T_PARENT` token.
* The underlying `Collections::functionCallTokens()` method should as well.
* The `PassedParameters::hasParameters()` method now needs to allow for the `T_PARENT` token potentially being used as part of a `new parent()` function call.

This commit fixes all that up.

Includes additional unit tests to safeguard it all (and some more).
…eters-account-for-parent-tokenization-change

PassedParameters::hasParameters(): account for upstream tokenization change for `parent`
While the feedback shown in the `setup-php` step is awesome, it doesn't show the version of Xdebug used when running code coverage, while, in case of issues, the version number of Xdebug is crucial to know.

This extra step allows for that information to always be available.

I've only added the step to the code coverage job though as that's the only one for which the Xdebug version is relevant.
The functions being tested in these three test classes all use function local `static` variables for optimization.

Having the function local `static` variable will often prevent code coverage from being recorded correctly for the code as the code for setting the static will only be run when the function is first called, which may not be in the dedicated test for the function, so it makes code coverage recording highly dependant on the order in which tests are run.

In these three cases, I do believe the function local `static` variable is justified (for the time being, benchmarking should be able to determine for sure at some point in the future).

To still prevent missed lines in the code coverage reports, I'm moving the tests for these three functions into a separate test suite, which will run first.
This should ensure the code which sets the static will be run first when the dedicated tests for these methods are run and should allow the correct registration of code coverage for this code.

Mind: if at some point the `executionOrder` configuration would be added to the config/enabled, it needs to be verified how that behaves in combination with multiple test suites. But that's for later.

Ref: sebastianbergmann/php-code-coverage#913
... for code which is only in place as defensive coding, but shouldn't be reachable under normal circumstances.
…rage-fixes

QA/Tests: various code coverage tweaks
... when the data set array contains more than one item.

This is done to lower the cognitive load when reading the tests.

Includes:
* Renaming a couple of parameters for more consistency.
* Renaming data provider sub-array keys if they didn't match the parameter names of the test function.

Note: this changeset excludes the `isShortArrayOrList` tests. Those tests will be addressed separately in the refactor of those methods.

Hoping I've caught everything, but not claiming completeness.
…ames-in-dataproviders

Tests: use parameter names in data provider test cases
... using the PHPUnit `--repeat` option.

Note: this option was already available in PHPUnit 4.x, so can be safely used for this codebase.

The changes made:
* Prevent "constant already defined notices" on repeated test runs.
* Prevent a file from not being tokenized on repeated test runs.

Ref:
* https://phpunit.readthedocs.io/en/9.5/textui.html
…s-to-allow-for-repeat-test-runs

Tests: minor tweaks to allow for running tests on repeat
Based on a similar class I wrote for the Requests library.

If/when that class get published as a package, this class should be removed in favour of the package.
... to allow for caching the results of processing intensive utility methods.

The `Cache` class is intended to be used for utility functions which depend on the `$phpcsFile` object.
The `NoFileCache` class is for file-independent functions.

Use selectively and with care as the memory usage of PHPCS will increase when using these caches!

Includes full set of tests to cover this new functionality.

These new tests have been added to the `RunFirst` test suite to prevent the cache setting and clearing done in these tests from interfering with the rest of the tests.
Includes:
* Additional tests to cover this change on the off-chance that someone will use this functionality in a non-test situation.
* Making sure that the tests related to the `[NoFile]Cache` classes will always run with caching turned **on** as running the cache functionality tests without caching enabled is a little pointless (and would fail the tests).
…ew `Cache` class

As `declare` constructs using alternative syntax can be long, determining the scope opener/closer can involve a lot of token walking, which is why I'm implementing caching for it.

Includes some minor tweaks to the exit routes of the function to ensure that the cache will always be set when the `T_DECLARE` token doesn't natively have a scope opener/closer assigned.

Includes a dedicated test to verify the cache is used and working.
…he new `Cache` class

While arrow functions are generally only small snippets of code, as they don't always have a clear "end token", determining whether something is an arrow function and retrieving the relevant open/close tokens can be token-walking intensive, which is why I'm implementing caching for it.

Note: the results will only be cached for the backported functionality. When using a more recent PHPCS version, the cache code will only be reached in the case of parse errors.

Includes a dedicated test to verify the cache is used and working.
This method searches up in a file to try and find an applicable namespace declaration.
As non-scoped namespace declarations are often at the top of the file, this can involve a **_lot_** of token walking, which is why I'm implementing caching for it.

Includes some minor tweaks to the exit routes of the function to ensure that the cache will always be set when the token passed is not in a scoped namespace declaration.

Includes a dedicated test to verify the cache is used and working.
…lass

While most function calls only involve a few parameters, splitting out an array into the individual array items can be very processing intense and will slow things down considerably when multiple sniffs each need the break down of the same array.

With this in mind, I'm implementing caching for it.

The saved cache can be quite large for calls to this function, at the same time, the trade off performance-wise is worth it in this case IMO.

Note: as this function can be called with a `$limit`, we need to be able to distinguish between "limited" results and "full" results, but should also take advantage of available "full" results when a consecutive function call tries to retrieve a "limited" result.

The implementation takes this into account, though the situation where a "limited" result was previously retrieved (and cached), and new "limited" call is made with a _lower_ limit currently does not take full advantage of the available cache. This is possibly an improvement which can still be made in the future.

Includes a set of dedicated tests to verify the cache is used and working, including testing specifically how the cache is set and used when the `$limit` parameter has been passed.
…Cache` class

This method finds the end of a potentially multi-line text string.
While most text strings are short and even multi-line ones are often only a few lines, some can be thousands of lines long.
With that in mind, I'm implementing caching for this method.

I've considered also applying caching for the `TextStrings::getCompleteTextString()` method, but as - in the case of thousands of lines long text - that would take a huge chunk of memory, I've decided against it.
Caching the "end token" of a multi-line text string should sufficiently improve performance.

Includes a dedicated test to verify the cache is used and working.
…ache` class

Depending on whether or not group use or multi-use statements are used, this method can involve sufficient token walking to make caching relevant.
Especially when keeping in mind that this function will likely be used a **_lot_** in the near future as part of the namespace resolution functionality, so retrieving the results via the cache instead of executing the same logic dozens of times for a file, seem prudent.

Includes a dedicated test to verify the cache is used and working.
jrfnl and others added 27 commits October 25, 2022 10:29
As the new `IsShortArrayOrListWithCache` class will now be the entry point to the `IsShortArrayOrList` class, we can rely upon the token being passed to the `IsShortArrayOrList` always being an _opener_ for a complete set of brackets and can remove some redundancy from the `IsShortArrayOrList` class.

Includes making the exception for when an incorrect token is passed more specific.

Includes updating the `IsShortArrayOrList` tests to no longer pass closer tokens to the `IsShortArrayOrList` class.
This is step 3 in a refactor to improve short list/short array determination.

This refactor adds a number of extra interim steps to try and avoid, whenever possible, walking the complete file to find "outer" brackets for nested short lists/arrays.

This should improve performance of the functionality.

Additionally, the interim steps will also provide higher accuracy of the results.

Includes adding a set of dedicated tests to cover the functionality in each method in the `IsShortArrayOrList` class.

The generic `PHPCSUtils\Internal\IsShortArrayOrList\IsShortArrayOrListTest` still remains for arbitrary short list vs short array tests (though some tests have moved to the method specific test classes).
A significant number of these tests would previously lead to incorrect results for the short list/short array determination. The refactor fixed these.

* Add tests involving short lists with short arrays as keys.
    I seriously mean the inline remark: "Please sack anyone who writes code like this".
* Add extra test for nested short list with empties.
* Add extra tests involving comma separated lists of variables as in that case, there is the most significant risk of mis-identifying the token.
* Add extra tests for short arrays/lists as values in a short array.
…array-refactor-improve-performance

IsShortArrayOrList: refactor for better accuracy and improved performance
Includes:
* Fixing some spelling errors.
* Adding missing `@since` tags.
* Adding missing link descriptions.
* A few `http` to `https` fixes.
* Move `@covers` tags from class level to method level for abstract test cases.
Docs: various updates to the docblocks and inline comments
Includes:
* Updating the "Tested on PHP" badge to include PHP 8.2.
* A few `http` to `https` fixes.
* Minor formatting improvements.
... after recent fixes in phpDocumentor3.
... using the latest released version of phpDocumentor (`3.3.1`) so the diff for the actual regen of version 1.0.0-alpha4 will only show the differences in content, not document structure.
The docs have been regenerated using phpDocumentor 3.3.1 with `--visibility=public,protected`.
* Always display link to the project on GH.
    The `site.github.is_project_page` key does not seem to be reliable.
* Display the version number of the last release, if available.
* Always display the "Maintained by" link.
* Remove duplicate `header` close tag.
Includes adding a `commonmark` configuration to prevent Commonmark blindly stripping _all_ HTML.
…guration-and-content

Docs website: update for release of PHPCSUtils 1.0.0-alpha4
... ahead of actually renaming the branch (just before release).
…nch-rename

Update all references to the main branch from `master` to `stable`
…lpha4

Changelog for PHPCSUtils 1.0.0-alpha4
@jrfnl jrfnl added this to the 1.0.0-alpha4 milestone Oct 25, 2022
@jrfnl jrfnl merged commit 37c6da9 into stable Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants