<commit_before><?php
//
// +----------------------------------------------------------------------+
// | PHP Version 5                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.php.net/license/3_0.txt.                                  |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | <EMAIL> so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: <NAME> <<EMAIL>>                             |
// +----------------------------------------------------------------------+
//
// $Id$
define('PEAR_VALIDATE_INSTALLING', 1);
define('PEAR_VALIDATE_NORMAL', 3);
define('PEAR_VALIDATE_PACKAGING', 7);
class PEAR_Validate
{
    var $packageregex = _PEAR_COMMON_PACKAGE_NAME_PREG;
    /**
     * @var PEAR_PackageFile
     */
    var $_packagexml;
    /**
     * @var int one of the PEAR_VALIDATE_* constants
     */
    var $_state = PEAR_VALIDATE_NORMAL;

    /**
     * Format: ('error' => array('field' => name, 'reason' => reason), 'warning' => same)
     * @var array
     * @access private
     */
    var $_failures = array('error' => array(), 'warning' => array());

    function getChannelPackageDownloadRegex()
    {
        return '(' . _PEAR_CHANNELS_NAME_PREG . ')::' . $this->getPackageDownloadRegex();
    }

    function getPackageDownloadRegex()
    {
        return '(' . $this->packageregex . ')(-([.0-9a-zA-Z]+))?';
    }

    function validPackageName($name)
    {
        return (bool)preg_match('/^' . $this->packageregex . '$/', $name);
    }

    function setPackageFile(&$pf)
    {
        $this->_packagexml = &$pf;
    }

    function _addFailure($field, $reason)
    {
        $this->_failures['error'] = array('field' => $field, 'reason' => $reason);
    }

    function _addWarning($field, $reason)
    {
        $this->_failures['warning'] = array('field' => $field, 'reason' => $reason);
    }

    function validate()
    {
        if (!isset($this->_packagexml)) {
            return false;
        }
    }

    function validatePackageName()
    {
        return $this->validPackageName($this->_packagexml->getPackage());
    }

    function validateVersion()
    {
        if ($this->_state != PEAR_VALIDATE_PACKAGING) {
            return true;
        }
        $version = $this->_packagexml->getVersion();
        $versioncomponents = explode('.', $version);
        if (count($versioncomponents) != 3) {
            $this->_addFailure('version', 'Must have 3 decimals (x.y.z) in a version number');
            return false;
        }
        $name = $this->_packagexml->getPackage();
        // version must be based upon state
        switch ($this->_packagexml->getState()) {
            case 'snapshot' :
            case 'devel' :
                if ($versioncomponents[0] == '0') {
                    return true;
                }
                return false;
            break;
            case 'alpha' :
            case 'beta' :
            // check for Package2 version 2.0.0
            if ($name{strlen($name) - 1} != $versioncomponents[0]) {
                if ($versioncomponents[0] == '1') {
                    if ($versioncomponents[1] == '0' && $versioncomponents[2]{0} == '0') {
                        if (strlen($versioncomponents[2]) > 1) {
                            return true;
                        } else {
                            $this->_addFailure('version', 'version 1.0.0 cannot be alpha or beta');
                            return false;
                        }
                    } else {
                        $this->_addFailure('version', 'versions greater than 1.0.0 cannot be alpha or beta');
                        return false;
                    }
                } else {
                    $this->_addFailure('version', 'major versions greater than 1 are not allowed for packages ' .
                        'not containing an identical postfix');
                }
            } else {
                if ($versioncomponents[1] == '0'&& $versioncomponents[2]{0} == '0') {
                    if (strlen($versioncomponents[2]) > 1) {
                        return true;
                    } else {
                        $this->_addFailure('version', 'version ' . $versioncomponents[0] . '.0.0 cannot be alpha or beta');
                        return false;
                    }
                } else {
                    $this->_addFailure('version', 'versions greater than ' . $versioncomponents[0] .
                        '.0.0 cannot be alpha or beta');
                    return false;
                }
            }
            case 'stable' :
                return true;
            break;
            default :
                return false;
            break;
        }
    }
}
?><commit_msg>tweaking of version number validation 1.3.0beta1 is allowed 1.3.1beta1 is not allowed (bugfix release is always stable) 1.x.0 must be stable extends is now used for new major versions <name extends="PHPUnit">PHPUnit2</name><commit_after><?php
//
// +----------------------------------------------------------------------+
// | PHP Version 5                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.php.net/license/3_0.txt.                                  |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | <EMAIL> so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: <NAME> <<EMAIL>>                             |
// +----------------------------------------------------------------------+
//
// $Id$
define('PEAR_VALIDATE_INSTALLING', 1);
define('PEAR_VALIDATE_NORMAL', 3);
define('PEAR_VALIDATE_PACKAGING', 7);
class PEAR_Validate
{
    var $packageregex = _PEAR_COMMON_PACKAGE_NAME_PREG;
    /**
     * @var PEAR_PackageFile
     */
    var $_packagexml;
    /**
     * @var int one of the PEAR_VALIDATE_* constants
     */
    var $_state = PEAR_VALIDATE_NORMAL;

