• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHPCompatibility / PHPCompatibility / 19804455605

30 Nov 2025 08:31PM UTC coverage: 98.306% (-0.04%) from 98.346%
19804455605

push

github

web-flow
Merge pull request #2014 from PHPCompatibility/php-8.5/new-removedterminatingcasewithsemicolon-sniff

PHP 8.5 | ✨ New `PHPCompatibility.ControlStructures.RemovedTerminatingCaseWithSemicolon` sniff (RFC)

30 of 34 new or added lines in 1 file covered. (88.24%)

21 existing lines in 15 files now uncovered.

8355 of 8499 relevant lines covered (98.31%)

20.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/PHPCompatibility/Sniffs/ParameterValues/RemovedIconvEncodingSniff.php
1
<?php
2
/**
3
 * PHPCompatibility, an external standard for PHP_CodeSniffer.
4
 *
5
 * @package   PHPCompatibility
6
 * @copyright 2012-2020 PHPCompatibility Contributors
7
 * @license   https://opensource.org/licenses/LGPL-3.0 LGPL3
8
 * @link      https://github.com/PHPCompatibility/PHPCompatibility
9
 */
10

11
namespace PHPCompatibility\Sniffs\ParameterValues;
12

13
use PHPCompatibility\AbstractFunctionCallParameterSniff;
14
use PHPCompatibility\Helpers\ScannedCode;
15
use PHP_CodeSniffer\Files\File;
16
use PHPCSUtils\Utils\PassedParameters;
17

18
/**
19
 * Detect passing deprecated `$type` values to `iconv_get_encoding()`.
20
 *
21
 * "The iconv and mbstring configuration options related to encoding have been
22
 * deprecated in favour of default_charset."
23
 *
24
 * {@internal It is unclear which mbstring functions should be targetted, so for now,
25
 * only the iconv function is handled.}
26
 *
27
 * PHP version 5.6
28
 *
29
 * @link https://www.php.net/manual/en/migration56.deprecated.php#migration56.deprecated.iconv-mbstring-encoding
30
 * @link https://wiki.php.net/rfc/default_encoding
31
 *
32
 * @since 9.0.0
33
 * @since 10.0.0 This class is now `final`.
34
 */
35
final class RemovedIconvEncodingSniff extends AbstractFunctionCallParameterSniff
36
{
37

38
    /**
39
     * Functions to check for.
40
     *
41
     * @since 9.0.0
42
     *
43
     * @var array<string, true>
44
     */
45
    protected $targetFunctions = [
46
        'iconv_set_encoding' => true,
47
    ];
48

49

50
    /**
51
     * Do a version check to determine if this sniff needs to run at all.
52
     *
53
     * @since 9.0.0
54
     *
55
     * @return bool
56
     */
57
    protected function bowOutEarly()
8✔
58
    {
59
        return (ScannedCode::shouldRunOnOrAbove('5.6') === false);
8✔
60
    }
61

62

63
    /**
64
     * Process the parameters of a matched function.
65
     *
66
     * @since 9.0.0
67
     *
68
     * @param \PHP_CodeSniffer\Files\File $phpcsFile    The file being scanned.
69
     * @param int                         $stackPtr     The position of the current token in the stack.
70
     * @param string                      $functionName The token content (function name) which was matched.
71
     * @param array                       $parameters   Array with information about the parameters.
72
     *
73
     * @return void
74
     */
75
    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
4✔
76
    {
77
        $targetParam = PassedParameters::getParameterFromStack($parameters, 1, 'type');
4✔
78
        if ($targetParam === false) {
4✔
UNCOV
79
            return;
×
80
        }
81

82
        $phpcsFile->addWarning(
4✔
83
            'All previously accepted values for the $type parameter of iconv_set_encoding() have been deprecated since PHP 5.6. Found %s',
4✔
84
            $targetParam['start'],
4✔
85
            'DeprecatedValueFound',
4✔
86
            [$targetParam['clean']]
4✔
87
        );
2✔
88
    }
2✔
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc