diff --git a/.scrutinizer.yml b/.scrutinizer.yml index c6d0a84..86a057c 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -2,8 +2,9 @@ imports: - php inherit: true tools: - external_code_coverage: - runs: 4 + ##See .travis.yml. + #external_code_coverage: + # runs: 4 php_sim: false php_cpd: true php_code_sniffer: diff --git a/.travis.yml b/.travis.yml index 80363c6..8d7c1da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,10 @@ before_script: - ../vendor/bin/phpunit --configuration secondaryPeer.xml > secondaryPeer.out.txt & - sleep 2 script: - - ../vendor/bin/phpunit --coverage-clover=coverage.clover --configuration phpunit.xml - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover + - ../vendor/bin/phpunit --configuration phpunit.xml + ## Code coverage seems to be causing a failure currently. + #- ../vendor/bin/phpunit --coverage-clover=coverage.clover --configuration phpunit.xml + #- wget https://scrutinizer-ci.com/ocular.phar + #- php ocular.phar code-coverage:upload --format=php-clover coverage.clover after_script: - cat secondaryPeer.out.txt \ No newline at end of file diff --git a/RELEASE-1.0.0a5 b/RELEASE-1.0.0a5 index 074a5eb..48d7a10 100644 --- a/RELEASE-1.0.0a5 +++ b/RELEASE-1.0.0a5 @@ -1,3 +1,4 @@ * Added fragments to exceptions, allowing retrieval of incomplete receives' contents, and byte count on incomplete sends. * Changed Stream to use an fread/fwrite duo instead of stream_copy_to_stream() for the sake of stability. +* Tweaked Stream::isAcceptingData() and NetworkStream::isAvailable(), in order to work around a reproducible hang on Linux. * Doc fixes. \ No newline at end of file diff --git a/composer.json b/composer.json index 022d983..96614ad 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "phpunit/phpunit": "@stable" }, "suggest": { - "pear2/cache_shm": ">=0.1.2", + "pear2/cache_shm": ">=0.1.3", "ext-apc": ">=3.0.13", "ext-wincache": ">=1.1.0", "ext-openssl": "*" diff --git a/package.xml b/package.xml index 889dc27..c59e765 100644 --- a/package.xml +++ b/package.xml @@ -2,8 +2,7 @@ PEAR2_Net_Transmitter pear2.php.net - Wrapper for network stream functionality. - + Wrapper for network stream functionality. PHP has built in support for various types of network streams, such as HTTP and TCP sockets. One problem that arises with them is the fact that a single fread/fwrite call might not read/write all the data you intended, regardless of whether you're in blocking mode or not. While the PHP manual offers a workaround in the form of a loop with a few variables, using it every single time you want to read/write can be tedious. This package abstracts this away, so that when you want to get exactly N amount of bytes, you can be sure the upper levels of your app will be dealing with N bytes. Oh, and the functionality is nicely wrapped in an object (but that's just the icing on the cake). @@ -13,10 +12,10 @@ This package abstracts this away, so that when you want to get exactly N amount boen.robot@gmail.com yes - 2013-08-15 - + 2014-11-02 + - 1.0.0a4 + 1.0.0a5 1.0.0 @@ -24,23 +23,22 @@ This package abstracts this away, so that when you want to get exactly N amount alpha LGPL License 2.1 - * Support for encrypted connections. Note that due to known issues with PHP itself, encrypted connections may be unstable (as in "sometimes disconnect suddenly" or "sometimes hang when calling TcpClient::isDataAwaiting() without a timeout"). -* Stream::isAcceptingData() and Stream::isDataAwaiting() now accept an optional timeout, modeled after stream_select(). -* Changed sending to retry indefinetly unless the connection is broken, thanks to isDataAwaiting()'s new ability. Receiving can still timeout. -* Chnaged the PHAR stub to not fail when reading the hash fails. -* Doc and CS fixes. + * Added fragments to exceptions, allowing retrieval of incomplete receives' contents, and byte count on incomplete sends. +* Changed Stream to use an fread/fwrite duo instead of stream_copy_to_stream() for the sake of stability. +* Tweaked Stream::isAcceptingData() and NetworkStream::isAvailable(), in order to work around a reproducible hang on Linux. +* Doc fixes. - + - - + + - + @@ -48,49 +46,49 @@ This package abstracts this away, so that when you want to get exactly N amount - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + @@ -98,14 +96,22 @@ This package abstracts this away, so that when you want to get exactly N amount - + + - + - - - - + + + + + + + + + + + @@ -129,7 +135,7 @@ This package abstracts this away, so that when you want to get exactly N amount PEAR2_Cache_SHM pear2.php.net - 0.1.2 + 0.1.3 openssl @@ -137,6 +143,29 @@ This package abstracts this away, so that when you want to get exactly N amount - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packagexmlsetup.php b/packagexmlsetup.php index d41eb3b..d536d55 100644 --- a/packagexmlsetup.php +++ b/packagexmlsetup.php @@ -14,163 +14,150 @@ * @link http://pear2.php.net/PEAR2_Net_Transmitter */ +/** + * References the package in $package and/or $compatible. + */ use Pyrus\Developer\PackageFile\v2; +/** + * Configuration array. + * + * Each key is the task. + * + * The task "replace" uses an array where the key is the value to be searched + * for, and the value is an array of additional attributes for the task, which + * normally contain at least "type" (pear-config/package-info) and "to", which + * specifies the value to replace it with. + * + * The task "eol" uses an array where the key is a filename pattern to be + * matched, and the value is the target platform's EOL to be used for those + * file names (windows/unix). + * + * Unrecognized tasks are ignored. + * + * @var array + */ +$config = array( + 'replace' => array( + '../src' => array( + 'type' => 'pear-config', + 'to' => 'php_dir' + ), + 'GIT: $Id$' => array( + 'type' => 'package-info', + 'to' => 'version' + ), + '~~summary~~' => array( + 'type' => 'package-info', + 'to' => 'summary' + ), + '~~description~~' => array( + 'type' => 'package-info', + 'to' => 'description' + ) + ), + 'eol' => array( + '*.bat' => 'windows' + ) +); + +if (!isset($package)) { + die('This file must be executed via "pyrus.phar make".'); +} + $packageGen = function ( + array $config, v2 $package, v2 $compatible = null ) { - $srcDirTask = array( - 'tasks:replace' => array( - array( - 'attribs' => array( - 'from' => '../src', - 'to' => 'php_dir', - 'type' => 'pear-config' - ) - ) - ) - ); - - $srcFileTasks = array( - 'tasks:replace' => array( - array( - 'attribs' => array( - 'from' => '~~summary~~', - 'to' => 'summary', - 'type' => 'package-info' - ) - ), - array( - 'attribs' => array( - 'from' => '~~description~~', - 'to' => 'description', - 'type' => 'package-info' - ) - ), - array( - 'attribs' => array( - 'from' => 'GIT: $Id$', - 'to' => 'version', - 'type' => 'package-info' - ) - ) - ) - ); - - $package->files['tests/bootstrap.php'] = array_merge_recursive( - $package->files['tests/bootstrap.php']->getArrayCopy(), - $srcDirTask - ); - - $package->files['docs/phpdoc.dist.xml'] = array_merge_recursive( - $package->files['docs/phpdoc.dist.xml']->getArrayCopy(), - $srcDirTask - ); - $package->files['docs/apigen.neon'] = array_merge_recursive( - $package->files['docs/apigen.neon']->getArrayCopy(), - $srcDirTask - ); - - $package->files['docs/doxygen.ini'] = array_merge_recursive( - $package->files['docs/doxygen.ini']->getArrayCopy(), - $srcDirTask, - array( - 'tasks:replace' => array( - array( - 'attribs' => array( - 'from' => 'GIT: $Id$', - 'to' => 'version', - 'type' => 'package-info' - ) - ) - ) - ) - ); - $hasCompatible = null !== $compatible; - if ($hasCompatible) { - $compatible->license = $package->license; - $compatible->files[ - "test/{$package->channel}/{$package->name}/bootstrap.php" - ] = array_merge_recursive( - $compatible->files[ - "test/{$package->channel}/{$package->name}/bootstrap.php" - ]->getArrayCopy(), - $srcDirTask - ); - - $compatible->files[ - "doc/{$package->channel}/{$package->name}/phpdoc.dist.xml" - ] = array_merge_recursive( - $compatible->files[ - "doc/{$package->channel}/{$package->name}/phpdoc.dist.xml" - ]->getArrayCopy(), - $srcDirTask - ); - $compatible->files["doc/{$package->channel}/{$package->name}/doxygen.ini"] - = array_merge_recursive( - $compatible->files[ - "doc/{$package->channel}/{$package->name}/doxygen.ini" - ]->getArrayCopy(), - $srcDirTask, - array( - 'tasks:replace' => array( - array( - 'attribs' => array( - 'from' => 'GIT: $Id$', - 'to' => 'version', - 'type' => 'package-info' - ) - ) - ) - ) - ); - } + $tasksNs = $package->getTasksNs(); + $cTasksNs = $compatible ? $compatible->getTasksNs() : ''; $oldCwd = getcwd(); chdir(__DIR__); - foreach ( - new RecursiveIteratorIterator( - new RecursiveDirectoryIterator( - 'src', - RecursiveDirectoryIterator::UNIX_PATHS - | RecursiveDirectoryIterator::SKIP_DOTS - ), - RecursiveIteratorIterator::LEAVES_ONLY - ) as $path) { - $filename = $path->getPathname(); - - $package->files[$filename] = array_merge_recursive( - $package->files[$filename]->getArrayCopy(), - $srcFileTasks - ); - - if ($hasCompatible) { - $compatibleFilename = str_replace('src/', 'php/', $filename); - $compatible->files[$compatibleFilename] = array_merge_recursive( - $compatible->files[$compatibleFilename]->getArrayCopy(), - $srcFileTasks - ); - } - } - - foreach ( - new RecursiveIteratorIterator( - new RecursiveDirectoryIterator( - '.', - RecursiveDirectoryIterator::UNIX_PATHS - | RecursiveDirectoryIterator::SKIP_DOTS - ), - RecursiveIteratorIterator::LEAVES_ONLY - ) as $path) { + foreach (new RecursiveIteratorIterator( + new RecursiveDirectoryIterator( + '.', + RecursiveDirectoryIterator::UNIX_PATHS + | RecursiveDirectoryIterator::SKIP_DOTS + ), + RecursiveIteratorIterator::LEAVES_ONLY + ) as $path) { $filename = substr($path->getPathname(), 2); + $cFilename = str_replace('src/', 'php/', $filename); if (isset($package->files[$filename])) { + $parsedFilename = pathinfo($filename); $as = (strpos($filename, 'examples/') === 0) ? $filename : substr($filename, strpos($filename, '/') + 1); + if (strpos($filename, 'scripts/') === 0) { + if (isset($parsedFilename['extension']) + && 'php' === $parsedFilename['extension'] + && !is_file( + $parsedFilename['dirname'] . '/' . + $parsedFilename['filename'] + ) + && is_file( + $parsedFilename['dirname'] . '/' . + $parsedFilename['filename'] . '.bat' + ) + ) { + $as = substr($as, 0, -4); + } + } $package->getReleaseToInstall('php')->installAs($filename, $as); + + $contents = file_get_contents($filename); + foreach ($config['replace'] as $from => $attribs) { + if (strpos($contents, $from) !== false) { + $attribs['from'] = $from; + $package->files[$filename] = array_merge_recursive( + $package->files[$filename]->getArrayCopy(), + array( + "{$tasksNs}:replace" => array( + array( + 'attribs' => $attribs + ) + ) + ) + ); + + if ($compatible) { + $compatible->files[$cFilename] = array_merge_recursive( + $compatible->files[$cFilename]->getArrayCopy(), + array( + "{$cTasksNs}:replace" => array( + array( + 'attribs' => $attribs + ) + ) + ) + ); + } + } + } + + foreach ($config['eol'] as $pattern => $platform) { + if (fnmatch($pattern, $filename)) { + $package->files[$filename] = array_merge_recursive( + $package->files[$filename]->getArrayCopy(), + array( + "{$tasksNs}:{$platform}eol" => array() + ) + ); + + if ($compatible) { + $compatible->files[$cFilename] = array_merge_recursive( + $compatible->files[$cFilename]->getArrayCopy(), + array( + "{$cTasksNs}:{$platform}eol" => array() + ) + ); + } + } + } } } chdir($oldCwd); @@ -178,6 +165,7 @@ }; list($package, $compatible) = $packageGen( + $config, $package, isset($compatible) ? $compatible : null ); diff --git a/stub.php b/stub.php index cc82a6f..5c741d9 100644 --- a/stub.php +++ b/stub.php @@ -70,7 +70,7 @@ } else { echo <<