    /**
     * Format: ('error' => array('field' => name, 'reason' => reason), 'warning' => same)
     * @var array
     * @access private
     */
    var $_failures = array('error' => array(), 'warning' => array());

    function getChannelPackageDownloadRegex()
    {
        return '(' . _PEAR_CHANNELS_NAME_PREG . ')::' . $this->getPackageDownloadRegex();
    }

    function getPackageDownloadRegex()
    {
        return '(' . $this->packageregex . ')(-([.0-9a-zA-Z]+))?';
    }

    function validPackageName($name)
    {
        return (bool)preg_match('/^' . $this->packageregex . '$/', $name);
    }

    function setPackageFile(&$pf)
    {
        $this->_packagexml = &$pf;
    }

    function _addFailure($field, $reason)
    {
        $this->_failures['error'] = array('field' => $field, 'reason' => $reason);
    }

    function _addWarning($field, $reason)
    {
        $this->_failures['warning'] = array('field' => $field, 'reason' => $reason);
    }

    /**
     * @param int one of the PEAR_VALIDATE_* constants
     */
    function validate($state = null)
    {
        if (!isset($this->_packagexml)) {
            return false;
        }
        if ($state !== null) {
            $this->_state = $state;
        }
    }

    function validatePackageName()
    {
        return $this->validPackageName($this->_packagexml->getPackage());
    }

    function validateVersion()
    {
        if ($this->_state != PEAR_VALIDATE_PACKAGING) {
            return true;
        }
        $version = $this->_packagexml->getVersion();
        $versioncomponents = explode('.', $version);
        if (count($versioncomponents) != 3) {
            $this->_addFailure('version',
                'Must have 3 decimals (x.y.z) in a version number');
            return false;
        }
        $name = $this->_packagexml->getPackage();
        // version must be based upon state
        switch ($this->_packagexml->getState()) {
            case 'snapshot' :
            case 'devel' :
                if ($versioncomponents[0] == '0') {
                    return true;
                }
                return false;
            break;
            case 'alpha' :
            case 'beta' :
            // check for a package that extends a package,
            // like Foo and Foo2
            if ($this->_packagexml->getExtends()) {
                if ($versioncomponents[0] == '1') {
                    if ($versioncomponents[2]{0} == '0') {
                        if (strlen($versioncomponents[2]) > 1) {
                            // version 1.*.0RC1 or 1.*.0beta24 etc.
                            return true;
                        } else {
                            // version 1.*.0
                            $this->_addFailure('version',
                                'version 1.' . $versioncomponents[1] .
                                    '.0 cannot be alpha or beta');
                            return false;
                        }
                    } else {
                        $this->_addFailure('version',
                            'bugfix versions (1.3.x where x > 0) cannot be alpha or beta');
                        return false;
                    }
                } else {
                    $this->_addFailure('version',
                        'major versions greater than 1 are not allowed for packages ' .
                        'not containing an identical postfix');
                }
            } else {
                $vlen = strlen($versioncomponents[0] . '');
                if ($name{strlen($name) - $vlen} != $versioncomponents[0]) {
                    $this->_addFailure('version', 'first version number "' .
                        $versioncomponents[0] . '" must match the postfix of ' .
                        'package name "' . $name . '" (' .
                        $name{strlen($name) - $vlen} . ')');
                    return false;
                }
                if ($versioncomponents[2]{0} == '0') {
                    if (strlen($versioncomponents[2]) > 1) {
                        // version 2.*.0RC1 etc.
                        return true;
                    } else {
                        // version 2.*.0
                        $this->_addFailure('version', 'version ' .
                            $versioncomponents[0] . '.0.0 cannot be alpha or beta');
                        return false;
                    }
                }
            }
            case 'stable' :
                if ($versioncomponents[0] == '0') {
                    $this->_addFailure('version', 'versions less than 1.0 cannot ' .
                    'be stable');
                    return false;
                }
                return true;
            break;
            default :
                return false;
            break;
        }
    }
}
?>
{'fraction_non_alphanumeric': 0.1842039281236941, 'fraction_numerical': 0.011199331383201004, 'mean_word_length': 1.192378160498351, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 90, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 15}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1153287', 'n_tokens_mistral': 3107, 'n_tokens_neox': 2945, 'n_words': 754}