<commit_before><?php

/*
 * This file is part of the Symfony package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\HttpFoundation\File;

use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;

/**
 * A file uploaded through a form.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class UploadedFile extends File
{
    /**
     * The original name of the uploaded file.
     *
     * @var string
     */
    protected $originalName;

    /**
     * The mime type provided by the uploader.
     *
     * @var string
     */
    protected $mimeType;

    /**
     * The file size provided by the uploader.
     *
     * @var integer
     */
    protected $size;

    /**
     * The UPLOAD_ERR_XXX constant provided by the uploader.
     *
     * @var integer
     */
    protected $error;

    /**
     * Whether the uploaded file has already been moved.
     *
     * @var Boolean
     */
    protected $moved;

    /**
     * Accepts the information of the uploaded file as provided by the PHP global $_FILES.
     *
     * @param string  $path         The full temporary path to the file
     * @param string  $originalName The original file name
     * @param string  $mimeType     The type of the file as provided by PHP
     * @param integer $size         The file size
     * @param integer $error        The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants)
     * @param Boolean $moved        Whether the file has been moved from its original location
     *
     * @throws FileException         If file_uploads is disabled
     * @throws FileNotFoundException If the file does not exist
     */
    public function __construct($path, $originalName, $mimeType, $size, $error, $moved = false)
    {
        if (!ini_get('file_uploads')) {
            throw new FileException(sprintf('Unable to create UploadedFile because "file_uploads" is disabled in your php.ini file (%s)', get_cfg_var('cfg_file_path')));
        }

        if (!is_file($path)) {
            throw new FileNotFoundException($path);
        }

        $this->path = realpath($path);
        $this->originalName = $originalName;
        $this->mimeType = $mimeType ?: 'application/octet-stream';
        $this->size = $size;
        $this->error = $error ?: UPLOAD_ERR_OK;
        $this->moved = (Boolean) $moved;
    }

    /**
     * @inheritDoc
     */
    public function getMimeType()
    {
        return parent::getMimeType() ?: $this->mimeType;
    }

    /**
     * @inheritDoc
     */
    public function getSize()
    {
        return null === $this->size ? parent::getSize() : $this->size;
    }

    /**
     * Returns the absolute file name without dots.
     *
     * @return string The file path
     */
    public function getName()
    {
        return $this->moved ? parent::getName() : $this->originalName;
    }

    /**
     * Returns the upload error.
     *
     * If the upload was successful, the constant UPLOAD_ERR_OK is returned.
     * Otherwise one of the other UPLOAD_ERR_XXX constants is returned.
     *
     * @return integer The upload error
     */
    public function getError()
    {
        return $this->error;
    }

    /**
     * Returns whether the file was uploaded successfully.
     *
     * @return Boolean  True if no error occurred during uploading
     */
    public function isValid()
    {
        return $this->error === UPLOAD_ERR_OK;
    }

    /**
     * Returns true if the size of the uploaded file exceeds the
     * upload_max_filesize directive in php.ini
     *
     * @return Boolean
     */
    protected function isIniSizeExceeded()
    {
        return $this->error === UPLOAD_ERR_INI_SIZE;
    }

    /**
     * Returns true if the size of the uploaded file exceeds the
     * MAX_FILE_SIZE directive specified in the HTML form
     *
     * @return Boolean
     */
    protected function isFormSizeExceeded()
    {
        return $this->error === UPLOAD_ERR_FORM_SIZE;
    }

    /**
     * Returns true if the file was completely uploaded
     *
     * @return Boolean
     */
    protected function isUploadComplete()
    {
        return $this->error !== UPLOAD_ERR_PARTIAL;
    }

    /**
     * @inheritDoc
     */
    public function move($directory, $name = null)
    {
        if ($this->moved) {
            return parent::move($directory, $name);
        }

        $this->doMove($directory, $this->originalName);

        if (null !== $name) {
            $this->rename($name);
        }
    }

    /**
     * @inheritDoc
     */
    protected function doMove($directory, $filename)
    {
        if ($this->moved) {
            return parent::doMove($directory, $filename);
        }

        $newPath = $directory.DIRECTORY_SEPARATOR.$filename;

        if (!move_uploaded_file($this->getPath(), $newPath)) {
            throw new FileException(sprintf('Could not move file %s to %s', $this->getPath(), $newPath));
        }

        $this->moved = true;
        $this->path = realpath($newPath);
    }
}
<commit_msg>[HttpFoundation] removed protected methods that were not used<commit_after><?php

