Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into function-get-par…
Browse files Browse the repository at this point in the history
…ams/disjunctive-normal-form
  • Loading branch information
fredden committed Mar 18, 2024
2 parents d6d83b2 + f627b49 commit 0fa04d6
Show file tree
Hide file tree
Showing 9 changed files with 316 additions and 13 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@ This projects adheres to [Keep a CHANGELOG](https://keepachangelog.com/) and use

_Nothing yet._

## [1.0.10] - 2024-03-18

### Changed

#### Other

* Dropped support for [PHP_CodeSniffer] < 3.9.0. [#561]
Please ensure you run `composer update phpcsstandards/phpcsutils --with-dependencies` to benefit from this.
* Various housekeeping and documentation improvements.

### Deprecated

#### Utils

* `NamingConventions::AZ_UPPER` constant. [#563]
* `NamingConventions::AZ_LOWER` constant. [#563]

### Fixed

#### PHPCS BackCompat

* `BackCompat\Helper::getEncoding()`: PHP 8.4 deprecation notice. [#568]
* `BackCompat\Helper::ignoreAnnotations()`: PHP 8.4 deprecation notice. [#568]

[#561]: https://github.com/PHPCSStandards/PHPCSUtils/pull/561
[#563]: https://github.com/PHPCSStandards/PHPCSUtils/pull/563
[#568]: https://github.com/PHPCSStandards/PHPCSUtils/pull/568


## [1.0.9] - 2023-12-08

Expand Down Expand Up @@ -956,6 +984,7 @@ This initial alpha release contains the following utility classes:


[Unreleased]: https://github.com/PHPCSStandards/PHPCSUtils/compare/stable...HEAD
[1.0.10]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.9...1.0.10
[1.0.9]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.8...1.0.9
[1.0.8]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.7...1.0.8
[1.0.7]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.6...1.0.7
Expand Down
11 changes: 8 additions & 3 deletions PHPCSUtils/BackCompat/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ public static function getTabWidth(File $phpcsFile)
* command-line or the ruleset.
*
* @since 1.0.0
* @since 1.0.10 The `File` type declaration has been removed from the parameter declaration.
*
* @param \PHP_CodeSniffer\Files\File|null $phpcsFile Optional. The current file being processed.
*
* @return string Encoding. Defaults to the PHPCS native default, which is 'utf-8'
* for PHPCS 3.x.
*/
public static function getEncoding(File $phpcsFile = null)
public static function getEncoding($phpcsFile = null)
{
$default = 'utf-8';

Expand All @@ -176,14 +177,18 @@ public static function getEncoding(File $phpcsFile = null)
* Check whether the "--ignore-annotations" option is in effect.
*
* @since 1.0.0
* @since 1.0.10 The `File` type declaration has been removed from the parameter declaration.
*
* @param \PHP_CodeSniffer\Files\File|null $phpcsFile Optional. The current file being processed.
*
* @return bool `TRUE` if annotations should be ignored, `FALSE` otherwise.
*/
public static function ignoreAnnotations(File $phpcsFile = null)
public static function ignoreAnnotations($phpcsFile = null)
{
if (isset($phpcsFile, $phpcsFile->config->annotations)) {
if (isset($phpcsFile)
&& $phpcsFile instanceof File
&& isset($phpcsFile->config->annotations)
) {
return ! $phpcsFile->config->annotations;
}

Expand Down
13 changes: 6 additions & 7 deletions PHPCSUtils/Utils/NamingConventions.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ final class NamingConventions
/**
* Uppercase A-Z.
*
* @since 1.0.0
* @since 1.0.0
* @deprecated 1.0.10
*
* @var string
*/
Expand All @@ -49,7 +50,8 @@ final class NamingConventions
/**
* Lowercase a-z.
*
* @since 1.0.0
* @since 1.0.0
* @deprecated 1.0.10
*
* @var string
*/
Expand Down Expand Up @@ -108,10 +110,7 @@ public static function isEqual($nameA, $nameB)
return true;
}

// OK, so these may be different names or they may be the same name with case differences.
$nameA = \strtr($nameA, self::AZ_UPPER, self::AZ_LOWER);
$nameB = \strtr($nameB, self::AZ_UPPER, self::AZ_LOWER);

return ($nameA === $nameB);
// Comparing via strcasecmp will only compare ASCII letters case-insensitively.
return (strcasecmp($nameA, $nameB) === 0);
}
}
25 changes: 25 additions & 0 deletions Tests/BackCompat/Helper/GetCommandLineDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use PHPCSUtils\BackCompat\Helper;
use PHPCSUtils\TestUtils\UtilityMethodTestCase;
use stdClass;

/**
* Test class.
Expand Down Expand Up @@ -200,4 +201,28 @@ public function testIgnoreAnnotationsSetViaProperty()

$this->assertTrue($result);
}

/**
* Test the ignoreAnnotations() method.
*
* @covers ::ignoreAnnotations
*
* @return void
*/
public function testIgnoreAnnotationsUsesGetConfigDataWhenInvalidFileParamPassed()
{
$config = null;
if (isset(self::$phpcsFile->config) === true) {
$config = self::$phpcsFile->config;
}

Helper::setConfigData('annotations', false, true, $config);

$result = Helper::ignoreAnnotations(new stdClass());

// Restore defaults before moving to the next test.
Helper::setConfigData('annotations', true, true, $config);

$this->assertTrue($result);
}
}
7 changes: 5 additions & 2 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ plugins:

phpcsutils:
packagist: phpcsstandards/phpcsutils
open_collective: php_codesniffer

# Theme info.
title: PHPCSUtils
Expand All @@ -26,11 +27,13 @@ google_analytics:
# SEO info.
tagline: "PHPCSUtils: A suite of utility functions for use with PHP_CodeSniffer."
twitter:
username: jrf_nl
username: PHP_CodeSniffer
card: summary
hashtags: PHPCSUtils
mastodon:
username: "@[email protected]"
author:
twitter: jrf_nl
twitter: PHP_CodeSniffer

# Needed so the select HTML tags do not get removed *sigh*
commonmark:
Expand Down
32 changes: 31 additions & 1 deletion docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,21 @@ <h1><a href="{{ "/" | absolute_url }}">{{ site.title | default: site.github.repo

<p class="view"><a href="{{ site.github.repository_url }}">Visit the Project on GitHub <small>{{ site.github.repository_nwo }}</small></a></p>

<p><a href="https://twitter.com/share" class="twitter-share-button" data-related="{{ site.twitter.username }}" data-count="none" data-hashtags="{{ site.twitter.hashtags }}">Tweet about it</a></p>
<p><a href="https://opencollective.com/{{ site.phpcsutils.open_collective }}/contribute" target="_blank">
<img src="https://opencollective.com/{{ site.phpcsutils.open_collective }}/contribute/[email protected]?color=blue" width=300 />
</a></p>

<div><a href="https://twitter.com/share" class="twitter-share-button" data-related="{{ site.twitter.username }}" data-count="none" data-hashtags="{{ site.twitter.hashtags }}">Tweet about it</a></div>

<div class="mastodon-share-button" data-target="{{ site.url }}" data-name="{{ site.tagline }} by {{ site.mastodon.username }}" data-buttonstyle="btn btn-secondary" data-text="Toot"></div>

<div id="modal" style="display: none;">
<label for="msb-address" name="instanceAddress">Instance address</label>
<input id="msb-address" type="text" /><br/>
<label for="msb-memorize-instance">Memorize instance</label>
<input type="checkbox" id="msb-memorize-instance" /><br/>
<button id="msb-share">share</button>
</div>

</header>
<section>
Expand Down Expand Up @@ -76,5 +90,21 @@ <h1><a href="{{ "/" | absolute_url }}">{{ site.title | default: site.github.repo
<script type="text/javascript">
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
</script>

<script>
const msbConfig = {
openModal: function () {
document.getElementById('modal').style.display = 'block';
},
closeModal: function () {
document.getElementById('modal').style.display = 'none';
},
addressFieldSelector: '#msb-address',
buttonModalSelector: '#msb-share',
memorizeFieldId: 'msb-memorize-instance',
buttonIconHtml: '<i class="fa fa-mastodon" aria-hidden="true"></i>'
};
</script>
<script src="{{ "/assets/js/mastodon.js?v=" | append: site.github.build_revision | relative_url }}"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions docs/assets/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,40 @@ header .install pre.highlight {
padding-top: 1em;
}

.mastodon-share-button {
font-size: 80%;
margin: 0 1em 0 0;
}

.mastodon-share-button .btn {
display: inline-block;
text-align: center;
vertical-align: middle;
padding: .25em 1em;
border-radius: 1rem;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out;
color: #ffffff;
background-color: #007bff;
}
.mastodon-share-button .btn:before {
content: url('data:image/svg+xml;charset=UTF-8,<svg style="color: blue" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M480,173.59c0-104.13-68.26-134.65-68.26-134.65C377.3,23.15,318.2,16.5,256.8,16h-1.51c-61.4.5-120.46,7.15-154.88,22.94,0,0-68.27,30.52-68.27,134.65,0,23.85-.46,52.35.29,82.59C34.91,358,51.11,458.37,145.32,483.29c43.43,11.49,80.73,13.89,110.76,12.24,54.47-3,85-19.42,85-19.42l-1.79-39.5s-38.93,12.27-82.64,10.77c-43.31-1.48-89-4.67-96-57.81a108.44,108.44,0,0,1-1-14.9,558.91,558.91,0,0,0,96.39,12.85c32.95,1.51,63.84-1.93,95.22-5.67,60.18-7.18,112.58-44.24,119.16-78.09C480.84,250.42,480,173.59,480,173.59ZM399.46,307.75h-50V185.38c0-25.8-10.86-38.89-32.58-38.89-24,0-36.06,15.53-36.06,46.24v67H231.16v-67c0-30.71-12-46.24-36.06-46.24-21.72,0-32.58,13.09-32.58,38.89V307.75h-50V181.67q0-38.65,19.75-61.39c13.6-15.15,31.4-22.92,53.51-22.92,25.58,0,44.95,9.82,57.75,29.48L256,147.69l12.45-20.85c12.81-19.66,32.17-29.48,57.75-29.48,22.11,0,39.91,7.77,53.51,22.92Q399.5,143,399.46,181.67Z" fill="white"></path></svg>');
}

#modal {
clear: both;
margin: 10px 0;
}

#modal #msb-share {
text-align: center;
vertical-align: middle;
padding: .25em 1em;
border-radius: 1rem;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out;
color: #ffffff;
background-color: #007bff;
}

/* General space usage/layout */
.wrapper{
width:100%;
Expand Down
Loading

0 comments on commit 0fa04d6

Please sign in to comment.