Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Set the internal pointer of an array to its first element
<?php reset(array|object &$array): mixed
<?php         $packages = $repo->findPackages($packageName, $version);



        if (count($packages) > 1) {

            $package = reset($packages);

            $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');

            $io->writeError('Alternatives were '.implode(', ', array_map(function ($p) {

                return $p->getPrettyString();
<?php             }, $packages)).'.');

            $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');

        } elseif ($packages) {

            $package = reset($packages);

            $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');

        } else {

            $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
<?php         $protocol = extension_loaded('openssl') ? 'https' : 'http';

        try {

            $json = $this->httpDownloader->get($protocol . '://repo.packagist.org/packages.json')->decodeJson();

            $hash = reset($json['provider-includes']);

            $hash = $hash['sha256'];

            $path = str_replace('%hash%', $hash, key($json['provider-includes']));

            $provider = $this->httpDownloader->get($protocol . '://repo.packagist.org/'.$path)->getBody();
<?php                     }

                    if (!$installedRepo->findPackagesWithReplacersAndProviders($link->getTarget(), $link->getConstraint())) {

                        if ($results = $installedRepo->findPackagesWithReplacersAndProviders($link->getTarget())) {

                            $provider = reset($results);

                            $lockErrors[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is in the lock file as "'.$provider->getPrettyVersion().'" but that does not satisfy your constraint "'.$link->getPrettyConstraint().'".';

                        } else {

                            $lockErrors[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is not present in the lock file.';
<?php                 if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {

                    unset($protos[$index]);

                }

                if (reset($protos) === 'http') {

                    throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');

                }
<?php             if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {

                $bits = explode('.', $key);

                $last = array_pop($bits);

                $arr = &$config[reset($bits)];

                foreach ($bits as $bit) {

                    if (!isset($arr[$bit])) {

                        $arr[$bit] = array();
<?php             if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {

                $bits = explode('.', $key);

                $last = array_pop($bits);

                $arr = &$config[reset($bits)];

                foreach ($bits as $bit) {

                    if (!isset($arr[$bit])) {

                        return;
<?php         $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));



        if (count($reasons) === 1) {

            reset($reasons);

            $rule = current($reasons);



            if (!in_array($rule->getReason(), array(Rule::RULE_ROOT_REQUIRE, Rule::RULE_FIXED), true)) {
<?php                         $message = Preg::replace('{^(%s%s (?:require|conflict))s}', '$1', $message);

                        $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');

                    } else {

                        $result[] = sprintf($message, $package, ' '.reset($versions));

                    }

                }

            } else {
<?php             $allReposPackages = $packages;

            $topPackage = reset($allReposPackages);

            if ($topPackage instanceof RootPackageInterface) {

                $suffix = ' See https://getcomposer.org/dep-on-root for details and assistance.';

            }
<?php                 }

            }

            if ($selected === null) {

                $selected = reset($available);

            }
<?php         }



        if ($higherRepoPackages) {

            $topPackage = reset($higherRepoPackages);

            if ($topPackage instanceof RootPackageInterface) {

                return array(

                    "- Root composer.json requires $packageName".self::constraintToText($constraint).', it is ',
<?php             $singular = count($higherRepoPackages) === 1;



            return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ',

                'found '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' in the lock file and '.self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' but ' . ($singular ? 'it does' : 'these do') . ' not match your '.$reason.' and ' . ($singular ? 'is' : 'are') . ' therefore not installable. Make sure you either fix the '.$reason.' or avoid updating this package to keep the one from the lock file.', );

        }



        return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ', 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' from '.$nextRepo->getRepoName().' but '.self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' has higher repository priority. The packages from the higher priority repository do not match your '.$reason.' and are therefore not installable. That repository is canonical so the lower priority repo\'s packages are not installable. See https://getcomposer.org/repoprio for details and assistance.');
<?php                 'found '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' in the lock file and '.self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' but ' . ($singular ? 'it does' : 'these do') . ' not match your '.$reason.' and ' . ($singular ? 'is' : 'are') . ' therefore not installable. Make sure you either fix the '.$reason.' or avoid updating this package to keep the one from the lock file.', );

        }



        return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ', 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' from '.$nextRepo->getRepoName().' but '.self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' has higher repository priority. The packages from the higher priority repository do not match your '.$reason.' and are therefore not installable. That repository is canonical so the lower priority repo\'s packages are not installable. See https://getcomposer.org/repoprio for details and assistance.');

    }
<?php                     });



                    if ($alternativeLiterals) {

                        reset($alternativeLiterals);

                        $this->moveWatch($literal, current($alternativeLiterals), $node);

                        continue;

                    }