PHP code example of sympress / coding-standards

1. Go to this page and download the library: Download sympress/coding-standards library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sympress / coding-standards example snippets


public function getTitle(): string
{
    return $this->title;
}

public function setTitle(string $title): void
{
    $this->title = $title;
}

public function title(): string
{
    return $this->title;
}

public function rename(string $title): void
{
    $this->title = $title;
}

return (array) json_decode($json, true, 512, JSON_THROW_ON_ERROR);

$decoded = json_decode($json, true, 512, JSON_THROW_ON_ERROR);

return (array) $decoded;

$foo = $this->buildValue();

$prefix = strtoupper('Result');

return sprintf('%s', $foo);

// phpcs:ignore SymPress.Functions.DisallowCallUserFunc.Found
call_user_func($callback);
xml
<rule ref="SymPress.Namespaces.Psr4">
    <properties>
        <property name="psr4" type="array">
            <element key="Acme\Plugin" value="src" />
            <element key="Acme\Plugin\Tests" value="tests" />
        </property>
    </properties>
</rule>
xml
<rule ref="SymPress.Functions.FunctionLength">
    <exclude-pattern>*/tests/*</exclude-pattern>
</rule>
text
Settings -> PHP -> Quality Tools -> PHP_CodeSniffer