/*
 * This file is part of the Symfony package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\HttpFoundation\File;

use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;

/**
 * A file uploaded through a form.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class UploadedFile extends File
{
    /**
     * The original name of the uploaded file.
     *
     * @var string
     */
    protected $originalName;

    /**
     * The mime type provided by the uploader.
     *
     * @var string
     */
    protected $mimeType;

    /**
     * The file size provided by the uploader.
     *
     * @var integer
     */
    protected $size;

    /**
     * The UPLOAD_ERR_XXX constant provided by the uploader.
     *
     * @var integer
     */
    protected $error;

    /**
     * Whether the uploaded file has already been moved.
     *
     * @var Boolean
     */
    protected $moved;

    /**
     * Accepts the information of the uploaded file as provided by the PHP global $_FILES.
     *
     * @param string  $path         The full temporary path to the file
     * @param string  $originalName The original file name
     * @param string  $mimeType     The type of the file as provided by PHP
     * @param integer $size         The file size
     * @param integer $error        The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants)
     * @param Boolean $moved        Whether the file has been moved from its original location
     *
     * @throws FileException         If file_uploads is disabled
     * @throws FileNotFoundException If the file does not exist
     */
    public function __construct($path, $originalName, $mimeType, $size, $error, $moved = false)
    {
        if (!ini_get('file_uploads')) {
            throw new FileException(sprintf('Unable to create UploadedFile because "file_uploads" is disabled in your php.ini file (%s)', get_cfg_var('cfg_file_path')));
        }

        if (!is_file($path)) {
            throw new FileNotFoundException($path);
        }

        $this->path = realpath($path);
        $this->originalName = $originalName;
        $this->mimeType = $mimeType ?: 'application/octet-stream';
        $this->size = $size;
        $this->error = $error ?: UPLOAD_ERR_OK;
        $this->moved = (Boolean) $moved;
    }

    /**
     * @inheritDoc
     */
    public function getMimeType()
    {
        return parent::getMimeType() ?: $this->mimeType;
    }

    /**
     * @inheritDoc
     */
    public function getSize()
    {
        return null === $this->size ? parent::getSize() : $this->size;
    }

    /**
     * Returns the absolute file name without dots.
     *
     * @return string The file path
     */
    public function getName()
    {
        return $this->moved ? parent::getName() : $this->originalName;
    }

    /**
     * Returns the upload error.
     *
     * If the upload was successful, the constant UPLOAD_ERR_OK is returned.
     * Otherwise one of the other UPLOAD_ERR_XXX constants is returned.
     *
     * @return integer The upload error
     */
    public function getError()
    {
        return $this->error;
    }

    /**
     * Returns whether the file was uploaded successfully.
     *
     * @return Boolean  True if no error occurred during uploading
     */
    public function isValid()
    {
        return $this->error === UPLOAD_ERR_OK;
    }

    /**
     * @inheritDoc
     */
    public function move($directory, $name = null)
    {
        if ($this->moved) {
            return parent::move($directory, $name);
        }

        $this->doMove($directory, $this->originalName);

        if (null !== $name) {
            $this->rename($name);
        }
    }

    /**
     * @inheritDoc
     */
    protected function doMove($directory, $filename)
    {
        if ($this->moved) {
            return parent::doMove($directory, $filename);
        }

        $newPath = $directory.DIRECTORY_SEPARATOR.$filename;

        if (!move_uploaded_file($this->getPath(), $newPath)) {
            throw new FileException(sprintf('Could not move file %s to %s', $this->getPath(), $newPath));
        }

        $this->moved = true;
        $this->path = realpath($newPath);
    }
}

{'fraction_non_alphanumeric': 0.11349913007880462, 'fraction_numerical': 0.0, 'mean_word_length': 2.174788823911631, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 68, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5104976', 'n_tokens_mistral': 2851, 'n_tokens_neox': 2791, 'n_words': 838}