[COMPOSER] Add new php-ffmpeg package

This commit is contained in:
t3nma
2020-08-07 23:42:38 +01:00
committed by Diogo Peralta Cordeiro
parent 83ba7030cc
commit d7ec199793
8874 changed files with 1090008 additions and 154 deletions

View File

@@ -0,0 +1,213 @@
# Changelog
All notable changes to this project will be documented in this file, in reverse chronological order by release.
## 2.9.1 - 2019-10-19
### Added
- [#39](https://github.com/zendframework/zend-serializer/pull/39) adds support for PHP 7.3.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- Nothing.
## 2.9.0 - 2018-05-14
### Added
- [#37](https://github.com/zendframework/zend-serializer/pull/37) adds support to the `PhpSerialize` adapter to allow it to support the
PHP 7 `$options` parameter of `unserialize`, and, specifically, the `allowed_classes` parameter.
A new options class, `PhpSerializeOptions`, now allows setting the `unserialize_class_whitelist`
option, which may be one of `true` (any class may be unserialized; current behavior), `false`
(no class may be unserialized), or an `array` of class names that are explicitly allowed to
be unserialized. An instance of this class may now be passed to the `PhpSerialize` constructor
in order to set the intended/expected behavior.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#34](https://github.com/zendframework/zend-serializer/pull/34) removes a redundant dependency on a Doctrine package.
## 2.8.1 - 2017-11-20
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#26](https://github.com/zendframework/zend-serializer/pull/26)
Travis: Remove fast finish flag
- [#32](https://github.com/zendframework/zend-serializer/pull/32)
Travis: fix doctrine/instantiator on PHP-5.6
- [#27](https://github.com/zendframework/zend-serializer/pull/27)
CS fixes for new coding standard
- [#25](https://github.com/zendframework/zend-serializer/pull/25)
Travis: Move coverage to latest-env to make composer.lock usefull again
- [#30](https://github.com/zendframework/zend-serializer/issues/30)
Fixed unserialize PythonPickle on big endian
## 2.8.0 - 2016-06-21
### Added
- [#20](https://github.com/zendframework/zend-serializer/pull/20) adds support
for zend-json v3.0.
### Deprecated
- Nothing.
### Removed
- [#20](https://github.com/zendframework/zend-serializer/pull/20) removes support
for PHP 5.5.
### Fixed
- Nothing.
## 2.7.2 - 2016-05-11
### Added
- [#17](https://github.com/zendframework/zend-serializer/pull/17) adds and
publishes the documentation to https://zendframework.github.com/zend-serializer/
### Deprecated
- Nothing.
### Removed
- [#16](https://github.com/zendframework/zend-serializer/pull/16) removes the
dependency on zend-math, making it optional. (This was done as the requirement
is only when using the `PythonPickle` adapter.)
### Fixed
- [#9](https://github.com/zendframework/zend-serializer/pull/9) fixes the
behavior of the `PhpSerialize` adapter to raise an exception during
deserialization if the value is not serialized, restoring behavior to match
the other adapters.
## 2.7.1 - 2016-04-18
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#15](https://github.com/zendframework/zend-serializer/pull/15) fixes the
`Module::init()` method to properly receive a `ModuleManager` instance, and
not expect a `ModuleEvent`.
## 2.7.0 - 2016-04-06
### Added
- [#14](https://github.com/zendframework/zend-serializer/pull/14) exposes the
package as a ZF component and/or generic configuration provider, by adding the
following:
- `AdapterPluginManagerFactory`, which can be consumed by container-interop /
zend-servicemanager to create and return a `AdapterPluginManager` instance.
- `ConfigProvider`, which maps the service `SerializerAdapterManager` to the above
factory.
- `Module`, which does the same as `ConfigProvider`, but specifically for
zend-mvc applications. It also provices a specification to
`Zend\ModuleManager\Listener\ServiceListener` to allow modules to provide
serializer configuration.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- Nothing.
## 2.6.1 - 2016-02-03
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#13](https://github.com/zendframework/zend-serializer/pull/13) updates the
zend-stdlib dependency to `^2.7 || ^3.0`, as it can work with either version.
## 2.6.0 - 2016-02-02
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#2](https://github.com/zendframework/zend-serializer/pull/2) updates the component
to use zend-servicemanager v3. This involves updating the `AdapterPluginManager`
to follow changes to `Zend\ServiceManager\AbstractPluginManager`, and updating
the `Serializer` class to inject an empty `ServiceManager` into instances of
the `AbstractPluginManager` that it creates.

View File

@@ -0,0 +1,27 @@
Copyright (c) 2005-2019, Zend Technologies USA, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
- Neither the name of Zend Technologies USA, Inc. nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,10 @@
# zend-serializer
[![Build Status](https://secure.travis-ci.org/zendframework/zend-serializer.svg?branch=master)](https://secure.travis-ci.org/zendframework/zend-serializer)
[![Coverage Status](https://coveralls.io/repos/github/zendframework/zend-serializer/badge.svg?branch=master)](https://coveralls.io/github/zendframework/zend-serializer?branch=master)
zend-serializer provides an adapter-based interface for generating and
recovering from storable representations of PHP types.
- File issues at https://github.com/zendframework/zend-serializer/issues
- Documentation is at https://docs.zendframework.com/zend-serializer/

View File

@@ -0,0 +1,66 @@
{
"name": "zendframework/zend-serializer",
"description": "Serialize and deserialize PHP structures to a variety of representations",
"license": "BSD-3-Clause",
"keywords": [
"zf",
"zendframework",
"serializer"
],
"support": {
"docs": "https://docs.zendframework.com/zend-serializer/",
"issues": "https://github.com/zendframework/zend-serializer/issues",
"source": "https://github.com/zendframework/zend-serializer",
"rss": "https://github.com/zendframework/zend-serializer/releases.atom",
"chat": "https://zendframework-slack.herokuapp.com",
"forum": "https://discourse.zendframework.com/c/questions/components"
},
"require": {
"php": "^5.6 || ^7.0",
"zendframework/zend-json": "^2.5 || ^3.0",
"zendframework/zend-stdlib": "^2.7 || ^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.16",
"zendframework/zend-coding-standard": "~1.0.0",
"zendframework/zend-math": "^2.6 || ^3.0",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3"
},
"suggest": {
"zendframework/zend-math": "(^2.6 || ^3.0) To support Python Pickle serialization",
"zendframework/zend-servicemanager": "(^2.7.5 || ^3.0.3) To support plugin manager support"
},
"autoload": {
"psr-4": {
"Zend\\Serializer\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"ZendTest\\Serializer\\": "test/"
}
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "2.9.x-dev",
"dev-develop": "2.10.x-dev"
},
"zf": {
"component": "Zend\\Serializer",
"config-provider": "Zend\\Serializer\\ConfigProvider"
}
},
"scripts": {
"check": [
"@cs-check",
"@test"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
abstract class AbstractAdapter implements AdapterInterface
{
/**
* @var AdapterOptions
*/
protected $options = null;
/**
* Constructor
*
* @param array|\Traversable|AdapterOptions $options
*/
public function __construct($options = null)
{
if ($options !== null) {
$this->setOptions($options);
}
}
/**
* Set adapter options
*
* @param array|\Traversable|AdapterOptions $options
* @return AbstractAdapter
*/
public function setOptions($options)
{
if (! $options instanceof AdapterOptions) {
$options = new AdapterOptions($options);
}
$this->options = $options;
return $this;
}
/**
* Get adapter options
*
* @return AdapterOptions
*/
public function getOptions()
{
if ($this->options === null) {
$this->options = new AdapterOptions();
}
return $this->options;
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
interface AdapterInterface
{
/**
* Generates a storable representation of a value.
*
* @param mixed $value Data to serialize
* @return string
* @throws \Zend\Serializer\Exception\ExceptionInterface
*/
public function serialize($value);
/**
* Creates a PHP value from a stored representation.
*
* @param string $serialized Serialized string
* @return mixed
* @throws \Zend\Serializer\Exception\ExceptionInterface
*/
public function unserialize($serialized);
}

View File

@@ -0,0 +1,16 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
use Zend\Stdlib\AbstractOptions;
class AdapterOptions extends AbstractOptions
{
}

View File

@@ -0,0 +1,85 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
use Zend\Serializer\Exception;
use Zend\Stdlib\ErrorHandler;
class IgBinary extends AbstractAdapter
{
/**
* @var string Serialized null value
*/
private static $serializedNull = null;
/**
* Constructor
*
* @throws Exception\ExtensionNotLoadedException If igbinary extension is not present
*/
public function __construct($options = null)
{
if (! extension_loaded('igbinary')) {
throw new Exception\ExtensionNotLoadedException(
'PHP extension "igbinary" is required for this adapter'
);
}
if (static::$serializedNull === null) {
static::$serializedNull = igbinary_serialize(null);
}
parent::__construct($options);
}
/**
* Serialize PHP value to igbinary
*
* @param mixed $value
* @return string
* @throws Exception\RuntimeException on igbinary error
*/
public function serialize($value)
{
ErrorHandler::start();
$ret = igbinary_serialize($value);
$err = ErrorHandler::stop();
if ($ret === false) {
throw new Exception\RuntimeException('Serialization failed', 0, $err);
}
return $ret;
}
/**
* Deserialize igbinary string to PHP value
*
* @param string $serialized
* @return mixed
* @throws Exception\RuntimeException on igbinary error
*/
public function unserialize($serialized)
{
if ($serialized === static::$serializedNull) {
return;
}
ErrorHandler::start();
$ret = igbinary_unserialize($serialized);
$err = ErrorHandler::stop();
if ($ret === null) {
throw new Exception\RuntimeException('Unserialization failed', 0, $err);
}
return $ret;
}
}

View File

@@ -0,0 +1,98 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
use Zend\Json\Json as ZendJson;
use Zend\Serializer\Exception;
class Json extends AbstractAdapter
{
/**
* @var JsonOptions
*/
protected $options = null;
/**
* Set options
*
* @param array|\Traversable|JsonOptions $options
* @return Json
*/
public function setOptions($options)
{
if (! $options instanceof JsonOptions) {
$options = new JsonOptions($options);
}
$this->options = $options;
return $this;
}
/**
* Get options
*
* @return JsonOptions
*/
public function getOptions()
{
if ($this->options === null) {
$this->options = new JsonOptions();
}
return $this->options;
}
/**
* Serialize PHP value to JSON
*
* @param mixed $value
* @return string
* @throws Exception\InvalidArgumentException
* @throws Exception\RuntimeException
*/
public function serialize($value)
{
$options = $this->getOptions();
$cycleCheck = $options->getCycleCheck();
$opts = [
'enableJsonExprFinder' => $options->getEnableJsonExprFinder(),
'objectDecodeType' => $options->getObjectDecodeType(),
];
try {
return ZendJson::encode($value, $cycleCheck, $opts);
} catch (\InvalidArgumentException $e) {
throw new Exception\InvalidArgumentException('Serialization failed: ' . $e->getMessage(), 0, $e);
} catch (\Exception $e) {
throw new Exception\RuntimeException('Serialization failed: ' . $e->getMessage(), 0, $e);
}
}
/**
* Deserialize JSON to PHP value
*
* @param string $json
* @return mixed
* @throws Exception\InvalidArgumentException
* @throws Exception\RuntimeException
*/
public function unserialize($json)
{
try {
$ret = ZendJson::decode($json, $this->getOptions()->getObjectDecodeType());
} catch (\InvalidArgumentException $e) {
throw new Exception\InvalidArgumentException('Unserialization failed: ' . $e->getMessage(), 0, $e);
} catch (\Exception $e) {
throw new Exception\RuntimeException('Unserialization failed: ' . $e->getMessage(), 0, $e);
}
return $ret;
}
}

View File

@@ -0,0 +1,87 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
use Zend\Json\Json as ZendJson;
use Zend\Serializer\Exception;
class JsonOptions extends AdapterOptions
{
/** @var bool */
protected $cycleCheck = false;
/** @var bool */
protected $enableJsonExprFinder = false;
/** @var int */
protected $objectDecodeType = ZendJson::TYPE_ARRAY;
/**
* @param bool $flag
* @return JsonOptions
*/
public function setCycleCheck($flag)
{
$this->cycleCheck = (bool) $flag;
return $this;
}
/**
* @return bool
*/
public function getCycleCheck()
{
return $this->cycleCheck;
}
/**
* @param bool $flag
* @return JsonOptions
*/
public function setEnableJsonExprFinder($flag)
{
$this->enableJsonExprFinder = (bool) $flag;
return $this;
}
/**
* @return bool
*/
public function getEnableJsonExprFinder()
{
return $this->enableJsonExprFinder;
}
/**
* @param int $type
* @return JsonOptions
* @throws Exception\InvalidArgumentException
*/
public function setObjectDecodeType($type)
{
if ($type != ZendJson::TYPE_ARRAY && $type != ZendJson::TYPE_OBJECT) {
throw new Exception\InvalidArgumentException(
'Unknown decode type: ' . $type
);
}
$this->objectDecodeType = (int) $type;
return $this;
}
/**
* @return int
*/
public function getObjectDecodeType()
{
return $this->objectDecodeType;
}
}

View File

@@ -0,0 +1,85 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
use Zend\Serializer\Exception;
use Zend\Stdlib\ErrorHandler;
class MsgPack extends AbstractAdapter
{
/**
* @var string Serialized 0 value
*/
private static $serialized0 = null;
/**
* Constructor
*
* @throws Exception\ExtensionNotLoadedException If msgpack extension is not present
*/
public function __construct($options = null)
{
if (! extension_loaded('msgpack')) {
throw new Exception\ExtensionNotLoadedException(
'PHP extension "msgpack" is required for this adapter'
);
}
if (static::$serialized0 === null) {
static::$serialized0 = msgpack_serialize(0);
}
parent::__construct($options);
}
/**
* Serialize PHP value to msgpack
*
* @param mixed $value
* @return string
* @throws Exception\RuntimeException on msgpack error
*/
public function serialize($value)
{
ErrorHandler::start();
$ret = msgpack_serialize($value);
$err = ErrorHandler::stop();
if ($ret === false) {
throw new Exception\RuntimeException('Serialization failed', 0, $err);
}
return $ret;
}
/**
* Deserialize msgpack string to PHP value
*
* @param string $serialized
* @return mixed
* @throws Exception\RuntimeException on msgpack error
*/
public function unserialize($serialized)
{
if ($serialized === static::$serialized0) {
return 0;
}
ErrorHandler::start();
$ret = msgpack_unserialize($serialized);
$err = ErrorHandler::stop();
if ($ret === 0) {
throw new Exception\RuntimeException('Unserialization failed', 0, $err);
}
return $ret;
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
use Zend\Serializer\Exception;
use Zend\Stdlib\ErrorHandler;
class PhpCode extends AbstractAdapter
{
/**
* Serialize PHP using var_export
*
* @param mixed $value
* @return string
*/
public function serialize($value)
{
return var_export($value, true);
}
/**
* Deserialize PHP string
*
* Warning: this uses eval(), and should likely be avoided.
*
* @param string $code
* @return mixed
* @throws Exception\RuntimeException on eval error
*/
public function unserialize($code)
{
ErrorHandler::start(E_ALL);
$ret = null;
// This suppression is due to the fact that the ErrorHandler cannot
// catch syntax errors, and is intentionally left in place.
$eval = @eval('$ret=' . $code . ';');
$err = ErrorHandler::stop();
if ($eval === false || $err) {
$msg = 'eval failed';
// Error handler doesn't catch syntax errors
if ($eval === false) {
$lastErr = error_get_last();
$msg .= ': ' . $lastErr['message'];
}
throw new Exception\RuntimeException($msg, 0, $err);
}
return $ret;
}
}

View File

@@ -0,0 +1,137 @@
<?php
/**
* @see https://github.com/zendframework/zend-serializer for the canonical source repository
* @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-serializer/blob/master/LICENSE.md New BSD License
*/
namespace Zend\Serializer\Adapter;
use Traversable;
use Zend\Serializer\Exception;
use Zend\Stdlib\ErrorHandler;
class PhpSerialize extends AbstractAdapter
{
/**
* Serialized boolean false value
*
* @var null|string
*/
private static $serializedFalse = null;
/**
* @var PhpSerializeOptions
*/
protected $options;
/**
* Constructor
*
* @param array|Traversable|PhpSerializeOptions|null $options
*/
public function __construct($options = null)
{
// needed to check if a returned false is based on a serialize false
// or based on failure (igbinary can overwrite [un]serialize functions)
if (static::$serializedFalse === null) {
static::$serializedFalse = serialize(false);
}
parent::__construct($options);
}
/**
* Set options
*
* @param array|Traversable|PhpSerializeOptions $options
* @return PhpSerialize
*/
public function setOptions($options)
{
if (! $options instanceof PhpSerializeOptions) {
$options = new PhpSerializeOptions($options);
}
$this->options = $options;
return $this;
}
/**
* Get options
*
* @return PhpSerializeOptions
*/
public function getOptions()
{
if ($this->options === null) {
$this->options = new PhpSerializeOptions();
}
return $this->options;
}
/**
* Serialize using serialize()
*
* @param mixed $value
* @return string
* @throws Exception\RuntimeException On serialize error
*/
public function serialize($value)
{
ErrorHandler::start();
$ret = serialize($value);
$err = ErrorHandler::stop();
if ($err) {
throw new Exception\RuntimeException('Serialization failed', 0, $err);
}
return $ret;
}
/**
* Unserialize
*
* @todo Allow integration with unserialize_callback_func
* @param string $serialized
* @return mixed
* @throws Exception\RuntimeException on unserialize error
*/
public function unserialize($serialized)
{
if (! is_string($serialized) || ! preg_match('/^((s|i|d|b|a|O|C):|N;)/', $serialized)) {
$value = $serialized;
if (is_object($value)) {
$value = get_class($value);
} elseif (! is_string($value)) {
$value = gettype($value);
}
throw new Exception\RuntimeException(sprintf(
'Serialized data must be a string containing serialized PHP code; received: %s',
$value
));
}
// If we have a serialized boolean false value, just return false;
// prevents the unserialize handler from creating an error.
if ($serialized === static::$serializedFalse) {
return false;
}
ErrorHandler::start(E_NOTICE);
// The second parameter to unserialize() is only available on PHP 7.0 or higher
$ret = PHP_MAJOR_VERSION >= 7
? unserialize($serialized, ['allowed_classes' => $this->getOptions()->getUnserializeClassWhitelist()])
: unserialize($serialized);
$err = ErrorHandler::stop();
if ($ret === false) {
throw new Exception\RuntimeException('Unserialization failed', 0, $err);
}
return $ret;
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* @see https://github.com/zendframework/zend-serializer for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-serializer/blob/master/LICENSE.md New BSD License
*/
namespace Zend\Serializer\Adapter;
use Zend\Json\Json as ZendJson;
use Zend\Serializer\Exception;
class PhpSerializeOptions extends AdapterOptions
{
/**
* The list of allowed classes for unserialization (PHP 7.0+).
*
* Possible values:
*
* - `array` of class names that are allowed to be unserialized
* - `true` if all classes should be allowed (behavior pre-PHP 7.0)
* - `false` if no classes should be allowed
*
* @var string[]|bool
*/
protected $unserializeClassWhitelist = true;
/**
* @param string[]|bool $unserializeClassWhitelist
* @return void
*/
public function setUnserializeClassWhitelist($unserializeClassWhitelist)
{
if ($unserializeClassWhitelist !== true && PHP_MAJOR_VERSION < 7) {
throw new Exception\InvalidArgumentException(
'Class whitelist for unserialize() is only available on PHP versions 7.0 or higher.'
);
}
$this->unserializeClassWhitelist = $unserializeClassWhitelist;
}
/**
* @return string[]|bool
*/
public function getUnserializeClassWhitelist()
{
return $this->unserializeClassWhitelist;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
use Zend\Serializer\Exception;
class PythonPickleOptions extends AdapterOptions
{
/**
* Pickle protocol version to serialize data
*
* @var int
*/
protected $protocol = 0;
/**
* Set pickle protocol version to serialize data
*
* Supported versions are 0, 1, 2 and 3
*
* @param int $protocol
* @return PythonPickleOptions
* @throws Exception\InvalidArgumentException
*/
public function setProtocol($protocol)
{
$protocol = (int) $protocol;
if ($protocol < 0 || $protocol > 3) {
throw new Exception\InvalidArgumentException(
"Invalid or unknown protocol version '{$protocol}'"
);
}
$this->protocol = $protocol;
return $this;
}
/**
* Get pickle protocol version to serialize data
*
* @return int
*/
public function getProtocol()
{
return $this->protocol;
}
}

View File

@@ -0,0 +1,138 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
use Zend\Serializer\Exception;
use Zend\Stdlib\ErrorHandler;
/**
* @link http://www.infoloom.com/gcaconfs/WEB/chicago98/simeonov.HTM
* @link http://en.wikipedia.org/wiki/WDDX
*/
class Wddx extends AbstractAdapter
{
/**
* @var WddxOptions
*/
protected $options = null;
/**
* Constructor
*
* @param array|\Traversable|WddxOptions $options
* @throws Exception\ExtensionNotLoadedException if wddx extension not found
*/
public function __construct($options = null)
{
if (! extension_loaded('wddx')) {
throw new Exception\ExtensionNotLoadedException(
'PHP extension "wddx" is required for this adapter'
);
}
parent::__construct($options);
}
/**
* Set options
*
* @param array|\Traversable|WddxOptions $options
* @return Wddx
*/
public function setOptions($options)
{
if (! $options instanceof WddxOptions) {
$options = new WddxOptions($options);
}
$this->options = $options;
return $this;
}
/**
* Get options
*
* @return WddxOptions
*/
public function getOptions()
{
if ($this->options === null) {
$this->options = new WddxOptions();
}
return $this->options;
}
/**
* Serialize PHP to WDDX
*
* @param mixed $value
* @return string
* @throws Exception\RuntimeException on wddx error
*/
public function serialize($value)
{
$comment = $this->getOptions()->getComment();
ErrorHandler::start();
if ($comment !== '') {
$wddx = wddx_serialize_value($value, $comment);
} else {
$wddx = wddx_serialize_value($value);
}
$error = ErrorHandler::stop();
if ($wddx === false) {
throw new Exception\RuntimeException('Serialization failed', 0, $error);
}
return $wddx;
}
/**
* Unserialize from WDDX to PHP
*
* @param string $wddx
* @return mixed
* @throws Exception\RuntimeException on wddx error
* @throws Exception\InvalidArgumentException if invalid xml
*/
public function unserialize($wddx)
{
$ret = wddx_deserialize($wddx);
if ($ret === null && class_exists('SimpleXMLElement', false)) {
// check if the returned NULL is valid
// or based on an invalid wddx string
try {
$oldLibxmlDisableEntityLoader = libxml_disable_entity_loader(true);
$dom = new \DOMDocument;
$dom->loadXML($wddx);
foreach ($dom->childNodes as $child) {
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
throw new Exception\InvalidArgumentException(
'Invalid XML: Detected use of illegal DOCTYPE'
);
}
}
$simpleXml = simplexml_import_dom($dom);
//$simpleXml = new \SimpleXMLElement($wddx);
libxml_disable_entity_loader($oldLibxmlDisableEntityLoader);
if (isset($simpleXml->data[0]->null[0])) {
return; // valid null
}
throw new Exception\RuntimeException('Unserialization failed: Invalid wddx packet');
} catch (\Exception $e) {
throw new Exception\RuntimeException('Unserialization failed: ' . $e->getMessage(), 0, $e);
}
}
return $ret;
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Adapter;
class WddxOptions extends AdapterOptions
{
/**
* Wddx packet header comment
*
* @var string
*/
protected $comment = '';
/**
* Set WDDX header comment
*
* @param string $comment
* @return WddxOptions
*/
public function setComment($comment)
{
$this->comment = (string) $comment;
return $this;
}
/**
* Get WDDX header comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer;
use Zend\ServiceManager\AbstractPluginManager;
use Zend\ServiceManager\Factory\InvokableFactory;
use Zend\ServiceManager\Exception\InvalidServiceException;
/**
* Plugin manager implementation for serializer adapters.
*
* Enforces that adapters retrieved are instances of
* Adapter\AdapterInterface. Additionally, it registers a number of default
* adapters available.
*/
class AdapterPluginManager extends AbstractPluginManager
{
protected $aliases = [
'igbinary' => Adapter\IgBinary::class,
'igBinary' => Adapter\IgBinary::class,
'IgBinary' => Adapter\IgBinary::class,
'json' => Adapter\Json::class,
'Json' => Adapter\Json::class,
'msgpack' => Adapter\MsgPack::class,
'msgPack' => Adapter\MsgPack::class,
'MsgPack' => Adapter\MsgPack::class,
'phpcode' => Adapter\PhpCode::class,
'phpCode' => Adapter\PhpCode::class,
'PhpCode' => Adapter\PhpCode::class,
'phpserialize' => Adapter\PhpSerialize::class,
'phpSerialize' => Adapter\PhpSerialize::class,
'PhpSerialize' => Adapter\PhpSerialize::class,
'pythonpickle' => Adapter\PythonPickle::class,
'pythonPickle' => Adapter\PythonPickle::class,
'PythonPickle' => Adapter\PythonPickle::class,
'wddx' => Adapter\Wddx::class,
'Wddx' => Adapter\Wddx::class,
];
protected $factories = [
Adapter\IgBinary::class => InvokableFactory::class,
Adapter\Json::class => InvokableFactory::class,
Adapter\MsgPack::class => InvokableFactory::class,
Adapter\PhpCode::class => InvokableFactory::class,
Adapter\PhpSerialize::class => InvokableFactory::class,
Adapter\PythonPickle::class => InvokableFactory::class,
Adapter\Wddx::class => InvokableFactory::class,
// Legacy (v2) due to alias resolution; canonical form of resolved
// alias is used to look up the factory, while the non-normalized
// resolved alias is used as the requested name passed to the factory.
'zendserializeradapterigbinary' => InvokableFactory::class,
'zendserializeradapterjson' => InvokableFactory::class,
'zendserializeradaptermsgpack' => InvokableFactory::class,
'zendserializeradapterphpcode' => InvokableFactory::class,
'zendserializeradapterphpserialize' => InvokableFactory::class,
'zendserializeradapterpythonpickle' => InvokableFactory::class,
'zendserializeradapterwddx' => InvokableFactory::class,
];
protected $instanceOf = Adapter\AdapterInterface::class;
/**
* Validate the plugin is of the expected type (v3).
*
* Validates against `$instanceOf`.
*
* @param mixed $instance
* @throws InvalidServiceException
*/
public function validate($instance)
{
if (! $instance instanceof $this->instanceOf) {
throw new InvalidServiceException(sprintf(
'%s can only create instances of %s; %s is invalid',
get_class($this),
$this->instanceOf,
(is_object($instance) ? get_class($instance) : gettype($instance))
));
}
}
/**
* Validate the plugin is of the expected type (v2).
*
* Proxies to `validate()`.
*
* @param mixed $instance
* @throws Exception\RuntimeException
*/
public function validatePlugin($instance)
{
try {
$this->validate($instance);
} catch (InvalidServiceException $e) {
throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e);
}
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* @link http://github.com/zendframework/zend-serializer for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class AdapterPluginManagerFactory implements FactoryInterface
{
/**
* zend-servicemanager v2 support for invocation options.
*
* @param array
*/
protected $creationOptions;
/**
* {@inheritDoc}
*
* @return AdapterPluginManager
*/
public function __invoke(ContainerInterface $container, $name, array $options = null)
{
return new AdapterPluginManager($container, $options ?: []);
}
/**
* {@inheritDoc}
*
* @return AdapterPluginManager
*/
public function createService(ServiceLocatorInterface $container, $name = null, $requestedName = null)
{
return $this($container, $requestedName ?: AdapterPluginManager::class, $this->creationOptions);
}
/**
* zend-servicemanager v2 support for invocation options.
*
* @param array $options
* @return void
*/
public function setCreationOptions(array $options)
{
$this->creationOptions = $options;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* @link http://github.com/zendframework/zend-serializer for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer;
class ConfigProvider
{
/**
* Return configuration for this component.
*
* @return array
*/
public function __invoke()
{
return [
'dependencies' => $this->getDependencyConfig(),
];
}
/**
* Return dependency mappings for this component.
*
* @return array
*/
public function getDependencyConfig()
{
return [
'factories' => [
'SerializerAdapterManager' => AdapterPluginManagerFactory::class,
],
];
}
}

View File

@@ -0,0 +1,14 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Exception;
interface ExceptionInterface
{
}

View File

@@ -0,0 +1,14 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Exception;
class ExtensionNotLoadedException extends RuntimeException
{
}

View File

@@ -0,0 +1,18 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Exception;
/**
* @used InvalidArgumentException
*/
class InvalidArgumentException extends \InvalidArgumentException implements
ExceptionInterface
{
}

View File

@@ -0,0 +1,17 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer\Exception;
/**
* @used RuntimeException
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* @link http://github.com/zendframework/zend-serializer for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer;
class Module
{
/**
* Return default zend-serializer configuration for zend-mvc applications.
*/
public function getConfig()
{
$provider = new ConfigProvider();
return [
'service_manager' => $provider->getDependencyConfig(),
];
}
/**
* Register a specification for the SerializerAdapterManager with the ServiceListener.
*
* @param \Zend\ModuleManager\ModuleManager $moduleManager
* @return void
*/
public function init($moduleManager)
{
$event = $moduleManager->getEvent();
$container = $event->getParam('ServiceManager');
$serviceListener = $container->get('ServiceListener');
$serviceListener->addServiceManager(
'SerializerAdapterManager',
'serializers',
'Zend\ModuleManager\Feature\SerializerProviderInterface',
'getSerializerConfig'
);
}
}

View File

@@ -0,0 +1,146 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Serializer;
use Zend\Serializer\Adapter\AdapterInterface as Adapter;
use Zend\ServiceManager\ServiceManager;
abstract class Serializer
{
/**
* Plugin manager for loading adapters
*
* @var null|AdapterPluginManager
*/
protected static $adapters;
/**
* The default adapter.
*
* @var string|Adapter
*/
protected static $defaultAdapter = 'PhpSerialize';
/**
* Create a serializer adapter instance.
*
* @param string|Adapter $adapterName Name of the adapter class
* @param array |\Traversable|null $adapterOptions Serializer options
* @return Adapter
*/
public static function factory($adapterName, $adapterOptions = null)
{
if ($adapterName instanceof Adapter) {
return $adapterName; // $adapterName is already an adapter object
}
return static::getAdapterPluginManager()->get($adapterName, $adapterOptions);
}
/**
* Change the adapter plugin manager
*
* @param AdapterPluginManager $adapters
* @return void
*/
public static function setAdapterPluginManager(AdapterPluginManager $adapters)
{
static::$adapters = $adapters;
}
/**
* Get the adapter plugin manager
*
* @return AdapterPluginManager
*/
public static function getAdapterPluginManager()
{
if (static::$adapters === null) {
static::$adapters = new AdapterPluginManager(new ServiceManager);
}
return static::$adapters;
}
/**
* Resets the internal adapter plugin manager
*
* @return AdapterPluginManager
*/
public static function resetAdapterPluginManager()
{
static::$adapters = new AdapterPluginManager(new ServiceManager);
return static::$adapters;
}
/**
* Change the default adapter.
*
* @param string|Adapter $adapter
* @param array|\Traversable|null $adapterOptions
*/
public static function setDefaultAdapter($adapter, $adapterOptions = null)
{
static::$defaultAdapter = static::factory($adapter, $adapterOptions);
}
/**
* Get the default adapter.
*
* @return Adapter
*/
public static function getDefaultAdapter()
{
if (! static::$defaultAdapter instanceof Adapter) {
static::setDefaultAdapter(static::$defaultAdapter);
}
return static::$defaultAdapter;
}
/**
* Generates a storable representation of a value using the default adapter.
* Optionally different adapter could be provided as second argument
*
* @param mixed $value
* @param string|Adapter $adapter
* @param array|\Traversable|null $adapterOptions Adapter constructor options
* only used to create adapter instance
* @return string
*/
public static function serialize($value, $adapter = null, $adapterOptions = null)
{
if ($adapter !== null) {
$adapter = static::factory($adapter, $adapterOptions);
} else {
$adapter = static::getDefaultAdapter();
}
return $adapter->serialize($value);
}
/**
* Creates a PHP value from a stored representation using the default adapter.
* Optionally different adapter could be provided as second argument
*
* @param string $serialized
* @param string|Adapter $adapter
* @param array|\Traversable|null $adapterOptions Adapter constructor options
* only used to create adapter instance
* @return mixed
*/
public static function unserialize($serialized, $adapter = null, $adapterOptions = null)
{
if ($adapter !== null) {
$adapter = static::factory($adapter, $adapterOptions);
} else {
$adapter = static::getDefaultAdapter();
}
return $adapter->unserialize($serialized);
}
}