diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 56043bed..a0ac7179 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -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) diff --git a/.github/workflows/basics.yml b/.github/workflows/basics.yml index ec7d3420..3ae47d5b 100644 --- a/.github/workflows/basics.yml +++ b/.github/workflows/basics.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index 20c74c6b..2b90659f 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -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. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fefcc5c5..3b203cd3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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. @@ -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. diff --git a/.remarkrc b/.remarkrc index 1d946443..568f5885 100644 --- a/.remarkrc +++ b/.remarkrc @@ -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", diff --git a/CHANGELOG.md b/CHANGELOG.md index 262b97d6..d2fffeb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php b/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php index 4c577884..6f78cb66 100644 --- a/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php +++ b/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php @@ -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; @@ -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'; } diff --git a/Universal/Tests/CodeAnalysis/ConstructorDestructorReturnUnitTest.5.inc b/Universal/Tests/CodeAnalysis/ConstructorDestructorReturnUnitTest.5.inc new file mode 100644 index 00000000..92c29fcb --- /dev/null +++ b/Universal/Tests/CodeAnalysis/ConstructorDestructorReturnUnitTest.5.inc @@ -0,0 +1,14 @@ +