From 6cd919c43c349c00dd14b44ac5c3fcbe7e471077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Wed, 12 Aug 2020 12:10:19 -0700 Subject: [PATCH 1/6] remove pear stuff --- .gitignore | 9 +- README.md | 3 +- bin/create-pear | 233 ------------------------------------------------ bin/create-phar | 71 --------------- package.ini | 36 -------- 5 files changed, 4 insertions(+), 348 deletions(-) delete mode 100755 bin/create-pear delete mode 100755 bin/create-phar delete mode 100644 package.ini diff --git a/.gitignore b/.gitignore index 3f94fe22..b085e1f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,6 @@ -*.tgz -*.phar +/vendor .php-version .php_cs.cache -phpunit.xml -package.xml composer.lock -experiments/ -vendor/ +phpunit.xml +*.tgz diff --git a/README.md b/README.md index 607bbad3..e6e0b7e8 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,7 @@ More details about this project can be found on the [frequently asked questions] ## How to _install_ and use Predis ## This library can be found on [Packagist](http://packagist.org/packages/predis/predis) for an easier -management of projects dependencies using [Composer](http://packagist.org/about-composer) or on our -[own PEAR channel](http://pear.nrk.io) for a more traditional installation using PEAR. Ultimately, +management of projects dependencies using [Composer](http://packagist.org/about-composer). Ultimately, compressed archives of each release are [available on GitHub](https://github.com/predishq/predis/releases). diff --git a/bin/create-pear b/bin/create-pear deleted file mode 100755 index b4f92db4..00000000 --- a/bin/create-pear +++ /dev/null @@ -1,233 +0,0 @@ -#!/usr/bin/env php - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -// -------------------------------------------------------------------------- // -// In order to be able to execute this script to create a PEAR package of Predis -// the `pear` binary must be available and executable in your $PATH. -// The parts used to parse author and version strings are taken from Onion (used -// by this library in the past) just to keep on relying on the package.ini file -// to simplify things. We might consider to switch to using the PEAR classes -// directly in the future. -// -------------------------------------------------------------------------- // - -function executeWithBackup($file, $callback) -{ - $exception = null; - $backup = "$file.backup"; - - copy($file, $backup); - - try { - call_user_func($callback, $file); - } catch (Exception $exception) { - // NOOP - } - - unlink($file); - rename($backup, $file); - - if ($exception) { - throw $exception; - } -} - -function parseAuthor($string) -{ - $author = array(); - - if (preg_match('/^\s*(.+?)\s*(?:"(\S+)"\s*)?<(\S+)>\s*$/x', $string , $regs)) { - if (count($regs) == 4) { - list($_,$name,$user,$email) = $regs; - $author['name'] = $name; - $author['user'] = $user; - $author['email'] = $email; - } elseif (count($regs) == 3) { - list($_,$name,$email) = $regs; - $author['name'] = $name; - $author['email'] = $email; - } - } else { - $author['name'] = $string; - } - - return $author; -} - -function parseVersion($string) -{ - $version_pattern = '([0-9.]+)'; - - if (preg_match("/^\s*$version_pattern\s*\$/x", $string, $regs)) { - return array('min' => $regs[1] ?: '0.0.0'); - } elseif (preg_match("/^\s*[>=]+\s*$version_pattern\s*\$/x", $string, $regs)) { - return array('min' => $regs[1] ?: '0.0.0'); - } elseif (preg_match("/^\s*[<=]+\s*$version_pattern\s*\$/x", $string, $regs)) { - return array('max' => $regs[1]); - } elseif (preg_match("/^\s*$version_pattern\s*<=>\s*$version_pattern\s*\$/x", $string, $regs)) { - return array( - 'min' => $regs[1] ?: '0.0.0', - 'max' => $regs[2], - ); - } - - return null; -} - -function addRolePath($pkg, $path, $role) -{ - if (is_dir($path)) { - $dirRoot = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS); - $dirTree = new RecursiveIteratorIterator($dirRoot, RecursiveIteratorIterator::CHILD_FIRST); - - foreach ($dirTree as $fileinfo) { - if ($fileinfo->isFile()) { - addPackageFile($pkg, $fileinfo, $role, $path); - } - } - } else { - foreach (glob($path) as $filename) { - addPackageFile($pkg, new SplFileInfo($filename), $role); - } - } -} - -function addPackageFile($pkg, $fileinfo, $role, $baseDir = '') -{ - $fileNode = $pkg->contents->dir->addChild('file'); - $fileNode->addAttribute('name', $filepath = $fileinfo->getPathname()); - $fileNode->addAttribute('role', $role); - $fileNode->addAttribute('md5sum', md5_file($filepath)); - - $installNode = $pkg->phprelease->filelist->addChild('install'); - $installNode->addAttribute('name', $filepath); - $installNode->addAttribute('as', !$baseDir ? basename($filepath) : substr($filepath, strlen($baseDir) + 1)); -} - -function generatePackageXml($packageINI) -{ - $XML = << - -XML; - - $cfg = parse_ini_file($packageINI, true); - $pkg = new SimpleXMLElement($XML); - - $pkg->name = $cfg['package']['name']; - $pkg->channel = $cfg['package']['channel']; - $pkg->summary = $cfg['package']['desc']; - $pkg->description = $cfg['package']['desc']; - - $author = parseAuthor($cfg['package']['author']); - $pkg->addChild('lead'); - $pkg->lead->name = $author['name']; - $pkg->lead->user = $author['user']; - $pkg->lead->email = $author['email']; - $pkg->lead->active = 'yes'; - - $datetime = new DateTime('now'); - $pkg->date = $datetime->format('Y-m-d'); - $pkg->time = $datetime->format('H:i:s'); - - $pkg->addChild('version'); - $pkg->version->release = $cfg['package']['version']; - $pkg->version->api = $cfg['package']['version']; - - $pkg->addChild('stability'); - $pkg->stability->release = $cfg['package']['stability']; - $pkg->stability->api = $cfg['package']['stability']; - - $pkg->license = $cfg['package']['license']; - $pkg->notes = '-'; - - $pkg->addChild('contents')->addChild('dir')->addAttribute('name', '/'); - - $pkg->addChild('dependencies')->addChild('required'); - foreach ($cfg['require'] as $required => $version) { - $version = parseVersion($version); - $pkg->dependencies->required->addChild($required); - - if (isset($version['min'])) { - $pkg->dependencies->required->$required->min = $version['min']; - } - if (isset($version['max'])) { - $pkg->dependencies->required->$required->min = $version['max']; - } - } - - $pkg->addChild('phprelease')->addChild('filelist'); - - $pathToRole = array( - 'doc' => 'doc', 'docs' => 'doc', 'examples' => 'doc', - 'lib' => 'php', 'src' => 'php', - 'test' => 'test', 'tests' => 'test', - ); - - foreach (array_merge($pathToRole, $cfg['roles'] ?: array()) as $path => $role) { - addRolePath($pkg, $path, $role); - } - - return $pkg; -} - -function rewritePackageInstallAs($pkg) -{ - foreach ($pkg->phprelease->filelist->install as $file) { - if (preg_match('/^src\//', $file['name'])) { - $file['as'] = "Predis/{$file['as']}"; - } - } -} - -function savePackageXml($xml) -{ - $dom = new DOMDocument("1.0"); - $dom->preserveWhiteSpace = false; - $dom->formatOutput = true; - $dom->loadXML($xml->asXML()); - - file_put_contents('package.xml', $dom->saveXML()); -} - -function buildPackage() -{ - passthru('pear -q package && rm package.xml'); -} - -function modifyPhpunitXml($file) -{ - $cfg = new SimpleXMLElement($file, null, true); - - $cfg[0]['bootstrap'] = str_replace('tests/', '', $cfg[0]['bootstrap']); - $cfg->testsuites->testsuite->directory = str_replace('tests/', '', $cfg->testsuites->testsuite->directory); - - $cfg->saveXml($file); -} - -// -------------------------------------------------------------------------- // - -executeWithBackup(__DIR__.'/../phpunit.xml.dist', function ($file) { - modifyPhpunitXml($file); - - $pkg = generatePackageXml('package.ini'); - rewritePackageInstallAs($pkg); - savePackageXml($pkg); - - buildPackage(); -}); diff --git a/bin/create-phar b/bin/create-phar deleted file mode 100755 index 23618096..00000000 --- a/bin/create-phar +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env php - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -// -------------------------------------------------------------------------- // -// In order to be able to execute this script to create a Phar archive of Predis, -// the Phar module must be loaded and the "phar.readonly" directive php.ini must -// be set to "off". You can change the values in the $options array to customize -// the creation of the Phar archive to better suit your needs. -// -------------------------------------------------------------------------- // - -$options = array( - 'name' => 'predis', - 'project_path' => __DIR__ . '/../src', - 'compression' => Phar::NONE, - 'append_version' => true, -); - -function getPharFilename($options) -{ - $filename = $options['name']; - - // NOTE: do not consider "append_version" with Phar compression do to a bug in - // Phar::compress() when renaming phar archives containing dots in their name. - if ($options['append_version'] && $options['compression'] === Phar::NONE) { - $versionFile = @fopen(__DIR__ . '/../VERSION', 'r'); - - if ($versionFile === false) { - throw new Exception("Could not locate the VERSION file."); - } - - $version = trim(fgets($versionFile)); - fclose($versionFile); - $filename .= "_$version"; - } - - return "$filename.phar"; -} - -function getPharStub($options) -{ - return <<compress($options['compression']); -$phar->setStub(getPharStub($options)); -$phar->buildFromDirectory($options['project_path']); diff --git a/package.ini b/package.ini deleted file mode 100644 index 3ba810b6..00000000 --- a/package.ini +++ /dev/null @@ -1,36 +0,0 @@ -; This file is meant to be used with Onion http://c9s.github.com/Onion/ -; For instructions on how to build a PEAR package of Predis please follow -; the instructions at this URL: -; -; https://github.com/c9s/Onion#a-quick-tutorial-for-building-pear-package -; - -[package] -name = "Predis" -desc = "Flexible and feature-complete Redis client for PHP and HHVM" -homepage = "http://github.com/nrk/predis" -license = "MIT" -version = "1.1.2" -stability = "stable" -channel = "pear.nrk.io" - -author = "Daniele Alessandri \"nrk\" " - -[require] -php = ">= 5.3.9" -pearinstaller = "1.4.1" - -[roles] -*.xml.dist = test -*.md = doc -LICENSE = doc - -[optional phpiredis] -hint = "Add support for faster protocol handling with phpiredis" -extensions[] = socket -extensions[] = phpiredis - -[optional webdis] -hint = "Add support for Webdis" -extensions[] = curl -extensions[] = phpiredis From 4edfda06698063ca5ef9120399a7b8bcafdadbd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Wed, 12 Aug 2020 12:29:48 -0700 Subject: [PATCH 2/6] remove single file script --- bin/create-single-file | 662 ----------------------------------------- 1 file changed, 662 deletions(-) delete mode 100755 bin/create-single-file diff --git a/bin/create-single-file b/bin/create-single-file deleted file mode 100755 index ecb876b0..00000000 --- a/bin/create-single-file +++ /dev/null @@ -1,662 +0,0 @@ -#!/usr/bin/env php - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -// -------------------------------------------------------------------------- // -// This script can be used to automatically glue all the .php files of Predis -// into a single monolithic script file that can be used without an autoloader, -// just like the other previous versions of the library. -// -// Much of its complexity is due to the fact that we cannot simply join PHP -// files, but namespaces and classes definitions must follow a precise order -// when dealing with subclassing and inheritance. -// -// The current implementation is pretty naïve, but it should do for now. -// -------------------------------------------------------------------------- // - -class CommandLine -{ - public static function getOptions() - { - $parameters = array( - 's:' => 'source:', - 'o:' => 'output:', - 'e:' => 'exclude:', - 'E:' => 'exclude-classes:', - ); - - $getops = getopt(implode(array_keys($parameters)), $parameters); - - $options = array( - 'source' => __DIR__ . "/../src", - 'output' => PredisFile::NS_ROOT . '.php', - 'exclude' => array(), - ); - - foreach ($getops as $option => $value) { - switch ($option) { - case 's': - case 'source': - $options['source'] = $value; - break; - - case 'o': - case 'output': - $options['output'] = $value; - break; - - case 'E': - case 'exclude-classes': - $options['exclude'] = @file($value, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: $value; - break; - - case 'e': - case 'exclude': - $options['exclude'] = is_array($value) ? $value : array($value); - break; - } - } - - return $options; - } -} - -class PredisFile -{ - const NS_ROOT = 'Predis'; - - private $namespaces; - - public function __construct() - { - $this->namespaces = array(); - } - - public static function from($libraryPath, array $exclude = array()) - { - $predisFile = new PredisFile(); - $libIterator = new RecursiveDirectoryIterator($libraryPath); - - foreach (new RecursiveIteratorIterator($libIterator) as $classFile) - { - if (!$classFile->isFile()) { - continue; - } - - $namespace = self::NS_ROOT.strtr(str_replace($libraryPath, '', $classFile->getPath()), '/', '\\'); - - if (in_array(sprintf('%s\\%s', $namespace, $classFile->getBasename('.php')), $exclude)) { - continue; - } - - $phpNamespace = $predisFile->getNamespace($namespace); - - if ($phpNamespace === false) { - $phpNamespace = new PhpNamespace($namespace); - $predisFile->addNamespace($phpNamespace); - } - - $phpClass = new PhpClass($phpNamespace, $classFile); - } - - return $predisFile; - } - - public function addNamespace(PhpNamespace $namespace) - { - if (isset($this->namespaces[(string)$namespace])) { - throw new InvalidArgumentException("Duplicated namespace"); - } - $this->namespaces[(string)$namespace] = $namespace; - } - - public function getNamespaces() - { - return $this->namespaces; - } - - public function getNamespace($namespace) - { - if (!isset($this->namespaces[$namespace])) { - return false; - } - - return $this->namespaces[$namespace]; - } - - public function getClassByFQN($classFqn) - { - if (($nsLastPos = strrpos($classFqn, '\\')) !== false) { - $namespace = $this->getNamespace(substr($classFqn, 0, $nsLastPos)); - if ($namespace === false) { - return null; - } - $className = substr($classFqn, $nsLastPos + 1); - - return $namespace->getClass($className); - } - - return null; - } - - private function calculateDependencyScores(&$classes, $fqn) - { - if (!isset($classes[$fqn])) { - $classes[$fqn] = 0; - } - - $classes[$fqn] += 1; - - if (($phpClass = $this->getClassByFQN($fqn)) === null) { - throw new RuntimeException( - "Cannot found the class $fqn which is required by other subclasses. Are you missing a file?" - ); - } - - foreach ($phpClass->getDependencies() as $fqn) { - $this->calculateDependencyScores($classes, $fqn); - } - } - - private function getDependencyScores() - { - $classes = array(); - - foreach ($this->getNamespaces() as $phpNamespace) { - foreach ($phpNamespace->getClasses() as $phpClass) { - $this->calculateDependencyScores($classes, $phpClass->getFQN()); - } - } - - return $classes; - } - - private function getOrderedNamespaces($dependencyScores) - { - $namespaces = array_fill_keys(array_unique( - array_map( - function ($fqn) { return PhpNamespace::extractName($fqn); }, - array_keys($dependencyScores) - ) - ), 0); - - foreach ($dependencyScores as $classFqn => $score) { - $namespaces[PhpNamespace::extractName($classFqn)] += $score; - } - - arsort($namespaces); - - return array_keys($namespaces); - } - - private function getOrderedClasses(PhpNamespace $phpNamespace, $classes) - { - $nsClassesFQNs = array_map(function ($cl) { return $cl->getFQN(); }, $phpNamespace->getClasses()); - $nsOrderedClasses = array(); - - foreach ($nsClassesFQNs as $nsClassFQN) { - $nsOrderedClasses[$nsClassFQN] = $classes[$nsClassFQN]; - } - - arsort($nsOrderedClasses); - - return array_keys($nsOrderedClasses); - } - - public function getPhpCode() - { - $buffer = array("getDependencyScores(); - $namespaces = $this->getOrderedNamespaces($classes); - - foreach ($namespaces as $namespace) { - $phpNamespace = $this->getNamespace($namespace); - - // generate namespace directive - $buffer[] = $phpNamespace->getPhpCode(); - $buffer[] = "\n"; - - // generate use directives - $useDirectives = $phpNamespace->getUseDirectives(); - if (count($useDirectives) > 0) { - $buffer[] = $useDirectives->getPhpCode(); - $buffer[] = "\n"; - } - - // generate classes bodies - $nsClasses = $this->getOrderedClasses($phpNamespace, $classes); - foreach ($nsClasses as $classFQN) { - $buffer[] = $this->getClassByFQN($classFQN)->getPhpCode(); - $buffer[] = "\n\n"; - } - - $buffer[] = "/* " . str_repeat("-", 75) . " */"; - $buffer[] = "\n\n"; - } - - return implode($buffer); - } - - public function saveTo($outputFile) - { - // TODO: add more sanity checks - if ($outputFile === null || $outputFile === '') { - throw new InvalidArgumentException('You must specify a valid output file'); - } - file_put_contents($outputFile, $this->getPhpCode()); - } -} - -class PhpNamespace implements IteratorAggregate -{ - private $namespace; - private $classes; - - public function __construct($namespace) - { - $this->namespace = $namespace; - $this->classes = array(); - $this->useDirectives = new PhpUseDirectives($this); - } - - public static function extractName($fqn) - { - $nsSepLast = strrpos($fqn, '\\'); - if ($nsSepLast === false) { - return $fqn; - } - $ns = substr($fqn, 0, $nsSepLast); - - return $ns !== '' ? $ns : null; - } - - public function addClass(PhpClass $class) - { - $this->classes[$class->getName()] = $class; - } - - public function getClass($className) - { - if (isset($this->classes[$className])) { - return $this->classes[$className]; - } - } - - public function getClasses() - { - return array_values($this->classes); - } - - public function getIterator() - { - return new \ArrayIterator($this->getClasses()); - } - - public function getUseDirectives() - { - return $this->useDirectives; - } - - public function getPhpCode() - { - return "namespace $this->namespace;\n"; - } - - public function __toString() - { - return $this->namespace; - } -} - -class PhpUseDirectives implements Countable, IteratorAggregate -{ - private $use; - private $aliases; - private $reverseAliases; - private $namespace; - - public function __construct(PhpNamespace $namespace) - { - $this->namespace = $namespace; - $this->use = array(); - $this->aliases = array(); - $this->reverseAliases = array(); - } - - public function add($use, $as = null) - { - if (in_array($use, $this->use)) { - return; - } - - $rename = null; - $this->use[] = $use; - $aliasedClassName = $as ?: PhpClass::extractName($use); - - if (isset($this->aliases[$aliasedClassName])) { - $parentNs = $this->getParentNamespace(); - - if ($parentNs && false !== $pos = strrpos($parentNs, '\\')) { - $parentNs = substr($parentNs, $pos); - } - - $newAlias = "{$parentNs}_{$aliasedClassName}"; - $rename = (object) array( - 'namespace' => $this->namespace, - 'from' => $aliasedClassName, - 'to' => $newAlias, - ); - - $this->aliases[$newAlias] = $use; - $as = $newAlias; - } else { - $this->aliases[$aliasedClassName] = $use; - } - - if ($as !== null) { - $this->reverseAliases[$use] = $as; - } - - return $rename; - } - - public function getList() - { - return $this->use; - } - - public function getIterator() - { - return new \ArrayIterator($this->getList()); - } - - public function getPhpCode() - { - $reverseAliases = $this->reverseAliases; - - $reducer = function ($str, $use) use ($reverseAliases) { - if (isset($reverseAliases[$use])) { - return $str .= "use $use as {$reverseAliases[$use]};\n"; - } else { - return $str .= "use $use;\n"; - } - }; - - return array_reduce($this->getList(), $reducer, ''); - } - - public function getNamespace() - { - return $this->namespace; - } - - public function getParentNamespace() - { - if (false !== $pos = strrpos($this->namespace, '\\')) { - return substr($this->namespace, 0, $pos); - } - - return ''; - } - - public function getFQN($className) - { - if (($nsSepFirst = strpos($className, '\\')) === false) { - if (isset($this->aliases[$className])) { - return $this->aliases[$className]; - } - - return (string)$this->getNamespace() . "\\$className"; - } - - if ($nsSepFirst != 0) { - throw new InvalidArgumentException("Partially qualified names are not supported"); - } - - return $className; - } - - public function count() - { - return count($this->use); - } -} - -class PhpClass -{ - const LICENSE_HEADER = << - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -LICENSE; - - private $namespace; - private $file; - private $body; - private $implements; - private $extends; - private $name; - - public function __construct(PhpNamespace $namespace, SplFileInfo $classFile) - { - $this->namespace = $namespace; - $this->file = $classFile; - $this->implements = array(); - $this->extends = array(); - - $this->extractData(); - $namespace->addClass($this); - } - - public static function extractName($fqn) - { - $nsSepLast = strrpos($fqn, '\\'); - if ($nsSepLast === false) { - return $fqn; - } - - return substr($fqn, $nsSepLast + 1); - } - - private function extractData() - { - $renames = array(); - $useDirectives = $this->getNamespace()->getUseDirectives(); - - $useExtractor = function ($m) use ($useDirectives, &$renames) { - array_shift($m); - - if (isset($m[1])) { - $m[1] = str_replace(" as ", '', $m[1]); - } - - if ($rename = call_user_func_array(array($useDirectives, 'add'), $m)) { - $renames[] = $rename; - } - }; - - $classBuffer = stream_get_contents(fopen($this->getFile()->getPathname(), 'r')); - - $classBuffer = str_replace(self::LICENSE_HEADER, '', $classBuffer); - - $classBuffer = preg_replace('/<\?php\s?\\n\s?/', '', $classBuffer); - $classBuffer = preg_replace('/\s?\?>\n?/ms', '', $classBuffer); - $classBuffer = preg_replace('/namespace\s+[\w\d_\\\\]+;\s?/', '', $classBuffer); - $classBuffer = preg_replace_callback('/use\s+([\w\d_\\\\]+)(\s+as\s+.*)?;\s?\n?/', $useExtractor, $classBuffer); - - foreach ($renames as $rename) { - $classBuffer = str_replace($rename->from, $rename->to, $classBuffer); - } - - $this->body = trim($classBuffer); - - $this->extractHierarchy(); - } - - private function extractHierarchy() - { - $implements = array(); - $extends = array(); - - $extractor = function ($iterator, $callback) { - $className = ''; - $iterator->seek($iterator->key() + 1); - - while ($iterator->valid()) { - $token = $iterator->current(); - - if (is_string($token)) { - if (preg_match('/\s?,\s?/', $token)) { - $callback(trim($className)); - $className = ''; - } else if ($token == '{') { - $callback(trim($className)); - return; - } - } - - switch ($token[0]) { - case T_NS_SEPARATOR: - $className .= '\\'; - break; - - case T_STRING: - $className .= $token[1]; - break; - - case T_IMPLEMENTS: - case T_EXTENDS: - $callback(trim($className)); - $iterator->seek($iterator->key() - 1); - return; - } - - $iterator->next(); - } - }; - - $tokens = token_get_all("getPhpCode())); - $iterator = new ArrayIterator($tokens); - - while ($iterator->valid()) { - $token = $iterator->current(); - if (is_string($token)) { - $iterator->next(); - continue; - } - - switch ($token[0]) { - case T_CLASS: - case T_INTERFACE: - $iterator->seek($iterator->key() + 2); - $tk = $iterator->current(); - $this->name = $tk[1]; - break; - - case T_IMPLEMENTS: - $extractor($iterator, function ($fqn) use (&$implements) { - $implements[] = $fqn; - }); - break; - - case T_EXTENDS: - $extractor($iterator, function ($fqn) use (&$extends) { - $extends[] = $fqn; - }); - break; - } - - $iterator->next(); - } - - $this->implements = $this->guessFQN($implements); - $this->extends = $this->guessFQN($extends); - } - - public function guessFQN($classes) - { - $useDirectives = $this->getNamespace()->getUseDirectives(); - return array_map(array($useDirectives, 'getFQN'), $classes); - } - - public function getImplementedInterfaces($all = false) - { - if ($all) { - return $this->implements; - } - - return array_filter( - $this->implements, - function ($cn) { return strpos($cn, 'Predis\\') === 0; } - ); - } - - public function getExtendedClasses($all = false) - { - if ($all) { - return $this->extemds; - } - - return array_filter( - $this->extends, - function ($cn) { return strpos($cn, 'Predis\\') === 0; } - ); - } - - public function getDependencies($all = false) - { - return array_merge( - $this->getImplementedInterfaces($all), - $this->getExtendedClasses($all) - ); - } - - public function getNamespace() - { - return $this->namespace; - } - - public function getFile() - { - return $this->file; - } - - public function getName() - { - return $this->name; - } - - public function getFQN() - { - return (string)$this->getNamespace() . '\\' . $this->name; - } - - public function getPhpCode() - { - return $this->body; - } - - public function __toString() - { - return "class " . $this->getName() . '{ ... }'; - } -} - -/* -------------------------------------------------------------------------- */ - -$options = CommandLine::getOptions(); -$predisFile = PredisFile::from($options['source'], $options['exclude']); -$predisFile->saveTo($options['output']); From 7636d55e105b45417157d07a98358dea4e07f774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Fri, 14 Aug 2020 10:10:01 -0700 Subject: [PATCH 3/6] rename github org --- CONTRIBUTING.md | 2 +- FAQ.md | 2 +- README.md | 10 +++++----- composer.json | 4 ++-- tests/Predis/Collection/Iterator/HashKeyTest.php | 4 ++-- tests/Predis/Collection/Iterator/SortedSetKeyTest.php | 2 +- tests/Predis/Command/StringIncrementByFloatTest.php | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9ad2f5e3..3cf3c21b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Filing bug reports ## -Bugs or feature requests can be posted on the [GitHub issues](http://github.com/predishq/predis/issues) +Bugs or feature requests can be posted on the [GitHub issues](http://github.com/predis/predis/issues) section of the project. When reporting bugs, in addition to the obvious description of your issue you __must__ always provide diff --git a/FAQ.md b/FAQ.md index 567f6b9e..152f534a 100644 --- a/FAQ.md +++ b/FAQ.md @@ -33,7 +33,7 @@ usually something that developers prefer to customize depending on their needs a generalized when using Redis because of the many possible access patterns for your data. This does not mean that it is impossible to have such a feature since you can leverage the extensibility of this library to define your own serialization-aware commands. You can find more details about how to -do that [on this issue](http://github.com/predishq/predis/issues/29#issuecomment-1202624). +do that [on this issue](http://github.com/predis/predis/issues/29#issuecomment-1202624). ### How can I force Predis to connect to Redis before sending any command? ### diff --git a/README.md b/README.md index e8b45e78..1b6946c8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Latest development][ico-version-dev]][link-packagist] [![Monthly installs][ico-downloads-monthly]][link-downloads] [![Build status][ico-travis]][link-travis] -![Build](https://github.com/predishq/predis/workflows/Predis%20Builds/badge.svg) +![Build](https://github.com/predis/predis/workflows/Predis%20Builds/badge.svg) A flexible and feature-complete [Redis](http://redis.io) client for PHP 7.2 and newer. @@ -39,7 +39,7 @@ More details about this project can be found on the [frequently asked questions] This library can be found on [Packagist](http://packagist.org/packages/predis/predis) for an easier management of projects dependencies using [Composer](http://packagist.org/about-composer) or on our [own PEAR channel](http://pear.nrk.io) for a more traditional installation using PEAR. Ultimately, -compressed archives of each release are [available on GitHub](https://github.com/predishq/predis/releases). +compressed archives of each release are [available on GitHub](https://github.com/predis/predis/releases). ### Loading the library ### @@ -460,9 +460,9 @@ found [on its project page](http://travis-ci.org/predishq/predis). ### Project related links ### -- [Source code](https://github.com/predishq/predis) -- [Wiki](https://github.com/predishq/predis/wiki) -- [Issue tracker](https://github.com/predishq/predis/issues) +- [Source code](https://github.com/predis/predis) +- [Wiki](https://github.com/predis/predis/wiki) +- [Issue tracker](https://github.com/predis/predis/issues) ### Author ### diff --git a/composer.json b/composer.json index cf48c36d..0883250f 100644 --- a/composer.json +++ b/composer.json @@ -3,10 +3,10 @@ "type": "library", "description": "A flexible and feature-complete Redis client for PHP.", "keywords": ["nosql", "redis", "predis"], - "homepage": "http://github.com/predishq/predis", + "homepage": "http://github.com/predis/predis", "license": "MIT", "support": { - "issues": "https://github.com/predishq/predis/issues" + "issues": "https://github.com/predis/predis/issues" }, "authors": [ { diff --git a/tests/Predis/Collection/Iterator/HashKeyTest.php b/tests/Predis/Collection/Iterator/HashKeyTest.php index d2901749..56088638 100644 --- a/tests/Predis/Collection/Iterator/HashKeyTest.php +++ b/tests/Predis/Collection/Iterator/HashKeyTest.php @@ -57,8 +57,8 @@ class HashKeyTest extends PredisTestCase } /** - * @see https://github.com/predishq/predis/pull/330 - * @see https://github.com/predishq/predis/issues/331 + * @see https://github.com/predis/predis/pull/330 + * @see https://github.com/predis/predis/issues/331 * @group disconnected */ public function testIterationWithIntegerFields() diff --git a/tests/Predis/Collection/Iterator/SortedSetKeyTest.php b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php index aeadeb5f..5435e7db 100644 --- a/tests/Predis/Collection/Iterator/SortedSetKeyTest.php +++ b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php @@ -57,7 +57,7 @@ class SortedSetKeyTest extends PredisTestCase } /** - * @see https://github.com/predishq/predis/issues/216 + * @see https://github.com/predis/predis/issues/216 * @group disconnected */ public function testIterationWithIntegerMembers() diff --git a/tests/Predis/Command/StringIncrementByFloatTest.php b/tests/Predis/Command/StringIncrementByFloatTest.php index 4976d1fc..796bcb8c 100644 --- a/tests/Predis/Command/StringIncrementByFloatTest.php +++ b/tests/Predis/Command/StringIncrementByFloatTest.php @@ -76,7 +76,7 @@ class StringIncrementByFloatTest extends PredisCommandTestCase $redis->set('foo', 2); // We use round() to avoid errors on some platforms, see the following - // issue https://github.com/predishq/predis/issues/220 for reference. + // issue https://github.com/predis/predis/issues/220 for reference. $this->assertEquals(22.123, $redis->incrbyfloat('foo', 20.123)); $this->assertEquals(10, round($redis->incrbyfloat('foo', -12.123), 5)); $this->assertEquals(-100.01, round($redis->incrbyfloat('foo', -110.01), 5)); From 71b2119436d94b3384e12f77bc715cee9327bfd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Fri, 14 Aug 2020 10:15:57 -0700 Subject: [PATCH 4/6] bump version --- VERSION | 2 +- src/Client.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 45a1b3f4..d72f2626 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.2 +2.0.0-dev diff --git a/src/Client.php b/src/Client.php index 4b210696..6e492f81 100644 --- a/src/Client.php +++ b/src/Client.php @@ -40,7 +40,7 @@ use Predis\Transaction\MultiExec as MultiExecTransaction; */ class Client implements ClientInterface, \IteratorAggregate { - const VERSION = '1.1.2'; + const VERSION = '2.0.0-dev'; protected $connection; protected $options; From d4a170d890817ff923efd2e1c8326f7ef707c18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Fri, 14 Aug 2020 10:27:07 -0700 Subject: [PATCH 5/6] drop Travis --- .gitattributes | 2 - .../workflows/{gh-actions.yml => tests.yml} | 15 +++--- .travis.yml | 29 ---------- README.md | 4 +- phpunit.xml.travisci | 54 ------------------- 5 files changed, 9 insertions(+), 95 deletions(-) rename .github/workflows/{gh-actions.yml => tests.yml} (72%) delete mode 100644 .travis.yml delete mode 100644 phpunit.xml.travisci diff --git a/.gitattributes b/.gitattributes index ca9c9dab..f39ca25e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,6 +5,4 @@ /.gitattributes export-ignore /.gitignore export-ignore /.php_cs export-ignore -/.travis.yml export-ignore /phpunit.xml.dist export-ignore -/phpunit.xml.travisci export-ignore diff --git a/.github/workflows/gh-actions.yml b/.github/workflows/tests.yml similarity index 72% rename from .github/workflows/gh-actions.yml rename to .github/workflows/tests.yml index e2d12bd0..762e0b04 100644 --- a/.github/workflows/gh-actions.yml +++ b/.github/workflows/tests.yml @@ -1,9 +1,8 @@ -# GitHub Action for Predis with PHP 7.2, 7.3, 7.4 & 8.0 & Redis 3, 4, 5 & 6 -name: Predis Builds +name: Tests on: [push, pull_request] jobs: predis: - name: Redis ${{ matrix.redis-versions }} (PHP ${{ matrix.php-versions }}) + name: PHP ${{ matrix.php-versions }} (Redis ${{ matrix.redis-versions }}) runs-on: ubuntu-latest services: redis: @@ -19,14 +18,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: Setup PHP, with composer and extensions + - name: Setup PHP with Composer and extensions with: php-version: ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php - - name: Get composer cache directory + uses: shivammathur/setup-php@v2 + - name: Get Composer cache directory id: composercache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Cache composer dependencies + - name: Cache Composer dependencies uses: actions/cache@v2 with: php-version: ${{ matrix.php-versions }} @@ -35,5 +34,5 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies run: composer install --no-progress --prefer-dist --optimize-autoloader - - name: Test with phpunit + - name: Test with PHPUnit run: vendor/bin/phpunit diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index beb94583..00000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: php -sudo: false -branches: - except: - - v0.5 - - v0.6 - - v0.6-PHP_5.2 - - documentation -before_install: - - docker run -d --rm -p 127.0.0.1:6379:6379 redis:${REDIS_VERSION:=3} -before_script: - - composer self-update - - composer install --no-interaction --prefer-source --dev -script: - - travis_retry vendor/bin/phpunit -c phpunit.xml.travisci -matrix: - fast_finish: true - include: - - php: 7.2 - - php: 7.3 - - php: 7.4 - env: REDIS_VERSION=4 # useless comment to trigger Travis - - php: 7.4 - env: REDIS_VERSION=5 - - php: 7.4 - env: REDIS_VERSION=6 - - php: nightly - allow_failures: - - php: nightly diff --git a/README.md b/README.md index 1b6946c8..7fa44c62 100644 --- a/README.md +++ b/README.md @@ -451,8 +451,8 @@ the `unstable` branch by modifying `phpunit.xml` and setting `REDIS_SERVER_VERSI the development server profile will be used. You can refer to [the tests README](tests/README.md) for more detailed information about testing Predis. -Predis uses Travis CI for continuous integration and the history for past and current builds can be -found [on its project page](http://travis-ci.org/predishq/predis). +Predis uses GitHub Actions for continuous integration and the history for past and current builds can be +found [on its actions page](https://github.com/predis/predis/actions). ## Other ## diff --git a/phpunit.xml.travisci b/phpunit.xml.travisci deleted file mode 100644 index 3bd2bf04..00000000 --- a/phpunit.xml.travisci +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - tests/Predis/ - - - - - - ext-phpiredis - ext-curl - realm-webdis - - - - - - - - - - src/ - - - - - - - - - - - - - - - - - - - From 25b6b824b4e03b0ad7db5560187515cfd8dc41a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Fri, 14 Aug 2020 10:35:25 -0700 Subject: [PATCH 6/6] update badges --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7fa44c62..a73dc9f5 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ [![Latest stable][ico-version-stable]][link-packagist] [![Latest development][ico-version-dev]][link-packagist] [![Monthly installs][ico-downloads-monthly]][link-downloads] -[![Build status][ico-travis]][link-travis] -![Build](https://github.com/predis/predis/workflows/Predis%20Builds/badge.svg) +[![Build status][ico-build]][link-actions] A flexible and feature-complete [Redis](http://redis.io) client for PHP 7.2 and newer. @@ -475,12 +474,12 @@ found [on its actions page](https://github.com/predis/predis/actions). The code for Predis is distributed under the terms of the MIT license (see [LICENSE](LICENSE)). -[ico-license]: https://img.shields.io/github/license/predishq/predis.svg?style=flat-square -[ico-version-stable]: https://img.shields.io/packagist/v/predis/predis.svg?style=flat-square -[ico-version-dev]: https://img.shields.io/packagist/vpre/predis/predis.svg?style=flat-square -[ico-downloads-monthly]: https://img.shields.io/packagist/dm/predis/predis.svg?style=flat-square -[ico-travis]: https://img.shields.io/travis/predishq/predis.svg?style=flat-square +[ico-license]: https://img.shields.io/github/license/predis/predis.svg +[ico-version-stable]: https://img.shields.io/packagist/v/predis/predis.svg +[ico-version-dev]: https://img.shields.io/packagist/vpre/predis/predis.svg +[ico-downloads-monthly]: https://img.shields.io/packagist/dm/predis/predis.svg +[ico-build]: https://img.shields.io/github/workflow/status/predis/predis/Tests/main [link-packagist]: https://packagist.org/packages/predis/predis -[link-travis]: https://travis-ci.org/predishq/predis +[link-actions]: https://github.com/predis/predis/actions [link-downloads]: https://packagist.org/packages/predis/predis/stats