Add Symfony Deprecation Contracts package
- Created CHANGELOG.md to maintain version history. - Added README.md with usage instructions for the trigger_deprecation() function. - Initialized composer.json for the Symfony Deprecation Contracts library, specifying dependencies and autoloading.
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The RandomLib library for securely generating random numbers and strings in PHP
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
* @copyright 2011 The Authors
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version Build @@version@@
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Mixer strategy interface.
|
||||
*
|
||||
* All mixing strategies must implement this interface
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @category PHPPasswordLib
|
||||
* @package Random
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
* @copyright 2011 The Authors
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @license http://www.gnu.org/licenses/lgpl-2.1.html LGPL v 2.1
|
||||
*/
|
||||
namespace RandomLibtest\Mocks\Random;
|
||||
|
||||
/**
|
||||
* The Mixer strategy interface.
|
||||
*
|
||||
* All mixing strategies must implement this interface
|
||||
*
|
||||
* @category PHPPasswordLib
|
||||
* @package Random
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
*/
|
||||
class Generator extends \RandomLib\Generator
|
||||
{
|
||||
protected $callbacks = array();
|
||||
|
||||
public static function init()
|
||||
{
|
||||
}
|
||||
|
||||
public function __construct(array $callbacks = array())
|
||||
{
|
||||
$this->callbacks = $callbacks;
|
||||
}
|
||||
|
||||
public function __call($name, array $args = array())
|
||||
{
|
||||
if (isset($this->callbacks[$name])) {
|
||||
return call_user_func_array($this->callbacks[$name], $args);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addSource(\PasswordLib\Random\Source $source)
|
||||
{
|
||||
return $this->__call('addSource', array($source));
|
||||
}
|
||||
|
||||
public function generate($size)
|
||||
{
|
||||
return $this->__call('generate', array($size));
|
||||
}
|
||||
|
||||
public function generateInt($min = 0, $max = \PHP_INT_MAX)
|
||||
{
|
||||
return $this->__call('generateInt', array($min, $max));
|
||||
}
|
||||
|
||||
public function generateString($length, $chars = '')
|
||||
{
|
||||
return $this->__call('generateString', array($length, $chars));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The RandomLib library for securely generating random numbers and strings in PHP
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
* @copyright 2011 The Authors
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version Build @@version@@
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Mixer strategy interface.
|
||||
*
|
||||
* All mixing strategies must implement this interface
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @category PHPPasswordLib
|
||||
* @package Random
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
* @copyright 2011 The Authors
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @license http://www.gnu.org/licenses/lgpl-2.1.html LGPL v 2.1
|
||||
*/
|
||||
namespace RandomLibtest\Mocks\Random;
|
||||
|
||||
use SecurityLib\Strength;
|
||||
|
||||
/**
|
||||
* The Mixer strategy interface.
|
||||
*
|
||||
* All mixing strategies must implement this interface
|
||||
*
|
||||
* @category PHPPasswordLib
|
||||
* @package Random
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
*/
|
||||
class Mixer extends \RandomLibTest\Mocks\AbstractMock implements \RandomLib\Mixer
|
||||
{
|
||||
public static $strength = null;
|
||||
|
||||
public static $test = true;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
static::$strength = new Strength(Strength::HIGH);
|
||||
static::$test = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of Strength indicating the strength of the mixer
|
||||
*
|
||||
* @return \SecurityLib\Strength An instance of one of the strength classes
|
||||
*/
|
||||
public static function getStrength()
|
||||
{
|
||||
return static::$strength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to see if the mixer is available
|
||||
*
|
||||
* @return bool If the mixer is available on the system
|
||||
*/
|
||||
public static function test()
|
||||
{
|
||||
return static::$test;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix the provided array of strings into a single output of the same size
|
||||
*
|
||||
* All elements of the array should be the same size.
|
||||
*
|
||||
* @param array $parts The parts to be mixed
|
||||
*
|
||||
* @return string The mixed result
|
||||
*/
|
||||
public function mix(array $parts)
|
||||
{
|
||||
return $this->__call('mix', array($parts));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The RandomLib library for securely generating random numbers and strings in PHP
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
* @copyright 2011 The Authors
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version Build @@version@@
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Random Number Source interface.
|
||||
*
|
||||
* All random number sources must implement this interface
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @category PHPPasswordLib
|
||||
* @package Random
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
* @copyright 2011 The Authors
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @license http://www.gnu.org/licenses/lgpl-2.1.html LGPL v 2.1
|
||||
*/
|
||||
namespace RandomLibtest\Mocks\Random;
|
||||
|
||||
use SecurityLib\Strength;
|
||||
|
||||
/**
|
||||
* The Random Number Source interface.
|
||||
*
|
||||
* All random number sources must implement this interface
|
||||
*
|
||||
* @category PHPPasswordLib
|
||||
* @package Random
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
|
||||
*/
|
||||
class Source extends \RandomLibTest\Mocks\AbstractMock implements \RandomLib\Source
|
||||
{
|
||||
public static $strength = null;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
static::$strength = new Strength(Strength::VERYLOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of Strength indicating the strength of the source
|
||||
*
|
||||
* @return \SecurityLib\Strength An instance of one of the strength classes
|
||||
*/
|
||||
public static function getStrength()
|
||||
{
|
||||
return static::$strength;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the source is currently available.
|
||||
* Reasons might be because the library is not installed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random string of the specified size
|
||||
*
|
||||
* Note: If the source fails to generate enough data, the result must be
|
||||
* padded to the requested length.
|
||||
*
|
||||
* @param int $size The size of the requested random string
|
||||
*
|
||||
* @return string A string of the requested size
|
||||
*/
|
||||
public function generate($size)
|
||||
{
|
||||
return $this->__call('generate', array($size));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user