<commit_before><?php

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

namespace Composer\Repository;

use Composer\Package\MemoryPackage;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionParser;

/**
 * @author <NAME> <<EMAIL>>
 */
class PlatformRepository extends ArrayRepository implements WritableRepositoryInterface
{
    private $localRepository;

    public function __construct(WritableRepositoryInterface $localRepository)
    {
        $this->localRepository = $localRepository;
    }

    protected function initialize()
    {
        parent::initialize();

        $versionParser = new VersionParser();

        try {
            $version = $versionParser->normalize(PHP_VERSION);
        } catch (\UnexpectedValueException $e) {
            $version = $versionParser->normalize(preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION));
        }

        $php = new MemoryPackage('php', $version);
        parent::addPackage($php);

        foreach (get_loaded_extensions() as $ext) {
            if (in_array($ext, array('standard', 'Core'))) {
                continue;
            }

            $reflExt = new \ReflectionExtension($ext);
            try {
                $version = $versionParser->normalize($reflExt->getVersion());
            } catch (\UnexpectedValueException $e) {
                $version = $versionParser->normalize('0');
            }

            $ext = new MemoryPackage('ext/'.strtolower($ext), $version);
            parent::addPackage($ext);
        }
    }

    public function getPackages()
    {
        return array_merge(parent::getPackages(), $this->localRepository->getPackages());
    }

    /**
     * {@inheritDoc}
     */<commit_msg>Rename platform packages so they avoid conflicts with any vendor<commit_after><?php

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

namespace Composer\Repository;

use Composer\Package\MemoryPackage;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionParser;

/**
 * @author <NAME> <<EMAIL>>
 */
class PlatformRepository extends ArrayRepository implements WritableRepositoryInterface
{
    private $localRepository;

    public function __construct(WritableRepositoryInterface $localRepository)
    {
        $this->localRepository = $localRepository;
    }

    protected function initialize()
    {
        parent::initialize();

        $versionParser = new VersionParser();

        try {
            $version = $versionParser->normalize(PHP_VERSION);
        } catch (\UnexpectedValueException $e) {
            $version = $versionParser->normalize(preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION));
        }

        $php = new MemoryPackage('php', $version);
        parent::addPackage($php);

        foreach (get_loaded_extensions() as $ext) {
            if (in_array($ext, array('standard', 'Core'))) {
                continue;
            }

            $reflExt = new \ReflectionExtension($ext);
            try {
                $version = $versionParser->normalize($reflExt->getVersion());
            } catch (\UnexpectedValueException $e) {
                $version = $versionParser->normalize('0');
            }

            $ext = new MemoryPackage('ext-'.strtolower($ext), $version);
            parent::addPackage($ext);
        }
    }

    public function getPackages()
    {
        return array_merge(parent::getPackages(), $this->localRepository->getPackages());
    }

    /**
     * {@inheritDoc}
     */
{'fraction_non_alphanumeric': 0.1341557440246723, 'fraction_numerical': 0.0010280133641737343, 'mean_word_length': 2.664783427495292, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 37, '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': '5620551', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1022, 'n_words': 233}