PHP 8.2.31
Preview: OpeningFunctionBraceKernighanRitchieUnitTest.1.inc.fixed Size: 3.96 KB
//opt/cpanel/ea-wappspector/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc.fixed

<?php

// Good.
function myFunction() {
}

// Brace should be on same line.
function myFunction() {
}

// Too many spaces.
function myFunction() {
}

// Uses tab.
function myFunction() {
}


class myClass
{
    // Good.
    function myFunction() {
    }

    // Brace should be on same line.
    function myFunction() {
    }

    // Too many spaces.
    function myFunction() {
    }

    // Uses tab.
    function myFunction() {
    }
}



/* Multi-line declarations */

// Good.
function myFunction($variable1, $variable2,
    $variable3, $variable4) {
}

// Brace should be on same line.
function myFunction($variable1, $variable2,
    $variable3, $variable4) {
}

// Too many spaces.
function myFunction($variable1, $variable2,
    $variable3, $variable4) {
}

// Uses tab.
function myFunction($variable1, $variable2,
    $variable3, $variable4) {
}


class myClass
{
    // Good.
    function myFunction($variable1, $variable2,
        $variable3, $variable4) {
    }

    // Brace should be on same line.
    function myFunction($variable1, $variable2,
        $variable3, $variable4) {
    }

    // Too many spaces.
    function myFunction($variable1, $variable2,
        $variable3, $variable4) {
    }

    // Uses tab.
    function myFunction($variable1, $variable2,
        $variable3, $variable4) {
    }
}

interface MyInterface
{
    function myFunction();
}

function myFunction(
                    $arg1,
                    $arg2,
                    $arg3,
                    $arg4,
                    $arg5,
                    $arg6
                    ) {
}

function myFunction(
                    $arg1,
                    $arg2,
                    $arg3,
                    $arg4,
                    $arg5,
                    $arg6
                    ) {
}

function myFunction() {}
function myFunction() {
}

// phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkClosures 1

$closureWithArgs = function ($arg1, $arg2) {
    // body
};

$closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2) {
    // body
};

$test = function ($param) use ($result) {
    return null;
};

$test = function ($param) use ($result) : Something {
    return null;
};

$test = function ($param) use ($result): Something {
    return null;
};

foo(function ($bar) { ?>
    <div><?php echo $bar; ?></div>
<?php });

// phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkClosures 0

$closureWithArgs = function ($arg1, $arg2){
    // body
};

function myFunction() : Something {
    return null;
}

function myFunction() : Something {
 // Break me
    return null;
}

function myFunction(): Something {
    return null;
}

function myFunction(): Something {
    return null;
}

function myFunction($bar) { ?>
    <div><?php echo $bar; ?></div>
<?php }

function myFunction($a, $lot, $of, $params)
    : array {
    return null;
}

function myFunction($a, $lot, $of, $params)
    : array {
    return null;
}

function myFunction($a, $lot, $of, $params) {
 // comment
    return null;
}

function myFunction($a, $lot, $of, $params)
    : array {
 // comment
    return null;
}

function myFunction($a, $lot, $of, $params)
    : array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
    return null;
}

function myFunction($a, $lot, $of, $params)
    : array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
    return null;
}

function myFunction() {}
function myFunction() {} // Too many spaces with an empty function.
function myFunction() {} // Too many spaces (tab) with an empty function.

// phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkFunctions 0
function shouldBeIgnored()
{}
// phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkFunctions 1

function dnfReturnType(): (Response&SuccessResponse)|AnotherResponse|string {
}

function commentAfterOpeningBrace() {
 // Some comment.
}

function variableAssignmentAfterOpeningBrace() {
 $a = 1;
}

abstract class MyClass {
    abstract public function abstractMethod();
}

Directory Contents

Dirs: 0 × Files: 17

Name Size Perms Modified Actions
1.15 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download
200 B lrw-r--r-- 2025-11-04 16:30:35
Edit Download
163 B lrw-r--r-- 2025-11-04 16:30:35
Edit Download
1.94 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download
4.34 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download
4.33 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download
170 B lrw-r--r-- 2025-11-04 16:30:35
Edit Download
2.47 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download
4.39 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download
4.39 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download
2.17 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download
3.97 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download
3.96 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download
312 B lrw-r--r-- 2025-11-04 16:30:35
Edit Download
307 B lrw-r--r-- 2025-11-04 16:30:35
Edit Download
194 B lrw-r--r-- 2025-11-04 16:30:35
Edit Download
3.12 KB lrw-r--r-- 2025-11-04 16:30:35
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).