Skip to content

Commit

Permalink
Merge pull request #275 from PHPCSStandards/develop
Browse files Browse the repository at this point in the history
Release PHPCSExtra 1.1.2
  • Loading branch information
jrfnl committed Sep 20, 2023
2 parents 98bcdba + 862b249 commit 746c319
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 15 deletions.
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -59,13 +59,13 @@ Please include as many details as relevant about the environment you experienced
You should be able to get the version numbers using the `composer info` command.
-->

| Environment | Answer
| ------------------------ | -------
| PHP version | x.y.z
| PHP_CodeSniffer version | x.y.z
| PHPCSExtra version | x.y.z
| PHPCSUtils version | x.y.z
| Install type | e.g. Composer global, Composer project local, git clone, other (please expand)
| Environment | Answer |
|-------------------------|--------------------------------------------------------------------------------|
| PHP version | x.y.z |
| PHP_CodeSniffer version | x.y.z |
| PHPCSExtra version | x.y.z |
| PHPCSUtils version | x.y.z |
| Install type | e.g. Composer global, Composer project local, git clone, other (please expand) |


## Additional Context (optional)
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/basics.yml
Expand Up @@ -26,7 +26,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
Expand All @@ -128,7 +128,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up node and enable caching of dependencies
uses: actions/setup-node@v3
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

# Ref: https://yamllint.readthedocs.io/en/stable/
- name: Run Yamllint on all yaml files in repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quicktest.yml
Expand Up @@ -35,7 +35,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Expand Up @@ -41,7 +41,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
Expand Down
2 changes: 1 addition & 1 deletion .remarkrc
Expand Up @@ -21,7 +21,7 @@
"remark-lint-no-duplicate-definitions",
"remark-lint-no-empty-url",
"remark-lint-no-file-name-consecutive-dashes",
"remark-lint-no-file-name-irregular-characters",
["remark-lint-no-file-name-irregular-characters", "\\.a-zA-Z0-9_-"],
"remark-lint-no-file-name-outer-dashes",
"remark-lint-no-heading-like-paragraph",
"remark-lint-no-literal-urls",
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,23 @@ This projects adheres to [Keep a CHANGELOG](http://keepachangelog.com/) and uses

_Nothing yet._

## [1.1.2] - 2023-09-21

### Changed

#### Other

* Various housekeeping.

### Fixed

#### Universal

* `Universal.CodeAnalysis.ConstructorDestructorReturn`: the sniff will now correctly ignore methods mirroring the class name (PHP-4 style constructors) in namespaced code. [#207], [#272]

[#272]: https://github.com/PHPCSStandards/PHPCSExtra/pull/272


## [1.1.1] - 2023-08-26

### Changed
Expand Down Expand Up @@ -506,6 +523,7 @@ This initial alpha release contains the following sniffs:
[php_version-config]: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-php-version

[Unreleased]: https://github.com/PHPCSStandards/PHPCSExtra/compare/stable...HEAD
[1.1.2]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.1.1...1.1.2
[1.1.1]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.4...1.1.0
[1.0.4]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.3...1.0.4
Expand Down
12 changes: 12 additions & 0 deletions Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php
Expand Up @@ -18,6 +18,7 @@
use PHPCSUtils\Tokens\Collections;
use PHPCSUtils\Utils\FunctionDeclarations;
use PHPCSUtils\Utils\GetTokensAsString;
use PHPCSUtils\Utils\Namespaces;
use PHPCSUtils\Utils\NamingConventions;
use PHPCSUtils\Utils\ObjectDeclarations;
use PHPCSUtils\Utils\Scopes;
Expand Down Expand Up @@ -105,6 +106,17 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

if (Namespaces::determineNamespace($phpcsFile, $stackPtr) !== '') {
/*
* Namespaced methods with the same name as the class are treated as
* regular methods, so we can bow out if we're in a namespace.
*
* Note: the exception to this is PHP 5.3.0-5.3.2. This is currently
* not dealt with.
*/
return;
}

$functionType = 'A PHP 4-style constructor';
}

Expand Down
@@ -0,0 +1,14 @@
<?php

/*
* The PHP4-style constructors are not constructors in namespaced files.
* No errors should be thrown for it, nor any auto-fixes made.
*/
namespace Some\Name;

class ReturnsAValue {
function returnsAValue(): string
{
return 'php4style';
}
}

0 comments on commit 746c319

Please sign in to comment.