<commit_before><?php
/**
 * @name        InstantiateNewClassesSniff
 * @package     Yaapi\Coding-Standards
 * @copyright   Copyright (C) 2015 http://joomworker.com - All rights reserved.
 * @license     GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 or later - http://www.gnu.org
 */

/**
 * Ensures that new classes are instantiated without brackets if they do not have any parameters.
 *
 * @since   1.0
 */
class YaAPI_Sniffs_Classes_InstantiateNewClassesSniff implements PHP_CodeSniffer_Sniff
{
    /**
     * Registers the token types that this sniff wishes to listen to.
     *
     * @return  array
     */
    public function register()
    {
        return [T_NEW];
    }

    /**
     * Process the tokens that this sniff is listening for.
     *
     * @param   PHP_CodeSniffer_File  $phpcsFile  The file where the token was found.
     * @param   integer               $stackPtr   The position in the stack where the token was found.
     *
     * @return  void
     */
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens  = $phpcsFile->getTokens();
        $running = true;
        $valid   = false;
        $started = false;
        $cnt     = $stackPtr + 1;

        do
        {
            if (!isset($tokens[$cnt]))
            {
                $running = false;
            }
            else
            {
                switch ($tokens[$cnt]['code'])
                {
                    case T_SEMICOLON:
                    case T_COMMA :
                        $valid   = true;
                        $running = false;
                        break;

                    case T_OPEN_PARENTHESIS :
                        $started = true;
                        break;

                    case T_VARIABLE :
                    case T_STRING :
                    case T_LNUMBER :
                    case T_CONSTANT_ENCAPSED_STRING :
                    case T_DOUBLE_QUOTED_STRING :
                    case T_ARRAY :
                        if ($started)
                        {
                            $valid   = true;
                            $running = false;
                        }
                        break;

                    case T_CLOSE_PARENTHESIS :
                        if (!$started)<commit_msg>add valid values<commit_after><?php
/**
 * @name        InstantiateNewClassesSniff
 * @package     Yaapi\Coding-Standards
 * @copyright   Copyright (C) 2015 http://joomworker.com - All rights reserved.
 * @license     GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 or later - http://www.gnu.org
 */

/**
 * Ensures that new classes are instantiated without brackets if they do not have any parameters.
 *
 * @since   1.0
 */
class YaAPI_Sniffs_Classes_InstantiateNewClassesSniff implements PHP_CodeSniffer_Sniff
{
    /**
     * Registers the token types that this sniff wishes to listen to.
     *
     * @return  array
     */
    public function register()
    {
        return [T_NEW];
    }

    /**
     * Process the tokens that this sniff is listening for.
     *
     * @param   PHP_CodeSniffer_File  $phpcsFile  The file where the token was found.
     * @param   integer               $stackPtr   The position in the stack where the token was found.
     *
     * @return  void
     */
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens  = $phpcsFile->getTokens();
        $running = true;
        $valid   = false;
        $started = false;
        $cnt     = $stackPtr + 1;

        do
        {
            if (!isset($tokens[$cnt]))
            {
                $running = false;
            }
            else
            {
                switch ($tokens[$cnt]['code'])
                {
                    case T_SEMICOLON:
                    case T_COMMA :
                        $valid   = true;
                        $running = false;
                        break;

                    case T_OPEN_PARENTHESIS :
                        $started = true;
                        break;

                    case T_VARIABLE :
                    case T_STRING :
                    case T_LNUMBER :
                    case T_CONSTANT_ENCAPSED_STRING :
                    case T_DOUBLE_QUOTED_STRING :
                    case T_ARRAY :
                    case T_TRUE :
                    case T_FALSE :
                        if ($started)
                        {
                            $valid   = true;
                            $running = false;
                        }
                        break;

                    case T_CLOSE_PARENTHESIS :
                        if (!$started)
{'fraction_non_alphanumeric': 0.07534246575342465, 'fraction_numerical': 0.003852739726027397, 'mean_word_length': 1.1485057471264368, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5707788', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1179, 'n_words': 321}