1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-11-09 11:42:28 +01:00

Add vendored files

This commit is contained in:
Chaoyi Zha 2015-11-02 23:17:51 -05:00
parent 6b06047a29
commit 4da8aac36e
4172 changed files with 459811 additions and 5 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
/vendor
#/vendor
.env

View File

@ -1,8 +1,8 @@
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"license": "MIT",
"name": "cydrobolt/polr",
"description": "The Polr URL Shortener.",
"keywords": ["url-shortener", "url", "cms"],
"license": "GPLv2+",
"type": "project",
"require": {
"php": ">=5.5.9",

7
vendor/autoload.php vendored Normal file
View File

@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit1022d009db9f708df68c1991f93b734b::getLoader();

1
vendor/bin/phpunit vendored Symbolic link
View File

@ -0,0 +1 @@
../phpunit/phpunit/phpunit

413
vendor/composer/ClassLoader.php vendored Normal file
View File

@ -0,0 +1,413 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0 class loader
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-0 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
if ('\\' == $class[0]) {
$class = substr($class, 1);
}
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative) {
return false;
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if ($file === null && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if ($file === null) {
// Remember that this class does not exist.
return $this->classMap[$class] = false;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
if (0 === strpos($class, $prefix)) {
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

21
vendor/composer/LICENSE vendored Normal file
View File

@ -0,0 +1,21 @@
Copyright (c) 2015 Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

454
vendor/composer/autoload_classmap.php vendored Normal file
View File

@ -0,0 +1,454 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'DatabaseSeeder' => $baseDir . '/database/seeds/DatabaseSeeder.php',
'ExampleTest' => $baseDir . '/tests/ExampleTest.php',
'File_Iterator' => $vendorDir . '/phpunit/php-file-iterator/src/Iterator.php',
'File_Iterator_Facade' => $vendorDir . '/phpunit/php-file-iterator/src/Facade.php',
'File_Iterator_Factory' => $vendorDir . '/phpunit/php-file-iterator/src/Factory.php',
'IlluminateQueueClosure' => $vendorDir . '/illuminate/queue/IlluminateQueueClosure.php',
'Illuminate\\Foundation\\Composer' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Composer.php',
'Illuminate\\Foundation\\Support\\Providers\\EventServiceProvider' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Support/Providers/EventServiceProvider.php',
'Illuminate\\Foundation\\Testing\\DatabaseMigrations' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/DatabaseMigrations.php',
'Illuminate\\Foundation\\Testing\\DatabaseTransactions' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/DatabaseTransactions.php',
'Illuminate\\Foundation\\Testing\\WithoutMiddleware' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/WithoutMiddleware.php',
'PHPUnit_Exception' => $vendorDir . '/phpunit/phpunit/src/Exception.php',
'PHPUnit_Extensions_GroupTestSuite' => $vendorDir . '/phpunit/phpunit/src/Extensions/GroupTestSuite.php',
'PHPUnit_Extensions_PhptTestCase' => $vendorDir . '/phpunit/phpunit/src/Extensions/PhptTestCase.php',
'PHPUnit_Extensions_PhptTestSuite' => $vendorDir . '/phpunit/phpunit/src/Extensions/PhptTestSuite.php',
'PHPUnit_Extensions_RepeatedTest' => $vendorDir . '/phpunit/phpunit/src/Extensions/RepeatedTest.php',
'PHPUnit_Extensions_TestDecorator' => $vendorDir . '/phpunit/phpunit/src/Extensions/TestDecorator.php',
'PHPUnit_Extensions_TicketListener' => $vendorDir . '/phpunit/phpunit/src/Extensions/TicketListener.php',
'PHPUnit_Framework_Assert' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert.php',
'PHPUnit_Framework_AssertionFailedError' => $vendorDir . '/phpunit/phpunit/src/Framework/AssertionFailedError.php',
'PHPUnit_Framework_BaseTestListener' => $vendorDir . '/phpunit/phpunit/src/Framework/BaseTestListener.php',
'PHPUnit_Framework_CodeCoverageException' => $vendorDir . '/phpunit/phpunit/src/Framework/CodeCoverageException.php',
'PHPUnit_Framework_Constraint' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint.php',
'PHPUnit_Framework_Constraint_And' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/And.php',
'PHPUnit_Framework_Constraint_ArrayHasKey' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/ArrayHasKey.php',
'PHPUnit_Framework_Constraint_ArraySubset' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/ArraySubset.php',
'PHPUnit_Framework_Constraint_Attribute' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Attribute.php',
'PHPUnit_Framework_Constraint_Callback' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Callback.php',
'PHPUnit_Framework_Constraint_ClassHasAttribute' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/ClassHasAttribute.php',
'PHPUnit_Framework_Constraint_ClassHasStaticAttribute' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/ClassHasStaticAttribute.php',
'PHPUnit_Framework_Constraint_Composite' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Composite.php',
'PHPUnit_Framework_Constraint_Count' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Count.php',
'PHPUnit_Framework_Constraint_Exception' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Exception.php',
'PHPUnit_Framework_Constraint_ExceptionCode' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/ExceptionCode.php',
'PHPUnit_Framework_Constraint_ExceptionMessage' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/ExceptionMessage.php',
'PHPUnit_Framework_Constraint_ExceptionMessageRegExp' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/ExceptionMessageRegExp.php',
'PHPUnit_Framework_Constraint_FileExists' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/FileExists.php',
'PHPUnit_Framework_Constraint_GreaterThan' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/GreaterThan.php',
'PHPUnit_Framework_Constraint_IsAnything' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsAnything.php',
'PHPUnit_Framework_Constraint_IsEmpty' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsEmpty.php',
'PHPUnit_Framework_Constraint_IsEqual' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsEqual.php',
'PHPUnit_Framework_Constraint_IsFalse' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsFalse.php',
'PHPUnit_Framework_Constraint_IsIdentical' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsIdentical.php',
'PHPUnit_Framework_Constraint_IsInstanceOf' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsInstanceOf.php',
'PHPUnit_Framework_Constraint_IsJson' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsJson.php',
'PHPUnit_Framework_Constraint_IsNull' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsNull.php',
'PHPUnit_Framework_Constraint_IsTrue' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsTrue.php',
'PHPUnit_Framework_Constraint_IsType' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsType.php',
'PHPUnit_Framework_Constraint_JsonMatches' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/JsonMatches.php',
'PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/JsonMatches/ErrorMessageProvider.php',
'PHPUnit_Framework_Constraint_LessThan' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/LessThan.php',
'PHPUnit_Framework_Constraint_Not' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Not.php',
'PHPUnit_Framework_Constraint_ObjectHasAttribute' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/ObjectHasAttribute.php',
'PHPUnit_Framework_Constraint_Or' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Or.php',
'PHPUnit_Framework_Constraint_PCREMatch' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/PCREMatch.php',
'PHPUnit_Framework_Constraint_SameSize' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/SameSize.php',
'PHPUnit_Framework_Constraint_StringContains' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/StringContains.php',
'PHPUnit_Framework_Constraint_StringEndsWith' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/StringEndsWith.php',
'PHPUnit_Framework_Constraint_StringMatches' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/StringMatches.php',
'PHPUnit_Framework_Constraint_StringStartsWith' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/StringStartsWith.php',
'PHPUnit_Framework_Constraint_TraversableContains' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/TraversableContains.php',
'PHPUnit_Framework_Constraint_TraversableContainsOnly' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/TraversableContainsOnly.php',
'PHPUnit_Framework_Constraint_Xor' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Xor.php',
'PHPUnit_Framework_Error' => $vendorDir . '/phpunit/phpunit/src/Framework/Error.php',
'PHPUnit_Framework_Error_Deprecated' => $vendorDir . '/phpunit/phpunit/src/Framework/Error/Deprecated.php',
'PHPUnit_Framework_Error_Notice' => $vendorDir . '/phpunit/phpunit/src/Framework/Error/Notice.php',
'PHPUnit_Framework_Error_Warning' => $vendorDir . '/phpunit/phpunit/src/Framework/Error/Warning.php',
'PHPUnit_Framework_Exception' => $vendorDir . '/phpunit/phpunit/src/Framework/Exception.php',
'PHPUnit_Framework_ExceptionWrapper' => $vendorDir . '/phpunit/phpunit/src/Framework/ExceptionWrapper.php',
'PHPUnit_Framework_ExpectationFailedException' => $vendorDir . '/phpunit/phpunit/src/Framework/ExpectationFailedException.php',
'PHPUnit_Framework_IncompleteTest' => $vendorDir . '/phpunit/phpunit/src/Framework/IncompleteTest.php',
'PHPUnit_Framework_IncompleteTestCase' => $vendorDir . '/phpunit/phpunit/src/Framework/IncompleteTestCase.php',
'PHPUnit_Framework_IncompleteTestError' => $vendorDir . '/phpunit/phpunit/src/Framework/IncompleteTestError.php',
'PHPUnit_Framework_InvalidCoversTargetError' => $vendorDir . '/phpunit/phpunit/src/Framework/InvalidCoversTargetError.php',
'PHPUnit_Framework_InvalidCoversTargetException' => $vendorDir . '/phpunit/phpunit/src/Framework/InvalidCoversTargetException.php',
'PHPUnit_Framework_MockObject_BadMethodCallException' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Exception/BadMethodCallException.php',
'PHPUnit_Framework_MockObject_Builder_Identity' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Identity.php',
'PHPUnit_Framework_MockObject_Builder_InvocationMocker' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/InvocationMocker.php',
'PHPUnit_Framework_MockObject_Builder_Match' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Match.php',
'PHPUnit_Framework_MockObject_Builder_MethodNameMatch' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/MethodNameMatch.php',
'PHPUnit_Framework_MockObject_Builder_Namespace' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Namespace.php',
'PHPUnit_Framework_MockObject_Builder_ParametersMatch' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/ParametersMatch.php',
'PHPUnit_Framework_MockObject_Builder_Stub' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Stub.php',
'PHPUnit_Framework_MockObject_Exception' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Exception/Exception.php',
'PHPUnit_Framework_MockObject_Generator' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php',
'PHPUnit_Framework_MockObject_Invocation' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invocation.php',
'PHPUnit_Framework_MockObject_InvocationMocker' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/InvocationMocker.php',
'PHPUnit_Framework_MockObject_Invocation_Object' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invocation/Object.php',
'PHPUnit_Framework_MockObject_Invocation_Static' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invocation/Static.php',
'PHPUnit_Framework_MockObject_Invokable' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invokable.php',
'PHPUnit_Framework_MockObject_Matcher' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher.php',
'PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/AnyInvokedCount.php',
'PHPUnit_Framework_MockObject_Matcher_AnyParameters' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/AnyParameters.php',
'PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/ConsecutiveParameters.php',
'PHPUnit_Framework_MockObject_Matcher_Invocation' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/Invocation.php',
'PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtIndex.php',
'PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtLeastCount.php',
'PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtLeastOnce.php',
'PHPUnit_Framework_MockObject_Matcher_InvokedAtMostCount' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtMostCount.php',
'PHPUnit_Framework_MockObject_Matcher_InvokedCount' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedCount.php',
'PHPUnit_Framework_MockObject_Matcher_InvokedRecorder' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedRecorder.php',
'PHPUnit_Framework_MockObject_Matcher_MethodName' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/MethodName.php',
'PHPUnit_Framework_MockObject_Matcher_Parameters' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/Parameters.php',
'PHPUnit_Framework_MockObject_Matcher_StatelessInvocation' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/StatelessInvocation.php',
'PHPUnit_Framework_MockObject_MockBuilder' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/MockBuilder.php',
'PHPUnit_Framework_MockObject_MockObject' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/MockObject.php',
'PHPUnit_Framework_MockObject_RuntimeException' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Exception/RuntimeException.php',
'PHPUnit_Framework_MockObject_Stub' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub.php',
'PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ConsecutiveCalls.php',
'PHPUnit_Framework_MockObject_Stub_Exception' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Exception.php',
'PHPUnit_Framework_MockObject_Stub_MatcherCollection' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/MatcherCollection.php',
'PHPUnit_Framework_MockObject_Stub_Return' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Return.php',
'PHPUnit_Framework_MockObject_Stub_ReturnArgument' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnArgument.php',
'PHPUnit_Framework_MockObject_Stub_ReturnCallback' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnCallback.php',
'PHPUnit_Framework_MockObject_Stub_ReturnSelf' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnSelf.php',
'PHPUnit_Framework_MockObject_Stub_ReturnValueMap' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnValueMap.php',
'PHPUnit_Framework_MockObject_Verifiable' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Verifiable.php',
'PHPUnit_Framework_OutputError' => $vendorDir . '/phpunit/phpunit/src/Framework/OutputError.php',
'PHPUnit_Framework_RiskyTest' => $vendorDir . '/phpunit/phpunit/src/Framework/RiskyTest.php',
'PHPUnit_Framework_RiskyTestError' => $vendorDir . '/phpunit/phpunit/src/Framework/RiskyTestError.php',
'PHPUnit_Framework_SelfDescribing' => $vendorDir . '/phpunit/phpunit/src/Framework/SelfDescribing.php',
'PHPUnit_Framework_SkippedTest' => $vendorDir . '/phpunit/phpunit/src/Framework/SkippedTest.php',
'PHPUnit_Framework_SkippedTestCase' => $vendorDir . '/phpunit/phpunit/src/Framework/SkippedTestCase.php',
'PHPUnit_Framework_SkippedTestError' => $vendorDir . '/phpunit/phpunit/src/Framework/SkippedTestError.php',
'PHPUnit_Framework_SkippedTestSuiteError' => $vendorDir . '/phpunit/phpunit/src/Framework/SkippedTestSuiteError.php',
'PHPUnit_Framework_SyntheticError' => $vendorDir . '/phpunit/phpunit/src/Framework/SyntheticError.php',
'PHPUnit_Framework_Test' => $vendorDir . '/phpunit/phpunit/src/Framework/Test.php',
'PHPUnit_Framework_TestCase' => $vendorDir . '/phpunit/phpunit/src/Framework/TestCase.php',
'PHPUnit_Framework_TestFailure' => $vendorDir . '/phpunit/phpunit/src/Framework/TestFailure.php',
'PHPUnit_Framework_TestListener' => $vendorDir . '/phpunit/phpunit/src/Framework/TestListener.php',
'PHPUnit_Framework_TestResult' => $vendorDir . '/phpunit/phpunit/src/Framework/TestResult.php',
'PHPUnit_Framework_TestSuite' => $vendorDir . '/phpunit/phpunit/src/Framework/TestSuite.php',
'PHPUnit_Framework_TestSuite_DataProvider' => $vendorDir . '/phpunit/phpunit/src/Framework/TestSuite/DataProvider.php',
'PHPUnit_Framework_UnintentionallyCoveredCodeError' => $vendorDir . '/phpunit/phpunit/src/Framework/UnintentionallyCoveredCodeError.php',
'PHPUnit_Framework_Warning' => $vendorDir . '/phpunit/phpunit/src/Framework/Warning.php',
'PHPUnit_Runner_BaseTestRunner' => $vendorDir . '/phpunit/phpunit/src/Runner/BaseTestRunner.php',
'PHPUnit_Runner_Exception' => $vendorDir . '/phpunit/phpunit/src/Runner/Exception.php',
'PHPUnit_Runner_Filter_Factory' => $vendorDir . '/phpunit/phpunit/src/Runner/Filter/Factory.php',
'PHPUnit_Runner_Filter_GroupFilterIterator' => $vendorDir . '/phpunit/phpunit/src/Runner/Filter/Group.php',
'PHPUnit_Runner_Filter_Group_Exclude' => $vendorDir . '/phpunit/phpunit/src/Runner/Filter/Group/Exclude.php',
'PHPUnit_Runner_Filter_Group_Include' => $vendorDir . '/phpunit/phpunit/src/Runner/Filter/Group/Include.php',
'PHPUnit_Runner_Filter_Test' => $vendorDir . '/phpunit/phpunit/src/Runner/Filter/Test.php',
'PHPUnit_Runner_StandardTestSuiteLoader' => $vendorDir . '/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php',
'PHPUnit_Runner_TestSuiteLoader' => $vendorDir . '/phpunit/phpunit/src/Runner/TestSuiteLoader.php',
'PHPUnit_Runner_Version' => $vendorDir . '/phpunit/phpunit/src/Runner/Version.php',
'PHPUnit_TextUI_Command' => $vendorDir . '/phpunit/phpunit/src/TextUI/Command.php',
'PHPUnit_TextUI_ResultPrinter' => $vendorDir . '/phpunit/phpunit/src/TextUI/ResultPrinter.php',
'PHPUnit_TextUI_TestRunner' => $vendorDir . '/phpunit/phpunit/src/TextUI/TestRunner.php',
'PHPUnit_Util_Blacklist' => $vendorDir . '/phpunit/phpunit/src/Util/Blacklist.php',
'PHPUnit_Util_Configuration' => $vendorDir . '/phpunit/phpunit/src/Util/Configuration.php',
'PHPUnit_Util_ErrorHandler' => $vendorDir . '/phpunit/phpunit/src/Util/ErrorHandler.php',
'PHPUnit_Util_Fileloader' => $vendorDir . '/phpunit/phpunit/src/Util/Fileloader.php',
'PHPUnit_Util_Filesystem' => $vendorDir . '/phpunit/phpunit/src/Util/Filesystem.php',
'PHPUnit_Util_Filter' => $vendorDir . '/phpunit/phpunit/src/Util/Filter.php',
'PHPUnit_Util_Getopt' => $vendorDir . '/phpunit/phpunit/src/Util/Getopt.php',
'PHPUnit_Util_GlobalState' => $vendorDir . '/phpunit/phpunit/src/Util/GlobalState.php',
'PHPUnit_Util_InvalidArgumentHelper' => $vendorDir . '/phpunit/phpunit/src/Util/InvalidArgumentHelper.php',
'PHPUnit_Util_Log_JSON' => $vendorDir . '/phpunit/phpunit/src/Util/Log/JSON.php',
'PHPUnit_Util_Log_JUnit' => $vendorDir . '/phpunit/phpunit/src/Util/Log/JUnit.php',
'PHPUnit_Util_Log_TAP' => $vendorDir . '/phpunit/phpunit/src/Util/Log/TAP.php',
'PHPUnit_Util_PHP' => $vendorDir . '/phpunit/phpunit/src/Util/PHP.php',
'PHPUnit_Util_PHP_Default' => $vendorDir . '/phpunit/phpunit/src/Util/PHP/Default.php',
'PHPUnit_Util_PHP_Windows' => $vendorDir . '/phpunit/phpunit/src/Util/PHP/Windows.php',
'PHPUnit_Util_Printer' => $vendorDir . '/phpunit/phpunit/src/Util/Printer.php',
'PHPUnit_Util_Regex' => $vendorDir . '/phpunit/phpunit/src/Util/Regex.php',
'PHPUnit_Util_String' => $vendorDir . '/phpunit/phpunit/src/Util/String.php',
'PHPUnit_Util_Test' => $vendorDir . '/phpunit/phpunit/src/Util/Test.php',
'PHPUnit_Util_TestDox_NamePrettifier' => $vendorDir . '/phpunit/phpunit/src/Util/TestDox/NamePrettifier.php',
'PHPUnit_Util_TestDox_ResultPrinter' => $vendorDir . '/phpunit/phpunit/src/Util/TestDox/ResultPrinter.php',
'PHPUnit_Util_TestDox_ResultPrinter_HTML' => $vendorDir . '/phpunit/phpunit/src/Util/TestDox/ResultPrinter/HTML.php',
'PHPUnit_Util_TestDox_ResultPrinter_Text' => $vendorDir . '/phpunit/phpunit/src/Util/TestDox/ResultPrinter/Text.php',
'PHPUnit_Util_TestSuiteIterator' => $vendorDir . '/phpunit/phpunit/src/Util/TestSuiteIterator.php',
'PHPUnit_Util_Type' => $vendorDir . '/phpunit/phpunit/src/Util/Type.php',
'PHPUnit_Util_XML' => $vendorDir . '/phpunit/phpunit/src/Util/XML.php',
'PHP_CodeCoverage' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage.php',
'PHP_CodeCoverage_Driver' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver.php',
'PHP_CodeCoverage_Driver_HHVM' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/HHVM.php',
'PHP_CodeCoverage_Driver_PHPDBG' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/PHPDBG.php',
'PHP_CodeCoverage_Driver_Xdebug' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/Xdebug.php',
'PHP_CodeCoverage_Exception' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception.php',
'PHP_CodeCoverage_Exception_UnintentionallyCoveredCode' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/UnintentionallyCoveredCode.php',
'PHP_CodeCoverage_Filter' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Filter.php',
'PHP_CodeCoverage_Report_Clover' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Clover.php',
'PHP_CodeCoverage_Report_Crap4j' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Crap4j.php',
'PHP_CodeCoverage_Report_Factory' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php',
'PHP_CodeCoverage_Report_HTML' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php',
'PHP_CodeCoverage_Report_HTML_Renderer' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML/Renderer.php',
'PHP_CodeCoverage_Report_HTML_Renderer_Dashboard' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML/Renderer/Dashboard.php',
'PHP_CodeCoverage_Report_HTML_Renderer_Directory' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML/Renderer/Directory.php',
'PHP_CodeCoverage_Report_HTML_Renderer_File' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML/Renderer/File.php',
'PHP_CodeCoverage_Report_Node' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Node.php',
'PHP_CodeCoverage_Report_Node_Directory' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Node/Directory.php',
'PHP_CodeCoverage_Report_Node_File' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Node/File.php',
'PHP_CodeCoverage_Report_Node_Iterator' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Node/Iterator.php',
'PHP_CodeCoverage_Report_PHP' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/PHP.php',
'PHP_CodeCoverage_Report_Text' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Text.php',
'PHP_CodeCoverage_Report_XML' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML.php',
'PHP_CodeCoverage_Report_XML_Directory' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Directory.php',
'PHP_CodeCoverage_Report_XML_File' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/File.php',
'PHP_CodeCoverage_Report_XML_File_Coverage' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/File/Coverage.php',
'PHP_CodeCoverage_Report_XML_File_Method' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/File/Method.php',
'PHP_CodeCoverage_Report_XML_File_Report' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/File/Report.php',
'PHP_CodeCoverage_Report_XML_File_Unit' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/File/Unit.php',
'PHP_CodeCoverage_Report_XML_Node' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Node.php',
'PHP_CodeCoverage_Report_XML_Project' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Project.php',
'PHP_CodeCoverage_Report_XML_Tests' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Tests.php',
'PHP_CodeCoverage_Report_XML_Totals' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Totals.php',
'PHP_CodeCoverage_Util' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Util.php',
'PHP_CodeCoverage_Util_InvalidArgumentHelper' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Util/InvalidArgumentHelper.php',
'PHP_Timer' => $vendorDir . '/phpunit/php-timer/src/Timer.php',
'PHP_Token' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_TokenWithScope' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_TokenWithScopeAndVisibility' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ABSTRACT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_AMPERSAND' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_AND_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ARRAY' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ARRAY_CAST' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_AS' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ASYNC' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_AT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_AWAIT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_BACKTICK' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_BAD_CHARACTER' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_BOOLEAN_AND' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_BOOLEAN_OR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_BOOL_CAST' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_BREAK' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CALLABLE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CARET' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CASE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CATCH' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CHARACTER' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CLASS' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CLASS_C' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CLASS_NAME_CONSTANT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CLONE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CLOSE_BRACKET' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CLOSE_CURLY' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CLOSE_SQUARE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CLOSE_TAG' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_COALESCE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_COLON' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_COMMA' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_COMMENT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_COMPILER_HALT_OFFSET' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CONCAT_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CONST' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CONSTANT_ENCAPSED_STRING' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CONTINUE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_CURLY_OPEN' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DEC' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DECLARE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DEFAULT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DIR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DIV' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DIV_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DNUMBER' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DO' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DOC_COMMENT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DOLLAR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DOLLAR_OPEN_CURLY_BRACES' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DOT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DOUBLE_ARROW' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DOUBLE_CAST' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DOUBLE_COLON' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_DOUBLE_QUOTES' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ECHO' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ELLIPSIS' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ELSE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ELSEIF' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_EMPTY' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ENCAPSED_AND_WHITESPACE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ENDDECLARE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ENDFOR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ENDFOREACH' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ENDIF' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ENDSWITCH' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ENDWHILE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_END_HEREDOC' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ENUM' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_EQUALS' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_EVAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_EXCLAMATION_MARK' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_EXIT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_EXTENDS' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_FILE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_FINAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_FINALLY' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_FOR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_FOREACH' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_FUNCTION' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_FUNC_C' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_GLOBAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_GOTO' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_GT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_HALT_COMPILER' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_IF' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_IMPLEMENTS' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_IN' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_INC' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_INCLUDE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_INCLUDE_ONCE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_INLINE_HTML' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_INSTANCEOF' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_INSTEADOF' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_INTERFACE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_INT_CAST' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ISSET' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_IS_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_IS_GREATER_OR_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_IS_IDENTICAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_IS_NOT_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_IS_NOT_IDENTICAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_IS_SMALLER_OR_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_Includes' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_JOIN' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_LAMBDA_ARROW' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_LAMBDA_CP' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_LAMBDA_OP' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_LINE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_LIST' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_LNUMBER' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_LOGICAL_AND' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_LOGICAL_OR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_LOGICAL_XOR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_LT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_METHOD_C' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_MINUS' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_MINUS_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_MOD_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_MULT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_MUL_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_NAMESPACE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_NEW' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_NS_C' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_NS_SEPARATOR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_NUM_STRING' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_OBJECT_CAST' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_OBJECT_OPERATOR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_ONUMBER' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_OPEN_BRACKET' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_OPEN_CURLY' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_OPEN_SQUARE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_OPEN_TAG' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_OPEN_TAG_WITH_ECHO' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_OR_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_PAAMAYIM_NEKUDOTAYIM' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_PERCENT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_PIPE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_PLUS' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_PLUS_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_POW' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_POW_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_PRINT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_PRIVATE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_PROTECTED' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_PUBLIC' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_QUESTION_MARK' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_REQUIRE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_REQUIRE_ONCE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_RETURN' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_SEMICOLON' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_SHAPE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_SL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_SL_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_SPACESHIP' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_SR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_SR_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_START_HEREDOC' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_STATIC' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_STRING' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_STRING_CAST' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_STRING_VARNAME' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_SWITCH' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_Stream' => $vendorDir . '/phpunit/php-token-stream/src/Token/Stream.php',
'PHP_Token_Stream_CachingFactory' => $vendorDir . '/phpunit/php-token-stream/src/Token/Stream/CachingFactory.php',
'PHP_Token_THROW' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_TILDE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_TRAIT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_TRAIT_C' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_TRY' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_TYPE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_TYPELIST_GT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_TYPELIST_LT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_UNSET' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_UNSET_CAST' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_USE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_VAR' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_VARIABLE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_WHERE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_WHILE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_WHITESPACE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_XHP_ATTRIBUTE' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_XHP_CATEGORY' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_XHP_CATEGORY_LABEL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_XHP_CHILDREN' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_XHP_LABEL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_XHP_REQUIRED' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_XHP_TAG_GT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_XHP_TAG_LT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_XHP_TEXT' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_XOR_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_YIELD' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_YIELD_FROM' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'SebastianBergmann\\Comparator\\ArrayComparator' => $vendorDir . '/sebastian/comparator/src/ArrayComparator.php',
'SebastianBergmann\\Comparator\\Comparator' => $vendorDir . '/sebastian/comparator/src/Comparator.php',
'SebastianBergmann\\Comparator\\ComparisonFailure' => $vendorDir . '/sebastian/comparator/src/ComparisonFailure.php',
'SebastianBergmann\\Comparator\\DOMNodeComparator' => $vendorDir . '/sebastian/comparator/src/DOMNodeComparator.php',
'SebastianBergmann\\Comparator\\DateTimeComparator' => $vendorDir . '/sebastian/comparator/src/DateTimeComparator.php',
'SebastianBergmann\\Comparator\\DoubleComparator' => $vendorDir . '/sebastian/comparator/src/DoubleComparator.php',
'SebastianBergmann\\Comparator\\ExceptionComparator' => $vendorDir . '/sebastian/comparator/src/ExceptionComparator.php',
'SebastianBergmann\\Comparator\\Factory' => $vendorDir . '/sebastian/comparator/src/Factory.php',
'SebastianBergmann\\Comparator\\MockObjectComparator' => $vendorDir . '/sebastian/comparator/src/MockObjectComparator.php',
'SebastianBergmann\\Comparator\\NumericComparator' => $vendorDir . '/sebastian/comparator/src/NumericComparator.php',
'SebastianBergmann\\Comparator\\ObjectComparator' => $vendorDir . '/sebastian/comparator/src/ObjectComparator.php',
'SebastianBergmann\\Comparator\\ResourceComparator' => $vendorDir . '/sebastian/comparator/src/ResourceComparator.php',
'SebastianBergmann\\Comparator\\ScalarComparator' => $vendorDir . '/sebastian/comparator/src/ScalarComparator.php',
'SebastianBergmann\\Comparator\\SplObjectStorageComparator' => $vendorDir . '/sebastian/comparator/src/SplObjectStorageComparator.php',
'SebastianBergmann\\Comparator\\TypeComparator' => $vendorDir . '/sebastian/comparator/src/TypeComparator.php',
'SebastianBergmann\\Diff\\Chunk' => $vendorDir . '/sebastian/diff/src/Chunk.php',
'SebastianBergmann\\Diff\\Diff' => $vendorDir . '/sebastian/diff/src/Diff.php',
'SebastianBergmann\\Diff\\Differ' => $vendorDir . '/sebastian/diff/src/Differ.php',
'SebastianBergmann\\Diff\\LCS\\LongestCommonSubsequence' => $vendorDir . '/sebastian/diff/src/LCS/LongestCommonSubsequence.php',
'SebastianBergmann\\Diff\\LCS\\MemoryEfficientImplementation' => $vendorDir . '/sebastian/diff/src/LCS/MemoryEfficientLongestCommonSubsequenceImplementation.php',
'SebastianBergmann\\Diff\\LCS\\TimeEfficientImplementation' => $vendorDir . '/sebastian/diff/src/LCS/TimeEfficientLongestCommonSubsequenceImplementation.php',
'SebastianBergmann\\Diff\\Line' => $vendorDir . '/sebastian/diff/src/Line.php',
'SebastianBergmann\\Diff\\Parser' => $vendorDir . '/sebastian/diff/src/Parser.php',
'SebastianBergmann\\Environment\\Console' => $vendorDir . '/sebastian/environment/src/Console.php',
'SebastianBergmann\\Environment\\Runtime' => $vendorDir . '/sebastian/environment/src/Runtime.php',
'SebastianBergmann\\Exporter\\Exporter' => $vendorDir . '/sebastian/exporter/src/Exporter.php',
'SebastianBergmann\\GlobalState\\Blacklist' => $vendorDir . '/sebastian/global-state/src/Blacklist.php',
'SebastianBergmann\\GlobalState\\CodeExporter' => $vendorDir . '/sebastian/global-state/src/CodeExporter.php',
'SebastianBergmann\\GlobalState\\Exception' => $vendorDir . '/sebastian/global-state/src/Exception.php',
'SebastianBergmann\\GlobalState\\Restorer' => $vendorDir . '/sebastian/global-state/src/Restorer.php',
'SebastianBergmann\\GlobalState\\RuntimeException' => $vendorDir . '/sebastian/global-state/src/RuntimeException.php',
'SebastianBergmann\\GlobalState\\Snapshot' => $vendorDir . '/sebastian/global-state/src/Snapshot.php',
'SebastianBergmann\\RecursionContext\\Context' => $vendorDir . '/sebastian/recursion-context/src/Context.php',
'SebastianBergmann\\RecursionContext\\Exception' => $vendorDir . '/sebastian/recursion-context/src/Exception.php',
'SebastianBergmann\\RecursionContext\\InvalidArgumentException' => $vendorDir . '/sebastian/recursion-context/src/InvalidArgumentException.php',
'SebastianBergmann\\Version' => $vendorDir . '/sebastian/version/src/Version.php',
'SessionHandlerInterface' => $vendorDir . '/symfony/http-foundation/Resources/stubs/SessionHandlerInterface.php',
'TestCase' => $baseDir . '/tests/TestCase.php',
'Text_Template' => $vendorDir . '/phpunit/php-text-template/src/Template.php',
);

15
vendor/composer/autoload_files.php vendored Normal file
View File

@ -0,0 +1,15 @@
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
$vendorDir . '/danielstjules/stringy/src/Create.php',
$vendorDir . '/illuminate/support/helpers.php',
$vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
$vendorDir . '/paragonie/random_compat/lib/random.php',
$vendorDir . '/nikic/fast-route/src/functions.php',
$vendorDir . '/laravel/lumen-framework/src/helpers.php',
);

17
vendor/composer/autoload_namespaces.php vendored Normal file
View File

@ -0,0 +1,17 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'phpDocumentor' => array($vendorDir . '/phpdocumentor/reflection-docblock/src'),
'Twig_' => array($vendorDir . '/twig/twig/lib'),
'Psr\\Log\\' => array($vendorDir . '/psr/log'),
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'),
'Dotenv' => array($vendorDir . '/vlucas/phpdotenv/src'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
'Cron' => array($vendorDir . '/mtdowling/cron-expression/src'),
'Carbon' => array($vendorDir . '/nesbot/carbon/src'),
);

53
vendor/composer/autoload_psr4.php vendored Normal file
View File

@ -0,0 +1,53 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'TwigBridge\\Tests\\' => array($vendorDir . '/rcrowe/twigbridge/tests'),
'TwigBridge\\' => array($vendorDir . '/rcrowe/twigbridge/src'),
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
'Symfony\\Component\\VarDumper\\' => array($vendorDir . '/symfony/var-dumper'),
'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'),
'Symfony\\Component\\Security\\Core\\' => array($vendorDir . '/symfony/security-core'),
'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/http-kernel'),
'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'),
'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
'Symfony\\Component\\DomCrawler\\' => array($vendorDir . '/symfony/dom-crawler'),
'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
'Stringy\\' => array($vendorDir . '/danielstjules/stringy/src'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'Laravel\\Lumen\\' => array($vendorDir . '/laravel/lumen-framework/src'),
'Illuminate\\View\\' => array($vendorDir . '/illuminate/view'),
'Illuminate\\Validation\\' => array($vendorDir . '/illuminate/validation'),
'Illuminate\\Translation\\' => array($vendorDir . '/illuminate/translation'),
'Illuminate\\Support\\' => array($vendorDir . '/illuminate/support'),
'Illuminate\\Session\\' => array($vendorDir . '/illuminate/session'),
'Illuminate\\Queue\\' => array($vendorDir . '/illuminate/queue'),
'Illuminate\\Pipeline\\' => array($vendorDir . '/illuminate/pipeline'),
'Illuminate\\Pagination\\' => array($vendorDir . '/illuminate/pagination'),
'Illuminate\\Http\\' => array($vendorDir . '/illuminate/http'),
'Illuminate\\Hashing\\' => array($vendorDir . '/illuminate/hashing'),
'Illuminate\\Filesystem\\' => array($vendorDir . '/illuminate/filesystem'),
'Illuminate\\Events\\' => array($vendorDir . '/illuminate/events'),
'Illuminate\\Encryption\\' => array($vendorDir . '/illuminate/encryption'),
'Illuminate\\Database\\' => array($vendorDir . '/illuminate/database'),
'Illuminate\\Cookie\\' => array($vendorDir . '/illuminate/cookie'),
'Illuminate\\Contracts\\' => array($vendorDir . '/illuminate/contracts'),
'Illuminate\\Container\\' => array($vendorDir . '/illuminate/container'),
'Illuminate\\Console\\' => array($vendorDir . '/illuminate/console'),
'Illuminate\\Config\\' => array($vendorDir . '/illuminate/config'),
'Illuminate\\Cache\\' => array($vendorDir . '/illuminate/cache'),
'Illuminate\\Bus\\' => array($vendorDir . '/illuminate/bus'),
'Illuminate\\Broadcasting\\' => array($vendorDir . '/illuminate/broadcasting'),
'Illuminate\\Auth\\' => array($vendorDir . '/illuminate/auth'),
'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'),
'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
'App\\' => array($baseDir . '/app'),
);

55
vendor/composer/autoload_real.php vendored Normal file
View File

@ -0,0 +1,55 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit1022d009db9f708df68c1991f93b734b
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit1022d009db9f708df68c1991f93b734b', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit1022d009db9f708df68c1991f93b734b', 'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
$loader->register(true);
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
composerRequire1022d009db9f708df68c1991f93b734b($file);
}
return $loader;
}
}
function composerRequire1022d009db9f708df68c1991f93b734b($file)
{
require $file;
}

3530
vendor/composer/installed.json vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
vendor/
composer.lock
.DS_Store

View File

@ -0,0 +1,7 @@
language: php
php:
- 5.6
- 5.5
- 5.4
- 5.3
- hhvm

View File

@ -0,0 +1,119 @@
### 1.10.0 (2015-07-22)
* Added trimLeft, trimRight
* Added support for unicode whitespace to trim
* Added delimit
* Added indexOf and indexOfLast
* Added htmlEncode and htmlDecode
* Added "Ç" in toAscii()
### 1.9.0 (2015-02-09)
* Added hasUpperCase and hasLowerCase
* Added $removeUnsupported parameter to toAscii()
* Improved toAscii support with additional Unicode spaces, Vietnamese chars,
and numerous other characters
* Separated the charsArray from toAscii as a protected method that may be
extended by inheriting classes
* Chars array is cached for better performance
### 1.8.1 (2015-01-08)
* Optimized chars()
* Added "ä Ä Ö Ü"" in toAscii()
* Added support for Unicode spaces in toAscii()
* Replaced instances of self::create() with static::create()
* Added missing test cases for safeTruncate() and longestCommonSuffix()
* Updated Stringy\create() to avoid collision when it already exists
### 1.8.0 (2015-01-03)
* Listed ext-mbstring in composer.json
* Added Stringy\create function for PHP 5.6
### 1.7.0 (2014-10-14)
* Added containsAll and containsAny
* Light cleanup
### 1.6.0 (2014-09-14)
* Added toTitleCase
### 1.5.2 (2014-07-09)
* Announced support for HHVM
### 1.5.1 (2014-04-19)
* Fixed toAscii() failing to remove remaining non-ascii characters
* Updated slugify() to treat dash and underscore as delimiters by default
* Updated slugify() to remove leading and trailing delimiter, if present
### 1.5.0 (2014-03-19)
* Made both str and encoding protected, giving property access to subclasses
* Added getEncoding()
* Fixed isJSON() giving false negatives
* Cleaned up and simplified: replace(), collapseWhitespace(), underscored(),
dasherize(), pad(), padLeft(), padRight() and padBoth()
* Fixed handling consecutive invalid chars in slugify()
* Removed conflicting hard sign transliteration in toAscii()
### 1.4.0 (2014-02-12)
* Implemented the IteratorAggregate interface, added chars()
* Renamed count() to countSubstr()
* Updated count() to implement Countable interface
* Implemented the ArrayAccess interface with positive and negative indices
* Switched from PSR-0 to PSR-4 autoloading
### 1.3.0 (2013-12-16)
* Additional Bulgarian support for toAscii
* str property made private
* Constructor casts first argument to string
* Constructor throws an InvalidArgumentException when given an array
* Constructor throws an InvalidArgumentException when given an object without
a __toString method
### 1.2.2 (2013-12-04)
* Updated create function to use late static binding
* Added optional $replacement param to slugify
### 1.2.1 (2013-10-11)
* Cleaned up tests
* Added homepage to composer.json
### 1.2.0 (2013-09-15)
* Fixed pad's use of InvalidArgumentException
* Fixed replace(). It now correctly treats regex special chars as normal chars
* Added additional Cyrillic letters to toAscii
* Added $caseSensitive to contains() and count()
* Added toLowerCase()
* Added toUpperCase()
* Added regexReplace()
### 1.1.0 (2013-08-31)
* Fix for collapseWhitespace()
* Added isHexadecimal()
* Added constructor to Stringy\Stringy
* Added isSerialized()
* Added isJson()
### 1.0.0 (2013-08-1)
* 1.0.0 release
* Added test coverage for Stringy::create and method chaining
* Added tests for returned type
* Fixed StaticStringy::replace(). It was returning a Stringy object instead of string
* Renamed standardize() to the more appropriate toAscii()
* Cleaned up comments and README
### 1.0.0-rc.1 (2013-07-28)
* Release candidate

View File

@ -0,0 +1,19 @@
Copyright (C) 2013 Daniel St. Jules
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

1190
vendor/danielstjules/stringy/README.md vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
{
"name": "danielstjules/stringy",
"description": "A string manipulation library with multibyte support",
"keywords": [
"multibyte", "string", "manipulation", "utility", "methods", "utf-8",
"helpers", "utils", "utf"
],
"homepage": "https://github.com/danielstjules/Stringy",
"license": "MIT",
"authors": [
{
"name": "Daniel St. Jules",
"email": "danielst.jules@gmail.com",
"homepage": "http://www.danielstjules.com"
}
],
"require": {
"php": ">=5.3.0",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"support": {
"issues": "https://github.com/danielstjules/Stringy/issues",
"source": "https://github.com/danielstjules/Stringy"
},
"autoload": {
"psr-4": { "Stringy\\": "src/" },
"files": ["src/Create.php"]
},
"autoload-dev": {
"classmap": [ "tests" ]
}
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Stringy">
<file>tests/CommonTest.php</file>
<file>tests/StringyTest.php</file>
<file>tests/StaticStringyTest.php</file>
<file phpVersion="5.6.0">tests/CreateTest.php</file>
</testsuite>
</testsuites>
</phpunit>

View File

@ -0,0 +1,19 @@
<?php
namespace Stringy;
if (!function_exists('Stringy\create')) {
/**
* Creates a Stringy object and returns it on success.
*
* @param mixed $str Value to modify, after being cast to string
* @param string $encoding The character encoding
* @return Stringy A Stringy object
* @throws \InvalidArgumentException if an array or object without a
* __toString method is passed as the first argument
*/
function create($str, $encoding = null)
{
return new Stringy($str, $encoding);
}
}

View File

@ -0,0 +1,979 @@
<?php
namespace Stringy;
class StaticStringy
{
/**
* Returns an array consisting of the characters in the string.
*
* @param string $str String for which to return the chars
* @param string $encoding The character encoding
* @return array An array of string chars
*/
public static function chars($str, $encoding = null)
{
return Stringy::create($str, $encoding)->chars();
}
/**
* Converts the first character of the supplied string to upper case.
*
* @param string $str String to modify
* @param string $encoding The character encoding
* @return string String with the first character being upper case
*/
public static function upperCaseFirst($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->upperCaseFirst();
}
/**
* Converts the first character of the supplied string to lower case.
*
* @param string $str String to modify
* @param string $encoding The character encoding
* @return string String with the first character being lower case
*/
public static function lowerCaseFirst($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->lowerCaseFirst();
}
/**
* Returns a camelCase version of the string. Trims surrounding spaces,
* capitalizes letters following digits, spaces, dashes and underscores,
* and removes spaces, dashes, as well as underscores.
*
* @param string $str String to convert to camelCase
* @param string $encoding The character encoding
* @return string String in camelCase
*/
public static function camelize($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->camelize();
}
/**
* Returns an UpperCamelCase version of the supplied string. It trims
* surrounding spaces, capitalizes letters following digits, spaces, dashes
* and underscores, and removes spaces, dashes, underscores.
*
* @param string $str String to convert to UpperCamelCase
* @param string $encoding The character encoding
* @return string String in UpperCamelCase
*/
public static function upperCamelize($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->upperCamelize();
}
/**
* Returns a lowercase and trimmed string separated by dashes. Dashes are
* inserted before uppercase characters (with the exception of the first
* character of the string), and in place of spaces as well as underscores.
*
* @param string $str String to convert
* @param string $encoding The character encoding
* @return string Dasherized string
*/
public static function dasherize($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->dasherize();
}
/**
* Returns a lowercase and trimmed string separated by underscores.
* Underscores are inserted before uppercase characters (with the exception
* of the first character of the string), and in place of spaces as well as
* dashes.
*
* @param string $str String to convert
* @param string $encoding The character encoding
* @return string Underscored string
*/
public static function underscored($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->underscored();
}
/**
* Returns a lowercase and trimmed string separated by the given delimiter.
* Delimiters are inserted before uppercase characters (with the exception
* of the first character of the string), and in place of spaces, dashes,
* and underscores. Alpha delimiters are not converted to lowercase.
*
* @param string $str String to convert
* @param string $delimiter Sequence used to separate parts of the string
* @param string $encoding The character encoding
* @return string String with delimiter
*/
public static function delimit($str, $delimiter, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->delimit($delimiter);
}
/**
* Returns a case swapped version of the string.
*
* @param string $str String to swap case
* @param string $encoding The character encoding
* @return string String with each character's case swapped
*/
public static function swapCase($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->swapCase();
}
/**
* Returns a trimmed string with the first letter of each word capitalized.
* Ignores the case of other letters, preserving any acronyms. Also accepts
* an array, $ignore, allowing you to list words not to be capitalized.
*
* @param string $str String to titleize
* @param string $encoding The character encoding
* @param array $ignore An array of words not to capitalize
* @return string Titleized string
*/
public static function titleize($str, $ignore = null, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->titleize($ignore);
}
/**
* Capitalizes the first word of the string, replaces underscores with
* spaces, and strips '_id'.
*
* @param string $str String to humanize
* @param string $encoding The character encoding
* @return string A humanized string
*/
public static function humanize($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->humanize();
}
/**
* Returns a string with smart quotes, ellipsis characters, and dashes from
* Windows-1252 (commonly used in Word documents) replaced by their ASCII
* equivalents.
*
* @param string $str String to remove special chars
* @return string String with those characters removed
*/
public static function tidy($str)
{
return (string) Stringy::create($str)->tidy();
}
/**
* Trims the string and replaces consecutive whitespace characters with a
* single space. This includes tabs and newline characters, as well as
* multibyte whitespace such as the thin space and ideographic space.
*
* @param string $str The string to cleanup whitespace
* @param string $encoding The character encoding
* @return string The trimmed string with condensed whitespace
*/
public static function collapseWhitespace($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->collapseWhitespace();
}
/**
* Returns an ASCII version of the string. A set of non-ASCII characters are
* replaced with their closest ASCII counterparts, and the rest are removed
* unless instructed otherwise.
*
* @param string $str A string with non-ASCII characters
* @param bool $removeUnsupported Whether or not to remove the
* unsupported characters
* @return string A string containing only ASCII characters
*/
public static function toAscii($str, $removeUnsupported = true)
{
return (string) Stringy::create($str)->toAscii($removeUnsupported);
}
/**
* Pads the string to a given length with $padStr. If length is less than
* or equal to the length of the string, no padding takes places. The
* default string used for padding is a space, and the default type (one of
* 'left', 'right', 'both') is 'right'. Throws an InvalidArgumentException
* if $padType isn't one of those 3 values.
*
* @param string $str String to pad
* @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space
* @param string $padType One of 'left', 'right', 'both'
* @param string $encoding The character encoding
* @return string The padded string
* @throws \InvalidArgumentException If $padType isn't one of 'right',
* 'left' or 'both'
*/
public static function pad($str, $length, $padStr = ' ', $padType = 'right',
$encoding = null)
{
return (string) Stringy::create($str, $encoding)
->pad($length, $padStr, $padType);
}
/**
* Returns a new string of a given length such that the beginning of the
* string is padded. Alias for pad() with a $padType of 'left'.
*
* @param string $str String to pad
* @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space
* @param string $encoding The character encoding
* @return string The padded string
*/
public static function padLeft($str, $length, $padStr = ' ', $encoding = null)
{
return (string) Stringy::create($str, $encoding)
->padLeft($length, $padStr);
}
/**
* Returns a new string of a given length such that the end of the string
* is padded. Alias for pad() with a $padType of 'right'.
*
* @param string $str String to pad
* @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space
* @param string $encoding The character encoding
* @return string The padded string
*/
public static function padRight($str, $length, $padStr = ' ', $encoding = null)
{
return (string) Stringy::create($str, $encoding)
->padRight($length, $padStr);
}
/**
* Returns a new string of a given length such that both sides of the
* string are padded. Alias for pad() with a $padType of 'both'.
*
* @param string $str String to pad
* @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space
* @param string $encoding The character encoding
* @return string The padded string
*/
public static function padBoth($str, $length, $padStr = ' ', $encoding = null)
{
return (string) Stringy::create($str, $encoding)
->padBoth($length, $padStr);
}
/**
* Returns true if the string begins with $substring, false otherwise. By
* default, the comparison is case-sensitive, but can be made insensitive
* by setting $caseSensitive to false.
*
* @param string $str String to check the start of
* @param string $substring The substring to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @param string $encoding The character encoding
* @return bool Whether or not $str starts with $substring
*/
public static function startsWith($str, $substring, $caseSensitive = true,
$encoding = null)
{
return Stringy::create($str, $encoding)
->startsWith($substring, $caseSensitive);
}
/**
* Returns true if the string ends with $substring, false otherwise. By
* default, the comparison is case-sensitive, but can be made insensitive
* by setting $caseSensitive to false.
*
* @param string $str String to check the end of
* @param string $substring The substring to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @param string $encoding The character encoding
* @return bool Whether or not $str ends with $substring
*/
public static function endsWith($str, $substring, $caseSensitive = true,
$encoding = null)
{
return Stringy::create($str, $encoding)
->endsWith($substring, $caseSensitive);
}
/**
* Converts each tab in the string to some number of spaces, as defined by
* $tabLength. By default, each tab is converted to 4 consecutive spaces.
*
* @param string $str String to convert tabs to spaces
* @param int $tabLength Number of spaces to replace each tab with
* @return string String with tabs switched to spaces
*/
public static function toSpaces($str, $tabLength = 4)
{
return (string) Stringy::create($str)->toSpaces($tabLength);
}
/**
* Converts each occurrence of some consecutive number of spaces, as
* defined by $tabLength, to a tab. By default, each 4 consecutive spaces
* are converted to a tab.
*
* @param string $str String to convert spaces to tabs
* @param int $tabLength Number of spaces to replace with a tab
* @return string String with spaces switched to tabs
*/
public static function toTabs($str, $tabLength = 4)
{
return (string) Stringy::create($str)->toTabs($tabLength);
}
/**
* Converts all characters in the string to lowercase. An alias for PHP's
* mb_strtolower().
*
* @param string $str String to convert case
* @param string $encoding The character encoding
* @return string The lowercase string
*/
public static function toLowerCase($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->toLowerCase();
}
/**
* Converts the first character of each word in the string to uppercase.
*
* @param string $str String to convert case
* @param string $encoding The character encoding
* @return string The title-cased string
*/
public static function toTitleCase($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->toTitleCase();
}
/**
* Converts all characters in the string to uppercase. An alias for PHP's
* mb_strtoupper().
*
* @param string $str String to convert case
* @param string $encoding The character encoding
* @return string The uppercase string
*/
public static function toUpperCase($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->toUpperCase();
}
/**
* Converts the string into an URL slug. This includes replacing non-ASCII
* characters with their closest ASCII equivalents, removing remaining
* non-ASCII and non-alphanumeric characters, and replacing whitespace with
* $replacement. The replacement defaults to a single dash, and the string
* is also converted to lowercase.
*
* @param string $str Text to transform into an URL slug
* @param string $replacement The string used to replace whitespace
* @return string The corresponding URL slug
*/
public static function slugify($str, $replacement = '-')
{
return (string) Stringy::create($str)->slugify($replacement);
}
/**
* Returns true if the string contains $needle, false otherwise. By default,
* the comparison is case-sensitive, but can be made insensitive by setting
* $caseSensitive to false.
*
* @param string $haystack String being checked
* @param string $needle Substring to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @param string $encoding The character encoding
* @return bool Whether or not $haystack contains $needle
*/
public static function contains($haystack, $needle, $caseSensitive = true,
$encoding = null)
{
return Stringy::create($haystack, $encoding)
->contains($needle, $caseSensitive);
}
/**
* Returns true if the string contains any $needles, false otherwise. By
* default, the comparison is case-sensitive, but can be made insensitive
* by setting $caseSensitive to false.
*
* @param string $haystack String being checked
* @param array $needles Substrings to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @param string $encoding The character encoding
* @return bool Whether or not $haystack contains any $needles
*/
public static function containsAny($haystack, $needles,
$caseSensitive = true, $encoding = null)
{
return Stringy::create($haystack, $encoding)
->containsAny($needles, $caseSensitive);
}
/**
* Returns true if the string contains all $needles, false otherwise. By
* default, the comparison is case-sensitive, but can be made insensitive
* by setting $caseSensitive to false.
*
* @param string $haystack String being checked
* @param array $needles Substrings to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @param string $encoding The character encoding
* @return bool Whether or not $haystack contains all $needles
*/
public static function containsAll($haystack, $needles,
$caseSensitive = true, $encoding = null)
{
return Stringy::create($haystack, $encoding)
->containsAll($needles, $caseSensitive);
}
/**
* Returns the index of the first occurrence of $needle in the string,
* and false if not found. Accepts an optional offset from which to begin
* the search.
*
* @param string $haystack String to search
* @param string $needle Substring to look for
* @param int $offset Offset from which to search
* @return int|bool The occurrence's index if found, otherwise false
*/
public static function indexOf($haystack, $needle, $offset = 0,
$encoding = null)
{
return Stringy::create($haystack, $encoding)
->indexOf($needle, $offset);
}
/**
* Returns the index of the last occurrence of $needle in the string,
* and false if not found. Accepts an optional offset from which to begin
* the search.
*
* @param string $haystack String to search
* @param string $needle Substring to look for
* @param int $offset Offset from which to search
* @return int|bool The last occurrence's index if found, otherwise false
*/
public static function indexOfLast($haystack, $needle, $offset = 0,
$encoding = null)
{
return Stringy::create($haystack, $encoding)
->indexOfLast($needle, $offset);
}
/**
* Surrounds a string with the given substring.
*
* @param string $str The string to surround
* @param string $substring The substring to add to both sides
* @return string The string with the substring prepended and appended
*/
public static function surround($str, $substring)
{
return (string) Stringy::create($str)->surround($substring);
}
/**
* Inserts $substring into the string at the $index provided.
*
* @param string $str String to insert into
* @param string $substring String to be inserted
* @param int $index The index at which to insert the substring
* @param string $encoding The character encoding
* @return string The resulting string after the insertion
*/
public static function insert($str, $substring, $index, $encoding = null)
{
return (string) Stringy::create($str, $encoding)
->insert($substring, $index);
}
/**
* Truncates the string to a given length. If $substring is provided, and
* truncating occurs, the string is further truncated so that the substring
* may be appended without exceeding the desired length.
*
* @param string $str String to truncate
* @param int $length Desired length of the truncated string
* @param string $substring The substring to append if it can fit
* @param string $encoding The character encoding
* @return string The resulting string after truncating
*/
public static function truncate($str, $length, $substring = '',
$encoding = null)
{
return (string) Stringy::create($str, $encoding)
->truncate($length, $substring);
}
/**
* Truncates the string to a given length, while ensuring that it does not
* split words. If $substring is provided, and truncating occurs, the
* string is further truncated so that the substring may be appended without
* exceeding the desired length.
*
* @param string $str String to truncate
* @param int $length Desired length of the truncated string
* @param string $substring The substring to append if it can fit
* @param string $encoding The character encoding
* @return string The resulting string after truncating
*/
public static function safeTruncate($str, $length, $substring = '',
$encoding = null)
{
return (string) Stringy::create($str, $encoding)
->safeTruncate($length, $substring);
}
/**
* Returns a reversed string. A multibyte version of strrev().
*
* @param string $str String to reverse
* @param string $encoding The character encoding
* @return string The reversed string
*/
public static function reverse($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->reverse();
}
/**
* A multibyte str_shuffle() function. It returns a string with its
* characters in random order.
*
* @param string $str String to shuffle
* @param string $encoding The character encoding
* @return string The shuffled string
*/
public static function shuffle($str, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->shuffle();
}
/**
* Returns a string with whitespace removed from the start and end of the
* string. Supports the removal of unicode whitespace. Accepts an optional
* string of characters to strip instead of the defaults.
*
* @param string $str String to trim
* @param string $chars Optional string of characters to strip
* @param string $encoding The character encoding
* @return string Trimmed $str
*/
public static function trim($str, $chars = null, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->trim($chars);
}
/**
* Returns a string with whitespace removed from the start of the string.
* Supports the removal of unicode whitespace. Accepts an optional
* string of characters to strip instead of the defaults.
*
* @param string $str String to trim
* @param string $chars Optional string of characters to strip
* @param string $encoding The character encoding
* @return string Trimmed $str
*/
public static function trimLeft($str, $chars = null, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->trimLeft($chars);
}
/**
* Returns a string with whitespace removed from the end of the string.
* Supports the removal of unicode whitespace. Accepts an optional
* string of characters to strip instead of the defaults.
*
* @param string $str String to trim
* @param string $chars Optional string of characters to strip
* @param string $encoding The character encoding
* @return string Trimmed $str
*/
public static function trimRight($str, $chars = null, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->trimRight($chars);
}
/**
* Returns the longest common prefix between the string and $otherStr.
*
* @param string $str First string for comparison
* @param string $otherStr Second string for comparison
* @param string $encoding The character encoding
* @return string The longest common prefix
*/
public static function longestCommonPrefix($str, $otherStr, $encoding = null)
{
return (string) Stringy::create($str, $encoding)
->longestCommonPrefix($otherStr);
}
/**
* Returns the longest common suffix between the string and $otherStr.
*
* @param string $str First string for comparison
* @param string $otherStr Second string for comparison
* @param string $encoding The character encoding
* @return string The longest common suffix
*/
public static function longestCommonSuffix($str, $otherStr, $encoding = null)
{
return (string) Stringy::create($str, $encoding)
->longestCommonSuffix($otherStr);
}
/**
* Returns the longest common substring between the string and $otherStr.
* In the case of ties, it returns that which occurs first.
*
* @param string $str First string for comparison
* @param string $otherStr Second string for comparison
* @param string $encoding The character encoding
* @return string The longest common substring
*/
public static function longestCommonSubstring($str, $otherStr,
$encoding = null)
{
return (string) Stringy::create($str, $encoding)
->longestCommonSubstring($otherStr);
}
/**
* Returns the length of the string. An alias for PHP's mb_strlen() function.
*
* @param string $str The string to get the length of
* @param string $encoding The character encoding
* @return int The number of characters in $str given the encoding
*/
public static function length($str, $encoding = null)
{
return Stringy::create($str, $encoding)->length();
}
/**
* Returns the substring beginning at $start with the specified $length.
* It differs from the mb_substr() function in that providing a $length of
* null will return the rest of the string, rather than an empty string.
*
* @param string $str The string to get the length of
* @param int $start Position of the first character to use
* @param int $length Maximum number of characters used
* @param string $encoding The character encoding
* @return string The substring of $str
*/
public static function substr($str, $start, $length = null, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->substr($start, $length);
}
/**
* Returns the character at $index, with indexes starting at 0.
*
* @param string $str The string from which to get the char
* @param int $index Position of the character
* @param string $encoding The character encoding
* @return string The character at $index
*/
public static function at($str, $index, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->at($index);
}
/**
* Returns the first $n characters of the string.
*
* @param string $str The string from which to get the substring
* @param int $n Number of chars to retrieve from the start
* @param string $encoding The character encoding
* @return string The first $n characters
*/
public static function first($str, $n, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->first($n);
}
/**
* Returns the last $n characters of the string.
*
* @param string $str The string from which to get the substring
* @param int $n Number of chars to retrieve from the end
* @param string $encoding The character encoding
* @return string The last $n characters
*/
public static function last($str, $n, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->last($n);
}
/**
* Ensures that the string begins with $substring. If it doesn't, it's
* prepended.
*
* @param string $str The string to modify
* @param string $substring The substring to add if not present
* @param string $encoding The character encoding
* @return string The string prefixed by the $substring
*/
public static function ensureLeft($str, $substring, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->ensureLeft($substring);
}
/**
* Ensures that the string begins with $substring. If it doesn't, it's
* appended.
*
* @param string $str The string to modify
* @param string $substring The substring to add if not present
* @param string $encoding The character encoding
* @return string The string suffixed by the $substring
*/
public static function ensureRight($str, $substring, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->ensureRight($substring);
}
/**
* Returns a new string with the prefix $substring removed, if present.
*
* @param string $str String from which to remove the prefix
* @param string $substring The prefix to remove
* @param string $encoding The character encoding
* @return string The string without the prefix $substring
*/
public static function removeLeft($str, $substring, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->removeLeft($substring);
}
/**
* Returns a new string with the suffix $substring removed, if present.
*
* @param string $str String from which to remove the suffix
* @param string $substring The suffix to remove
* @param string $encoding The character encoding
* @return string The string without the suffix $substring
*/
public static function removeRight($str, $substring, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->removeRight($substring);
}
/**
* Returns true if the string contains a lower case char, false
* otherwise.
*
* @param string $str String to check
* @param string $encoding The character encoding
* @return bool Whether or not $str contains a lower case character.
*/
public static function hasLowerCase($str, $encoding = null)
{
return Stringy::create($str, $encoding)->hasLowerCase();
}
/**
* Returns true if the string contains an upper case char, false
* otherwise.
*
* @param string $str String to check
* @param string $encoding The character encoding
* @return bool Whether or not $str contains an upper case character.
*/
public static function hasUpperCase($str, $encoding = null)
{
return Stringy::create($str, $encoding)->hasUpperCase();
}
/**
* Returns true if the string contains only alphabetic chars, false
* otherwise.
*
* @param string $str String to check
* @param string $encoding The character encoding
* @return bool Whether or not $str contains only alphabetic chars
*/
public static function isAlpha($str, $encoding = null)
{
return Stringy::create($str, $encoding)->isAlpha();
}
/**
* Returns true if the string contains only alphabetic and numeric chars,
* false otherwise.
*
* @param string $str String to check
* @param string $encoding The character encoding
* @return bool Whether or not $str contains only alphanumeric chars
*/
public static function isAlphanumeric($str, $encoding = null)
{
return Stringy::create($str, $encoding)->isAlphanumeric();
}
/**
* Returns true if the string contains only whitespace chars, false
* otherwise.
*
* @param string $str String to check
* @param string $encoding The character encoding
* @return bool Whether or not $str contains only whitespace characters
*/
public static function isBlank($str, $encoding = null)
{
return Stringy::create($str, $encoding)->isBlank();
}
/**
* Returns true if the string is JSON, false otherwise.
*
* @param string $str String to check
* @param string $encoding The character encoding
* @return bool Whether or not $str is JSON
*/
public static function isJson($str, $encoding = null)
{
return Stringy::create($str, $encoding)->isJson();
}
/**
* Returns true if the string contains only lower case chars, false
* otherwise.
*
* @param string $str String to check
* @param string $encoding The character encoding
* @return bool Whether or not $str contains only lower case characters
*/
public static function isLowerCase($str, $encoding = null)
{
return Stringy::create($str, $encoding)->isLowerCase();
}
/**
* Returns true if the string is serialized, false otherwise.
*
* @param string $str String to check
* @param string $encoding The character encoding
* @return bool Whether or not $str is serialized
*/
public static function isSerialized($str, $encoding = null)
{
return Stringy::create($str, $encoding)->isSerialized();
}
/**
* Returns true if the string contains only upper case chars, false
* otherwise.
*
* @param string $str String to check
* @param string $encoding The character encoding
* @return bool Whether or not $str contains only upper case characters
*/
public static function isUpperCase($str, $encoding = null)
{
return Stringy::create($str, $encoding)->isUpperCase();
}
/**
* Returns true if the string contains only hexadecimal chars, false
* otherwise.
*
* @param string $str String to check
* @param string $encoding The character encoding
* @return bool Whether or not $str contains only hexadecimal characters
*/
public static function isHexadecimal($str, $encoding = null)
{
return Stringy::create($str, $encoding)->isHexadecimal();
}
/**
* Returns the number of occurrences of $substring in the given string.
* By default, the comparison is case-sensitive, but can be made insensitive
* by setting $caseSensitive to false.
*
* @param string $str The string to search through
* @param string $substring The substring to search for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @param string $encoding The character encoding
* @return int The number of $substring occurrences
*/
public static function countSubstr($str, $substring, $caseSensitive = true,
$encoding = null)
{
return Stringy::create($str, $encoding)
->countSubstr($substring, $caseSensitive);
}
/**
* Replaces all occurrences of $search in $str by $replacement.
*
* @param string $str The haystack to search through
* @param string $search The needle to search for
* @param string $replacement The string to replace with
* @param string $encoding The character encoding
* @return string The resulting string after the replacements
*/
public static function replace($str, $search, $replacement, $encoding = null)
{
return (string) Stringy::create($str, $encoding)
->replace($search, $replacement);
}
/**
* Replaces all occurrences of $pattern in $str by $replacement. An alias
* for mb_ereg_replace(). Note that the 'i' option with multibyte patterns
* in mb_ereg_replace() requires PHP 5.4+. This is due to a lack of support
* in the bundled version of Oniguruma in PHP 5.3.
*
* @param string $str The haystack to search through
* @param string $pattern The regular expression pattern
* @param string $replacement The string to replace with
* @param string $options Matching conditions to be used
* @param string $encoding The character encoding
* @return string The resulting string after the replacements
*/
public static function regexReplace($str, $pattern, $replacement,
$options = 'msr', $encoding = null)
{
return (string) Stringy::create($str, $encoding)
->regexReplace($pattern, $replacement, $options, $encoding);
}
/**
* Convert all applicable characters to HTML entities.
*
* @param string $str The string to encode.
* @param int|null $flags See http://php.net/manual/en/function.htmlentities.php
* @param string $encoding The character encoding
* @return Stringy Object with the resulting $str after being html encoded.
*/
public static function htmlEncode($str, $flags = ENT_COMPAT, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->htmlEncode($flags);
}
/**
* Convert all HTML entities to their applicable characters.
*
* @param string $str The string to decode.
* @param int|null $flags See http://php.net/manual/en/function.html-entity-decode.php
* @param string $encoding The character encoding
* @return Stringy Object with the resulting $str after being html decoded.
*/
public static function htmlDecode($str, $flags = ENT_COMPAT, $encoding = null)
{
return (string) Stringy::create($str, $encoding)->htmlDecode($flags);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
<?php
require __DIR__ . '/../src/Create.php';
use function Stringy\create as s;
class CreateTestCase extends PHPUnit_Framework_TestCase
{
public function testCreate()
{
$stringy = s('foo bar', 'UTF-8');
$this->assertInstanceOf('Stringy\Stringy', $stringy);
$this->assertEquals('foo bar', (string) $stringy);
$this->assertEquals('UTF-8', $stringy->getEncoding());
}
}

View File

@ -0,0 +1,710 @@
<?php
require __DIR__ . '/../src/StaticStringy.php';
use Stringy\StaticStringy as S;
class StaticStringyTestCase extends CommonTest
{
/**
* @dataProvider indexOfProvider()
*/
public function testIndexOf($expected, $str, $subStr, $offset = 0, $encoding = null)
{
$result = S::indexOf($str, $subStr, $offset, $encoding);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider indexOfLastProvider()
*/
public function testIndexOfLast($expected, $str, $subStr, $offset = 0, $encoding = null)
{
$result = S::indexOfLast($str, $subStr, $offset, $encoding);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider charsProvider()
*/
public function testChars($expected, $str, $encoding = null)
{
$result = S::chars($str, $encoding);
$this->assertInternalType('array', $result);
foreach ($result as $char) {
$this->assertInternalType('string', $char);
}
$this->assertEquals($expected, $result);
}
/**
* @dataProvider upperCaseFirstProvider()
*/
public function testUpperCaseFirst($expected, $str, $encoding = null)
{
$result = S::upperCaseFirst($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider lowerCaseFirstProvider()
*/
public function testLowerCaseFirst($expected, $str, $encoding = null)
{
$result = S::lowerCaseFirst($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider camelizeProvider()
*/
public function testCamelize($expected, $str, $encoding = null)
{
$result = S::camelize($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider upperCamelizeProvider()
*/
public function testUpperCamelize($expected, $str, $encoding = null)
{
$result = S::upperCamelize($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider dasherizeProvider()
*/
public function testDasherize($expected, $str, $encoding = null)
{
$result = S::dasherize($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider underscoredProvider()
*/
public function testUnderscored($expected, $str, $encoding = null)
{
$result = S::underscored($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider swapCaseProvider()
*/
public function testSwapCase($expected, $str, $encoding = null)
{
$result = S::swapCase($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider titleizeProvider()
*/
public function testTitleize($expected, $str, $ignore = null,
$encoding = null)
{
$result = S::titleize($str, $ignore, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider humanizeProvider()
*/
public function testHumanize($expected, $str, $encoding = null)
{
$result = S::humanize($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider tidyProvider()
*/
public function testTidy($expected, $str)
{
$result = S::tidy($str);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider collapseWhitespaceProvider()
*/
public function testCollapseWhitespace($expected, $str, $encoding = null)
{
$result = S::collapseWhitespace($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider toAsciiProvider()
*/
public function testToAscii($expected, $str, $removeUnsupported = true)
{
$result = S::toAscii($str, $removeUnsupported);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider padProvider()
*/
public function testPad($expected, $str, $length, $padStr = ' ',
$padType = 'right', $encoding = null)
{
$result = S::pad($str, $length, $padStr, $padType, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testPadException()
{
$result = S::pad('string', 5, 'foo', 'bar');
}
/**
* @dataProvider padLeftProvider()
*/
public function testPadLeft($expected, $str, $length, $padStr = ' ',
$encoding = null)
{
$result = S::padLeft($str, $length, $padStr, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider padRightProvider()
*/
public function testPadRight($expected, $str, $length, $padStr = ' ',
$encoding = null)
{
$result = S::padRight($str, $length, $padStr, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider padBothProvider()
*/
public function testPadBoth($expected, $str, $length, $padStr = ' ',
$encoding = null)
{
$result = S::padBoth($str, $length, $padStr, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider startsWithProvider()
*/
public function testStartsWith($expected, $str, $substring,
$caseSensitive = true, $encoding = null)
{
$result = S::startsWith($str, $substring, $caseSensitive, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider endsWithProvider()
*/
public function testEndsWith($expected, $str, $substring,
$caseSensitive = true, $encoding = null)
{
$result = S::endsWith($str, $substring, $caseSensitive, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider toSpacesProvider()
*/
public function testToSpaces($expected, $str, $tabLength = 4)
{
$result = S::toSpaces($str, $tabLength);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider toTabsProvider()
*/
public function testToTabs($expected, $str, $tabLength = 4)
{
$result = S::toTabs($str, $tabLength);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider toLowerCaseProvider()
*/
public function testToLowerCase($expected, $str, $encoding = null)
{
$result = S::toLowerCase($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider toTitleCaseProvider()
*/
public function testToTitleCase($expected, $str, $encoding = null)
{
$result = S::toTitleCase($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider toUpperCaseProvider()
*/
public function testToUpperCase($expected, $str, $encoding = null)
{
$result = S::toUpperCase($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider slugifyProvider()
*/
public function testSlugify($expected, $str, $replacement = '-')
{
$result = S::slugify($str, $replacement);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider containsProvider()
*/
public function testContains($expected, $haystack, $needle,
$caseSensitive = true, $encoding = null)
{
$result = S::contains($haystack, $needle, $caseSensitive, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider containsAnyProvider()
*/
public function testcontainsAny($expected, $haystack, $needles,
$caseSensitive = true, $encoding = null)
{
$result = S::containsAny($haystack, $needles, $caseSensitive, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider containsAllProvider()
*/
public function testContainsAll($expected, $haystack, $needles,
$caseSensitive = true, $encoding = null)
{
$result = S::containsAll($haystack, $needles, $caseSensitive, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider surroundProvider()
*/
public function testSurround($expected, $str, $substring)
{
$result = S::surround($str, $substring);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider insertProvider()
*/
public function testInsert($expected, $str, $substring, $index,
$encoding = null)
{
$result = S::insert($str, $substring, $index, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider truncateProvider()
*/
public function testTruncate($expected, $str, $length, $substring = '',
$encoding = null)
{
$result = S::truncate($str, $length, $substring, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider safeTruncateProvider()
*/
public function testSafeTruncate($expected, $str, $length, $substring = '',
$encoding = null)
{
$result = S::safeTruncate($str, $length, $substring, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider reverseProvider()
*/
public function testReverse($expected, $str, $encoding = null)
{
$result = S::reverse($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider shuffleProvider()
*/
public function testShuffle($str, $encoding = null)
{
$result = S::shuffle($str, $encoding);
$encoding = $encoding ?: mb_internal_encoding();
$this->assertInternalType('string', $result);
$this->assertEquals(mb_strlen($str, $encoding),
mb_strlen($result, $encoding));
// We'll make sure that the chars are present after shuffle
for ($i = 0; $i < mb_strlen($str, $encoding); $i++) {
$char = mb_substr($str, $i, 1, $encoding);
$countBefore = mb_substr_count($str, $char, $encoding);
$countAfter = mb_substr_count($result, $char, $encoding);
$this->assertEquals($countBefore, $countAfter);
}
}
/**
* @dataProvider trimProvider()
*/
public function testTrim($expected, $str, $chars = null, $encoding = null)
{
$result = S::trim($str, $chars, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider trimLeftProvider()
*/
public function testTrimLeft($expected, $str, $chars = null,
$encoding = null)
{
$result = S::trimLeft($str, $chars, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider trimRightProvider()
*/
public function testTrimRight($expected, $str, $chars = null,
$encoding = null)
{
$result = S::trimRight($str, $chars, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider longestCommonPrefixProvider()
*/
public function testLongestCommonPrefix($expected, $str, $otherStr,
$encoding = null)
{
$result = S::longestCommonPrefix($str, $otherStr, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider longestCommonSuffixProvider()
*/
public function testLongestCommonSuffix($expected, $str, $otherStr,
$encoding = null)
{
$result = S::longestCommonSuffix($str, $otherStr, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider longestCommonSubstringProvider()
*/
public function testLongestCommonSubstring($expected, $str, $otherStr,
$encoding = null)
{
$result = S::longestCommonSubstring($str, $otherStr, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider lengthProvider()
*/
public function testLength($expected, $str, $encoding = null)
{
$result = S::length($str, $encoding);
$this->assertEquals($expected, $result);
$this->assertInternalType('int', $result);
}
/**
* @dataProvider substrProvider()
*/
public function testSubstr($expected, $str, $start, $length = null,
$encoding = null)
{
$result = S::substr($str, $start, $length, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider atProvider()
*/
public function testAt($expected, $str, $index, $encoding = null)
{
$result = S::at($str, $index, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider firstProvider()
*/
public function testFirst($expected, $str, $n, $encoding = null)
{
$result = S::first($str, $n, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider lastProvider()
*/
public function testLast($expected, $str, $n, $encoding = null)
{
$result = S::last($str, $n, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider ensureLeftProvider()
*/
public function testEnsureLeft($expected, $str, $substring, $encoding = null)
{
$result = S::ensureLeft($str, $substring, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider ensureRightProvider()
*/
public function testEnsureRight($expected, $str, $substring, $encoding = null)
{
$result = S::ensureRight($str, $substring, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider removeLeftProvider()
*/
public function testRemoveLeft($expected, $str, $substring, $encoding = null)
{
$result = S::removeLeft($str, $substring, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider removeRightProvider()
*/
public function testRemoveRight($expected, $str, $substring, $encoding = null)
{
$result = S::removeRight($str, $substring, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider isAlphaProvider()
*/
public function testIsAlpha($expected, $str, $encoding = null)
{
$result = S::isAlpha($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider isAlphanumericProvider()
*/
public function testIsAlphanumeric($expected, $str, $encoding = null)
{
$result = S::isAlphanumeric($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider isBlankProvider()
*/
public function testIsBlank($expected, $str, $encoding = null)
{
$result = S::isBlank($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider isJsonProvider()
*/
public function testIsJson($expected, $str, $encoding = null)
{
$result = S::isJson($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider isLowerCaseProvider()
*/
public function testIsLowerCase($expected, $str, $encoding = null)
{
$result = S::isLowerCase($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider hasLowerCaseProvider()
*/
public function testHasLowerCase($expected, $str, $encoding = null)
{
$result = S::hasLowerCase($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider isSerializedProvider()
*/
public function testIsSerialized($expected, $str, $encoding = null)
{
$result = S::isSerialized($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider isUpperCaseProvider()
*/
public function testIsUpperCase($expected, $str, $encoding = null)
{
$result = S::isUpperCase($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider hasUpperCaseProvider()
*/
public function testHasUpperCase($expected, $str, $encoding = null)
{
$result = S::hasUpperCase($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider isHexadecimalProvider()
*/
public function testIsHexadecimal($expected, $str, $encoding = null)
{
$result = S::isHexadecimal($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider countSubstrProvider()
*/
public function testCountSubstr($expected, $str, $substring,
$caseSensitive = true, $encoding = null)
{
$result = S::countSubstr($str, $substring, $caseSensitive, $encoding);
$this->assertInternalType('int', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider replaceProvider()
*/
public function testReplace($expected, $str, $search, $replacement,
$encoding = null)
{
$result = S::replace($str, $search, $replacement, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider regexReplaceProvider()
*/
public function testRegexReplace($expected, $str, $pattern, $replacement,
$options = 'msr', $encoding = null)
{
$result = S::regexReplace($str, $pattern, $replacement, $options, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider htmlEncodeProvider()
*/
public function testHtmlEncode($expected, $str, $flags = ENT_COMPAT, $encoding = null)
{
$result = S::htmlEncode($str, $flags, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider htmlDecodeProvider()
*/
public function testHtmlDecode($expected, $str, $flags = ENT_COMPAT, $encoding = null)
{
$result = S::htmlDecode($str, $flags, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
}

View File

@ -0,0 +1,994 @@
<?php
require __DIR__ . '/../src/Stringy.php';
use Stringy\Stringy as S;
class StringyTestCase extends CommonTest
{
public function testConstruct()
{
$stringy = new S('foo bar', 'UTF-8');
$this->assertStringy($stringy);
$this->assertEquals('foo bar', (string) $stringy);
$this->assertEquals('UTF-8', $stringy->getEncoding());
}
/**
* @expectedException InvalidArgumentException
*/
public function testConstructWithArray()
{
(string) new S(array());
$this->fail('Expecting exception when the constructor is passed an array');
}
/**
* @expectedException InvalidArgumentException
*/
public function testMissingToString()
{
(string) new S(new stdClass());
$this->fail('Expecting exception when the constructor is passed an ' .
'object without a __toString method');
}
/**
* @dataProvider toStringProvider()
*/
public function testToString($expected, $str)
{
$this->assertEquals($expected, (string) new S($str));
}
public function toStringProvider()
{
return array(
array('', null),
array('', false),
array('1', true),
array('-9', -9),
array('1.18', 1.18),
array(' string ', ' string ')
);
}
public function testCreate()
{
$stringy = S::create('foo bar', 'UTF-8');
$this->assertStringy($stringy);
$this->assertEquals('foo bar', (string) $stringy);
$this->assertEquals('UTF-8', $stringy->getEncoding());
}
public function testChaining()
{
$stringy = S::create("Fòô Bàř", 'UTF-8');
$this->assertStringy($stringy);
$result = $stringy->collapseWhitespace()->swapCase()->upperCaseFirst();
$this->assertEquals('FÒÔ bÀŘ', $result);
}
public function testCount()
{
$stringy = S::create('Fòô', 'UTF-8');
$this->assertEquals(3, $stringy->count());
$this->assertEquals(3, count($stringy));
}
public function testGetIterator()
{
$stringy = S::create('Fòô Bàř', 'UTF-8');
$valResult = array();
foreach ($stringy as $char) {
$valResult[] = $char;
}
$keyValResult = array();
foreach ($stringy as $pos => $char) {
$keyValResult[$pos] = $char;
}
$this->assertEquals(array('F', 'ò', 'ô', ' ', 'B', 'à', 'ř'), $valResult);
$this->assertEquals(array('F', 'ò', 'ô', ' ', 'B', 'à', 'ř'), $keyValResult);
}
/**
* @dataProvider offsetExistsProvider()
*/
public function testOffsetExists($expected, $offset)
{
$stringy = S::create('fòô', 'UTF-8');
$this->assertEquals($expected, $stringy->offsetExists($offset));
$this->assertEquals($expected, isset($stringy[$offset]));
}
public function offsetExistsProvider()
{
return array(
array(true, 0),
array(true, 2),
array(false, 3),
array(true, -1),
array(true, -3),
array(false, -4)
);
}
public function testOffsetGet()
{
$stringy = S::create('fòô', 'UTF-8');
$this->assertEquals('f', $stringy->offsetGet(0));
$this->assertEquals('ô', $stringy->offsetGet(2));
$this->assertEquals('ô', $stringy[2]);
}
/**
* @expectedException \OutOfBoundsException
*/
public function testOffsetGetOutOfBounds()
{
$stringy = S::create('fòô', 'UTF-8');
$test = $stringy[3];
}
/**
* @expectedException \Exception
*/
public function testOffsetSet()
{
$stringy = S::create('fòô', 'UTF-8');
$stringy[1] = 'invalid';
}
/**
* @expectedException \Exception
*/
public function testOffsetUnset()
{
$stringy = S::create('fòô', 'UTF-8');
unset($stringy[1]);
}
/**
* @dataProvider indexOfProvider()
*/
public function testIndexOf($expected, $str, $subStr, $offset = 0, $encoding = null)
{
$result = S::create($str, $encoding)->indexOf($subStr, $offset);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider indexOfLastProvider()
*/
public function testIndexOfLast($expected, $str, $subStr, $offset = 0, $encoding = null)
{
$result = S::create($str, $encoding)->indexOfLast($subStr, $offset);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider charsProvider()
*/
public function testChars($expected, $str, $encoding = null)
{
$result = S::create($str, $encoding)->chars();
$this->assertInternalType('array', $result);
foreach ($result as $char) {
$this->assertInternalType('string', $char);
}
$this->assertEquals($expected, $result);
}
/**
* @dataProvider upperCaseFirstProvider()
*/
public function testUpperCaseFirst($expected, $str, $encoding = null)
{
$result = S::create($str, $encoding)->upperCaseFirst();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider lowerCaseFirstProvider()
*/
public function testLowerCaseFirst($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->lowerCaseFirst();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider camelizeProvider()
*/
public function testCamelize($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->camelize();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider upperCamelizeProvider()
*/
public function testUpperCamelize($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->upperCamelize();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider dasherizeProvider()
*/
public function testDasherize($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->dasherize();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider underscoredProvider()
*/
public function testUnderscored($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->underscored();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider delimitProvider()
*/
public function testDelimit($expected, $str, $delimiter, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->delimit($delimiter);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider swapCaseProvider()
*/
public function testSwapCase($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->swapCase();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider titleizeProvider()
*/
public function testTitleize($expected, $str, $ignore = null,
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->titleize($ignore);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider humanizeProvider()
*/
public function testHumanize($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->humanize();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider tidyProvider()
*/
public function testTidy($expected, $str)
{
$stringy = S::create($str);
$result = $stringy->tidy();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider collapseWhitespaceProvider()
*/
public function testCollapseWhitespace($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->collapseWhitespace();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider toAsciiProvider()
*/
public function testToAscii($expected, $str, $removeUnsupported = true)
{
$stringy = S::create($str);
$result = $stringy->toAscii($removeUnsupported);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider padProvider()
*/
public function testPad($expected, $str, $length, $padStr = ' ',
$padType = 'right', $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->pad($length, $padStr, $padType);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testPadException()
{
$stringy = S::create('foo');
$result = $stringy->pad(5, 'foo', 'bar');
}
/**
* @dataProvider padLeftProvider()
*/
public function testPadLeft($expected, $str, $length, $padStr = ' ',
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->padLeft($length, $padStr);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider padRightProvider()
*/
public function testPadRight($expected, $str, $length, $padStr = ' ',
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->padRight($length, $padStr);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider padBothProvider()
*/
public function testPadBoth($expected, $str, $length, $padStr = ' ',
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->padBoth($length, $padStr);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider startsWithProvider()
*/
public function testStartsWith($expected, $str, $substring,
$caseSensitive = true, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->startsWith($substring, $caseSensitive);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider endsWithProvider()
*/
public function testEndsWith($expected, $str, $substring,
$caseSensitive = true, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->endsWith($substring, $caseSensitive);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider toSpacesProvider()
*/
public function testToSpaces($expected, $str, $tabLength = 4)
{
$stringy = S::create($str);
$result = $stringy->toSpaces($tabLength);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider toTabsProvider()
*/
public function testToTabs($expected, $str, $tabLength = 4)
{
$stringy = S::create($str);
$result = $stringy->toTabs($tabLength);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider toLowerCaseProvider()
*/
public function testToLowerCase($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->toLowerCase();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider toTitleCaseProvider()
*/
public function testToTitleCase($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->toTitleCase();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider toUpperCaseProvider()
*/
public function testToUpperCase($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->toUpperCase();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider slugifyProvider()
*/
public function testSlugify($expected, $str, $replacement = '-')
{
$stringy = S::create($str);
$result = $stringy->slugify($replacement);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider containsProvider()
*/
public function testContains($expected, $haystack, $needle,
$caseSensitive = true, $encoding = null)
{
$stringy = S::create($haystack, $encoding);
$result = $stringy->contains($needle, $caseSensitive);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($haystack, $stringy);
}
/**
* @dataProvider containsAnyProvider()
*/
public function testcontainsAny($expected, $haystack, $needles,
$caseSensitive = true, $encoding = null)
{
$stringy = S::create($haystack, $encoding);
$result = $stringy->containsAny($needles, $caseSensitive);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($haystack, $stringy);
}
/**
* @dataProvider containsAllProvider()
*/
public function testContainsAll($expected, $haystack, $needles,
$caseSensitive = true, $encoding = null)
{
$stringy = S::create($haystack, $encoding);
$result = $stringy->containsAll($needles, $caseSensitive);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($haystack, $stringy);
}
/**
* @dataProvider surroundProvider()
*/
public function testSurround($expected, $str, $substring)
{
$stringy = S::create($str);
$result = $stringy->surround($substring);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider insertProvider()
*/
public function testInsert($expected, $str, $substring, $index,
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->insert($substring, $index);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider truncateProvider()
*/
public function testTruncate($expected, $str, $length, $substring = '',
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->truncate($length, $substring);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider safeTruncateProvider()
*/
public function testSafeTruncate($expected, $str, $length, $substring = '',
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->safeTruncate($length, $substring);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider reverseProvider()
*/
public function testReverse($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->reverse();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider shuffleProvider()
*/
public function testShuffle($str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$encoding = $encoding ?: mb_internal_encoding();
$result = $stringy->shuffle();
$this->assertStringy($result);
$this->assertEquals($str, $stringy);
$this->assertEquals(mb_strlen($str, $encoding),
mb_strlen($result, $encoding));
// We'll make sure that the chars are present after shuffle
for ($i = 0; $i < mb_strlen($str, $encoding); $i++) {
$char = mb_substr($str, $i, 1, $encoding);
$countBefore = mb_substr_count($str, $char, $encoding);
$countAfter = mb_substr_count($result, $char, $encoding);
$this->assertEquals($countBefore, $countAfter);
}
}
/**
* @dataProvider trimProvider()
*/
public function testTrim($expected, $str, $chars = null, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->trim($chars);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider trimLeftProvider()
*/
public function testTrimLeft($expected, $str, $chars = null,
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->trimLeft($chars);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider trimRightProvider()
*/
public function testTrimRight($expected, $str, $chars = null,
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->trimRight($chars);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider longestCommonPrefixProvider()
*/
public function testLongestCommonPrefix($expected, $str, $otherStr,
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->longestCommonPrefix($otherStr);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider longestCommonSuffixProvider()
*/
public function testLongestCommonSuffix($expected, $str, $otherStr,
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->longestCommonSuffix($otherStr);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider longestCommonSubstringProvider()
*/
public function testLongestCommonSubstring($expected, $str, $otherStr,
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->longestCommonSubstring($otherStr);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider lengthProvider()
*/
public function testLength($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->length();
$this->assertInternalType('int', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider substrProvider()
*/
public function testSubstr($expected, $str, $start, $length = null,
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->substr($start, $length);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider atProvider()
*/
public function testAt($expected, $str, $index, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->at($index);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider firstProvider()
*/
public function testFirst($expected, $str, $n, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->first($n);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider lastProvider()
*/
public function testLast($expected, $str, $n, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->last($n);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider ensureLeftProvider()
*/
public function testEnsureLeft($expected, $str, $substring, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->ensureLeft($substring);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider ensureRightProvider()
*/
public function testEnsureRight($expected, $str, $substring, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->ensureRight($substring);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider removeLeftProvider()
*/
public function testRemoveLeft($expected, $str, $substring, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->removeLeft($substring);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider removeRightProvider()
*/
public function testRemoveRight($expected, $str, $substring, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->removeRight($substring);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider isAlphaProvider()
*/
public function testIsAlpha($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->isAlpha();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider isAlphanumericProvider()
*/
public function testIsAlphanumeric($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->isAlphanumeric();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider isBlankProvider()
*/
public function testIsBlank($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->isBlank();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider isJsonProvider()
*/
public function testIsJson($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->isJson();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider isLowerCaseProvider()
*/
public function testIsLowerCase($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->isLowerCase();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider hasLowerCaseProvider()
*/
public function testHasLowerCase($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->hasLowerCase();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider isSerializedProvider()
*/
public function testIsSerialized($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->isSerialized();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider isUpperCaseProvider()
*/
public function testIsUpperCase($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->isUpperCase();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider hasUpperCaseProvider()
*/
public function testHasUpperCase($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->hasUpperCase();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider isHexadecimalProvider()
*/
public function testIsHexadecimal($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->isHexadecimal();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider countSubstrProvider()
*/
public function testCountSubstr($expected, $str, $substring,
$caseSensitive = true, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->countSubstr($substring, $caseSensitive);
$this->assertInternalType('int', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider replaceProvider()
*/
public function testReplace($expected, $str, $search, $replacement,
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->replace($search, $replacement);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider regexReplaceProvider()
*/
public function testregexReplace($expected, $str, $pattern, $replacement,
$options = 'msr', $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->regexReplace($pattern, $replacement, $options);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider htmlEncodeProvider()
*/
public function testHtmlEncode($expected, $str, $flags = ENT_COMPAT, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->htmlEncode($flags);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider htmlDecodeProvider()
*/
public function testHtmlDecode($expected, $str, $flags = ENT_COMPAT, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->htmlDecode($flags);
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
}

4
vendor/doctrine/inflector/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
vendor/
composer.lock
composer.phar
phpunit.xml

11
vendor/doctrine/inflector/.travis.yml vendored Normal file
View File

@ -0,0 +1,11 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
install:
- composer --prefer-source install

19
vendor/doctrine/inflector/LICENSE vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2006-2013 Doctrine Project
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

6
vendor/doctrine/inflector/README.md vendored Normal file
View File

@ -0,0 +1,6 @@
# Doctrine Inflector
Doctrine Inflector is a small library that can perform string manipulations
with regard to upper-/lowercase and singular/plural forms of words.
[![Build Status](https://travis-ci.org/doctrine/inflector.svg?branch=master)](https://travis-ci.org/doctrine/inflector)

29
vendor/doctrine/inflector/composer.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"name": "doctrine/inflector",
"type": "library",
"description": "Common String Manipulations with regard to casing and singular/plural rules.",
"keywords": ["string", "inflection", "singularize", "pluralize"],
"homepage": "http://www.doctrine-project.org",
"license": "MIT",
"authors": [
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
{"name": "Roman Borschel", "email": "roman@code-factory.org"},
{"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
{"name": "Jonathan Wage", "email": "jonwage@gmail.com"},
{"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}
],
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "4.*"
},
"autoload": {
"psr-0": { "Doctrine\\Common\\Inflector\\": "lib/" }
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
}

View File

@ -0,0 +1,415 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Common\Inflector;
/**
* Doctrine inflector has static methods for inflecting text.
*
* The methods in these classes are from several different sources collected
* across several different php projects and several different authors. The
* original author names and emails are not known.
*
* Pluralize & Singularize implementation are borrowed from CakePHP with some modifications.
*
* @link www.doctrine-project.org
* @since 1.0
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Jonathan H. Wage <jonwage@gmail.com>
*/
class Inflector
{
/**
* Plural inflector rules.
*
* @var array
*/
private static $plural = array(
'rules' => array(
'/(s)tatus$/i' => '\1\2tatuses',
'/(quiz)$/i' => '\1zes',
'/^(ox)$/i' => '\1\2en',
'/([m|l])ouse$/i' => '\1ice',
'/(matr|vert|ind)(ix|ex)$/i' => '\1ices',
'/(x|ch|ss|sh)$/i' => '\1es',
'/([^aeiouy]|qu)y$/i' => '\1ies',
'/(hive)$/i' => '\1s',
'/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
'/sis$/i' => 'ses',
'/([ti])um$/i' => '\1a',
'/(p)erson$/i' => '\1eople',
'/(m)an$/i' => '\1en',
'/(c)hild$/i' => '\1hildren',
'/(buffal|tomat)o$/i' => '\1\2oes',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i',
'/us$/i' => 'uses',
'/(alias)$/i' => '\1es',
'/(ax|cris|test)is$/i' => '\1es',
'/s$/' => 's',
'/^$/' => '',
'/$/' => 's',
),
'uninflected' => array(
'.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people', 'cookie'
),
'irregular' => array(
'atlas' => 'atlases',
'beef' => 'beefs',
'brother' => 'brothers',
'cafe' => 'cafes',
'child' => 'children',
'cookie' => 'cookies',
'corpus' => 'corpuses',
'cow' => 'cows',
'criteria' => 'criterion',
'ganglion' => 'ganglions',
'genie' => 'genies',
'genus' => 'genera',
'graffito' => 'graffiti',
'hoof' => 'hoofs',
'human' => 'humans',
'loaf' => 'loaves',
'man' => 'men',
'money' => 'monies',
'mongoose' => 'mongooses',
'move' => 'moves',
'mythos' => 'mythoi',
'niche' => 'niches',
'numen' => 'numina',
'occiput' => 'occiputs',
'octopus' => 'octopuses',
'opus' => 'opuses',
'ox' => 'oxen',
'penis' => 'penises',
'person' => 'people',
'sex' => 'sexes',
'soliloquy' => 'soliloquies',
'testis' => 'testes',
'trilby' => 'trilbys',
'turf' => 'turfs',
)
);
/**
* Singular inflector rules.
*
* @var array
*/
private static $singular = array(
'rules' => array(
'/(s)tatuses$/i' => '\1\2tatus',
'/^(.*)(menu)s$/i' => '\1\2',
'/(quiz)zes$/i' => '\\1',
'/(matr)ices$/i' => '\1ix',
'/(vert|ind)ices$/i' => '\1ex',
'/^(ox)en/i' => '\1',
'/(alias)(es)*$/i' => '\1',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
'/([ftw]ax)es/i' => '\1',
'/(cris|ax|test)es$/i' => '\1is',
'/(shoe|slave)s$/i' => '\1',
'/(o)es$/i' => '\1',
'/ouses$/' => 'ouse',
'/([^a])uses$/' => '\1us',
'/([m|l])ice$/i' => '\1ouse',
'/(x|ch|ss|sh)es$/i' => '\1',
'/(m)ovies$/i' => '\1\2ovie',
'/(s)eries$/i' => '\1\2eries',
'/([^aeiouy]|qu)ies$/i' => '\1y',
'/([lr])ves$/i' => '\1f',
'/(tive)s$/i' => '\1',
'/(hive)s$/i' => '\1',
'/(drive)s$/i' => '\1',
'/([^fo])ves$/i' => '\1fe',
'/(^analy)ses$/i' => '\1sis',
'/(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
'/([ti])a$/i' => '\1um',
'/(p)eople$/i' => '\1\2erson',
'/(m)en$/i' => '\1an',
'/(c)hildren$/i' => '\1\2hild',
'/(n)ews$/i' => '\1\2ews',
'/eaus$/' => 'eau',
'/^(.*us)$/' => '\\1',
'/s$/i' => '',
),
'uninflected' => array(
'.*[nrlm]ese',
'.*deer',
'.*fish',
'.*measles',
'.*ois',
'.*pox',
'.*sheep',
'.*ss',
),
'irregular' => array(
'criterion' => 'criteria',
'curves' => 'curve',
'foes' => 'foe',
'waves' => 'wave',
)
);
/**
* Words that should not be inflected.
*
* @var array
*/
private static $uninflected = array(
'Amoyese', 'bison', 'Borghese', 'bream', 'breeches', 'britches', 'buffalo', 'cantus',
'carp', 'chassis', 'clippers', 'cod', 'coitus', 'Congoese', 'contretemps', 'corps',
'debris', 'diabetes', 'djinn', 'eland', 'elk', 'equipment', 'Faroese', 'flounder',
'Foochowese', 'gallows', 'Genevese', 'Genoese', 'Gilbertese', 'graffiti',
'headquarters', 'herpes', 'hijinks', 'Hottentotese', 'information', 'innings',
'jackanapes', 'Kiplingese', 'Kongoese', 'Lucchese', 'mackerel', 'Maltese', '.*?media',
'mews', 'moose', 'mumps', 'Nankingese', 'news', 'nexus', 'Niasese',
'Pekingese', 'Piedmontese', 'pincers', 'Pistoiese', 'pliers', 'Portuguese',
'proceedings', 'rabies', 'rice', 'rhinoceros', 'salmon', 'Sarawakese', 'scissors',
'sea[- ]bass', 'series', 'Shavese', 'shears', 'siemens', 'species', 'staff', 'swine',
'testes', 'trousers', 'trout', 'tuna', 'Vermontese', 'Wenchowese', 'whiting',
'wildebeest', 'Yengeese'
);
/**
* Method cache array.
*
* @var array
*/
private static $cache = array();
/**
* The initial state of Inflector so reset() works.
*
* @var array
*/
private static $initialState = array();
/**
* Converts a word into the format for a Doctrine table name. Converts 'ModelName' to 'model_name'.
*
* @param string $word The word to tableize.
*
* @return string The tableized word.
*/
public static function tableize($word)
{
return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word));
}
/**
* Converts a word into the format for a Doctrine class name. Converts 'table_name' to 'TableName'.
*
* @param string $word The word to classify.
*
* @return string The classified word.
*/
public static function classify($word)
{
return str_replace(" ", "", ucwords(strtr($word, "_-", " ")));
}
/**
* Camelizes a word. This uses the classify() method and turns the first character to lowercase.
*
* @param string $word The word to camelize.
*
* @return string The camelized word.
*/
public static function camelize($word)
{
return lcfirst(self::classify($word));
}
/**
* Clears Inflectors inflected value caches, and resets the inflection
* rules to the initial values.
*
* @return void
*/
public static function reset()
{
if (empty(self::$initialState)) {
self::$initialState = get_class_vars('Inflector');
return;
}
foreach (self::$initialState as $key => $val) {
if ($key != 'initialState') {
self::${$key} = $val;
}
}
}
/**
* Adds custom inflection $rules, of either 'plural' or 'singular' $type.
*
* ### Usage:
*
* {{{
* Inflector::rules('plural', array('/^(inflect)or$/i' => '\1ables'));
* Inflector::rules('plural', array(
* 'rules' => array('/^(inflect)ors$/i' => '\1ables'),
* 'uninflected' => array('dontinflectme'),
* 'irregular' => array('red' => 'redlings')
* ));
* }}}
*
* @param string $type The type of inflection, either 'plural' or 'singular'
* @param array $rules An array of rules to be added.
* @param boolean $reset If true, will unset default inflections for all
* new rules that are being defined in $rules.
*
* @return void
*/
public static function rules($type, $rules, $reset = false)
{
foreach ($rules as $rule => $pattern) {
if ( ! is_array($pattern)) {
continue;
}
if ($reset) {
self::${$type}[$rule] = $pattern;
} else {
self::${$type}[$rule] = ($rule === 'uninflected')
? array_merge($pattern, self::${$type}[$rule])
: $pattern + self::${$type}[$rule];
}
unset($rules[$rule], self::${$type}['cache' . ucfirst($rule)]);
if (isset(self::${$type}['merged'][$rule])) {
unset(self::${$type}['merged'][$rule]);
}
if ($type === 'plural') {
self::$cache['pluralize'] = self::$cache['tableize'] = array();
} elseif ($type === 'singular') {
self::$cache['singularize'] = array();
}
}
self::${$type}['rules'] = $rules + self::${$type}['rules'];
}
/**
* Returns a word in plural form.
*
* @param string $word The word in singular form.
*
* @return string The word in plural form.
*/
public static function pluralize($word)
{
if (isset(self::$cache['pluralize'][$word])) {
return self::$cache['pluralize'][$word];
}
if (!isset(self::$plural['merged']['irregular'])) {
self::$plural['merged']['irregular'] = self::$plural['irregular'];
}
if (!isset(self::$plural['merged']['uninflected'])) {
self::$plural['merged']['uninflected'] = array_merge(self::$plural['uninflected'], self::$uninflected);
}
if (!isset(self::$plural['cacheUninflected']) || !isset(self::$plural['cacheIrregular'])) {
self::$plural['cacheUninflected'] = '(?:' . implode('|', self::$plural['merged']['uninflected']) . ')';
self::$plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$plural['merged']['irregular'])) . ')';
}
if (preg_match('/(.*)\\b(' . self::$plural['cacheIrregular'] . ')$/i', $word, $regs)) {
self::$cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$plural['merged']['irregular'][strtolower($regs[2])], 1);
return self::$cache['pluralize'][$word];
}
if (preg_match('/^(' . self::$plural['cacheUninflected'] . ')$/i', $word, $regs)) {
self::$cache['pluralize'][$word] = $word;
return $word;
}
foreach (self::$plural['rules'] as $rule => $replacement) {
if (preg_match($rule, $word)) {
self::$cache['pluralize'][$word] = preg_replace($rule, $replacement, $word);
return self::$cache['pluralize'][$word];
}
}
}
/**
* Returns a word in singular form.
*
* @param string $word The word in plural form.
*
* @return string The word in singular form.
*/
public static function singularize($word)
{
if (isset(self::$cache['singularize'][$word])) {
return self::$cache['singularize'][$word];
}
if (!isset(self::$singular['merged']['uninflected'])) {
self::$singular['merged']['uninflected'] = array_merge(
self::$singular['uninflected'],
self::$uninflected
);
}
if (!isset(self::$singular['merged']['irregular'])) {
self::$singular['merged']['irregular'] = array_merge(
self::$singular['irregular'],
array_flip(self::$plural['irregular'])
);
}
if (!isset(self::$singular['cacheUninflected']) || !isset(self::$singular['cacheIrregular'])) {
self::$singular['cacheUninflected'] = '(?:' . join('|', self::$singular['merged']['uninflected']) . ')';
self::$singular['cacheIrregular'] = '(?:' . join('|', array_keys(self::$singular['merged']['irregular'])) . ')';
}
if (preg_match('/(.*)\\b(' . self::$singular['cacheIrregular'] . ')$/i', $word, $regs)) {
self::$cache['singularize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$singular['merged']['irregular'][strtolower($regs[2])], 1);
return self::$cache['singularize'][$word];
}
if (preg_match('/^(' . self::$singular['cacheUninflected'] . ')$/i', $word, $regs)) {
self::$cache['singularize'][$word] = $word;
return $word;
}
foreach (self::$singular['rules'] as $rule => $replacement) {
if (preg_match($rule, $word)) {
self::$cache['singularize'][$word] = preg_replace($rule, $replacement, $word);
return self::$cache['singularize'][$word];
}
}
self::$cache['singularize'][$word] = $word;
return $word;
}
}

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/Doctrine/Tests/TestInit.php"
>
<testsuites>
<testsuite name="Doctrine Inflector Test Suite">
<directory>./tests/Doctrine/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./lib/Doctrine/</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>performance</group>
</exclude>
</groups>
</phpunit>

View File

@ -0,0 +1,210 @@
<?php
namespace Doctrine\Tests\Common\Inflector;
use Doctrine\Tests\DoctrineTestCase;
use Doctrine\Common\Inflector\Inflector;
class InflectorTest extends DoctrineTestCase
{
/**
* Singular & Plural test data. Returns an array of sample words.
*
* @return array
*/
public function dataSampleWords()
{
Inflector::reset();
// in the format array('singular', 'plural')
return array(
array('categoria', 'categorias'),
array('house', 'houses'),
array('powerhouse', 'powerhouses'),
array('Bus', 'Buses'),
array('bus', 'buses'),
array('menu', 'menus'),
array('news', 'news'),
array('food_menu', 'food_menus'),
array('Menu', 'Menus'),
array('FoodMenu', 'FoodMenus'),
array('quiz', 'quizzes'),
array('matrix_row', 'matrix_rows'),
array('matrix', 'matrices'),
array('vertex', 'vertices'),
array('index', 'indices'),
array('Alias', 'Aliases'),
array('Media', 'Media'),
array('NodeMedia', 'NodeMedia'),
array('alumnus', 'alumni'),
array('bacillus', 'bacilli'),
array('cactus', 'cacti'),
array('focus', 'foci'),
array('fungus', 'fungi'),
array('nucleus', 'nuclei'),
array('octopus', 'octopuses'),
array('radius', 'radii'),
array('stimulus', 'stimuli'),
array('syllabus', 'syllabi'),
array('terminus', 'termini'),
array('virus', 'viri'),
array('person', 'people'),
array('glove', 'gloves'),
array('crisis', 'crises'),
array('tax', 'taxes'),
array('wave', 'waves'),
array('bureau', 'bureaus'),
array('cafe', 'cafes'),
array('roof', 'roofs'),
array('foe', 'foes'),
array('cookie', 'cookies'),
array('identity', 'identities'),
array('criteria', 'criterion'),
array('curve', 'curves'),
array('', ''),
);
}
/**
* testInflectingSingulars method
*
* @dataProvider dataSampleWords
* @return void
*/
public function testInflectingSingulars($singular, $plural)
{
$this->assertEquals(
$singular,
Inflector::singularize($plural),
"'$plural' should be singularized to '$singular'"
);
}
/**
* testInflectingPlurals method
*
* @dataProvider dataSampleWords
* @return void
*/
public function testInflectingPlurals($singular, $plural)
{
$this->assertEquals(
$plural,
Inflector::pluralize($singular),
"'$singular' should be pluralized to '$plural'"
);
}
/**
* testCustomPluralRule method
*
* @return void
*/
public function testCustomPluralRule()
{
Inflector::reset();
Inflector::rules('plural', array('/^(custom)$/i' => '\1izables'));
$this->assertEquals(Inflector::pluralize('custom'), 'customizables');
Inflector::rules('plural', array('uninflected' => array('uninflectable')));
$this->assertEquals(Inflector::pluralize('uninflectable'), 'uninflectable');
Inflector::rules('plural', array(
'rules' => array('/^(alert)$/i' => '\1ables'),
'uninflected' => array('noflect', 'abtuse'),
'irregular' => array('amaze' => 'amazable', 'phone' => 'phonezes')
));
$this->assertEquals(Inflector::pluralize('noflect'), 'noflect');
$this->assertEquals(Inflector::pluralize('abtuse'), 'abtuse');
$this->assertEquals(Inflector::pluralize('alert'), 'alertables');
$this->assertEquals(Inflector::pluralize('amaze'), 'amazable');
$this->assertEquals(Inflector::pluralize('phone'), 'phonezes');
}
/**
* testCustomSingularRule method
*
* @return void
*/
public function testCustomSingularRule()
{
Inflector::reset();
Inflector::rules('singular', array('/(eple)r$/i' => '\1', '/(jente)r$/i' => '\1'));
$this->assertEquals(Inflector::singularize('epler'), 'eple');
$this->assertEquals(Inflector::singularize('jenter'), 'jente');
Inflector::rules('singular', array(
'rules' => array('/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'),
'uninflected' => array('singulars'),
'irregular' => array('spins' => 'spinor')
));
$this->assertEquals(Inflector::singularize('inflectors'), 'inflecta');
$this->assertEquals(Inflector::singularize('contributors'), 'contributa');
$this->assertEquals(Inflector::singularize('spins'), 'spinor');
$this->assertEquals(Inflector::singularize('singulars'), 'singulars');
}
/**
* test that setting new rules clears the inflector caches.
*
* @return void
*/
public function testRulesClearsCaches()
{
Inflector::reset();
$this->assertEquals(Inflector::singularize('Bananas'), 'Banana');
$this->assertEquals(Inflector::pluralize('Banana'), 'Bananas');
Inflector::rules('singular', array(
'rules' => array('/(.*)nas$/i' => '\1zzz')
));
$this->assertEquals('Banazzz', Inflector::singularize('Bananas'), 'Was inflected with old rules.');
Inflector::rules('plural', array(
'rules' => array('/(.*)na$/i' => '\1zzz'),
'irregular' => array('corpus' => 'corpora')
));
$this->assertEquals(Inflector::pluralize('Banana'), 'Banazzz', 'Was inflected with old rules.');
$this->assertEquals(Inflector::pluralize('corpus'), 'corpora', 'Was inflected with old irregular form.');
}
/**
* Test resetting inflection rules.
*
* @return void
*/
public function testCustomRuleWithReset()
{
Inflector::reset();
$uninflected = array('atlas', 'lapis', 'onibus', 'pires', 'virus', '.*x');
$pluralIrregular = array('as' => 'ases');
Inflector::rules('singular', array(
'rules' => array('/^(.*)(a|e|o|u)is$/i' => '\1\2l'),
'uninflected' => $uninflected,
), true);
Inflector::rules('plural', array(
'rules' => array(
'/^(.*)(a|e|o|u)l$/i' => '\1\2is',
),
'uninflected' => $uninflected,
'irregular' => $pluralIrregular
), true);
$this->assertEquals(Inflector::pluralize('Alcool'), 'Alcoois');
$this->assertEquals(Inflector::pluralize('Atlas'), 'Atlas');
$this->assertEquals(Inflector::singularize('Alcoois'), 'Alcool');
$this->assertEquals(Inflector::singularize('Atlas'), 'Atlas');
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace Doctrine\Tests;
/**
* Base testcase class for all Doctrine testcases.
*/
abstract class DoctrineTestCase extends \PHPUnit_Framework_TestCase
{
}

View File

@ -0,0 +1,27 @@
<?php
/*
* This file bootstraps the test environment.
*/
namespace Doctrine\Tests;
error_reporting(E_ALL | E_STRICT);
// register silently failing autoloader
spl_autoload_register(function($class)
{
if (0 === strpos($class, 'Doctrine\Tests\\')) {
$path = __DIR__.'/../../'.strtr($class, '\\', '/').'.php';
if (is_file($path) && is_readable($path)) {
require_once $path;
return true;
}
} else if (0 === strpos($class, 'Doctrine\Common\\')) {
$path = __DIR__.'/../../../lib/'.($class = strtr($class, '\\', '/')).'.php';
if (is_file($path) && is_readable($path)) {
require_once $path;
return true;
}
}
});

View File

@ -0,0 +1,5 @@
phpunit.xml
composer.lock
build
vendor
coverage.clover

View File

@ -0,0 +1,46 @@
before_commands:
- "composer install --prefer-source"
tools:
external_code_coverage:
timeout: 600
php_code_coverage:
enabled: true
test_command: ./vendor/bin/phpunit
php_code_sniffer:
enabled: true
config:
standard: PSR2
filter:
paths: ["src/*", "tests/*"]
php_cpd:
enabled: true
excluded_dirs: ["build/*", "tests", "vendor"]
php_cs_fixer:
enabled: true
config:
level: all
filter:
paths: ["src/*", "tests/*"]
php_loc:
enabled: true
excluded_dirs: ["build", "tests", "vendor"]
php_mess_detector:
enabled: true
config:
ruleset: phpmd.xml.dist
design_rules: { eval_expression: false }
filter:
paths: ["src/*"]
php_pdepend:
enabled: true
excluded_dirs: ["build", "tests", "vendor"]
php_analyzer:
enabled: true
filter:
paths: ["src/*", "tests/*"]
php_hhvm:
enabled: true
filter:
paths: ["src/*", "tests/*"]
sensiolabs_security_checker: true

View File

@ -0,0 +1,14 @@
#!/bin/sh
set -x
if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ] || [ "$TRAVIS_PHP_VERSION" = 'hhvm-nightly' ] ; then
curl -sS https://getcomposer.org/installer > composer-installer.php
hhvm composer-installer.php
hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 composer.phar update --prefer-source
elif [ "$TRAVIS_PHP_VERSION" = '5.3.3' ] ; then
composer self-update
composer update --prefer-source --no-dev
composer dump-autoload
else
composer self-update
composer update --prefer-source
fi

View File

@ -0,0 +1,22 @@
language: php
php:
- 5.3.3
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
before_script:
- ./.travis.install.sh
- if [ $TRAVIS_PHP_VERSION = '5.6' ]; then PHPUNIT_FLAGS="--coverage-clover coverage.clover"; else PHPUNIT_FLAGS=""; fi
script:
- if [ $TRAVIS_PHP_VERSION = '5.3.3' ]; then phpunit; fi
- if [ $TRAVIS_PHP_VERSION != '5.3.3' ]; then ./vendor/bin/phpunit $PHPUNIT_FLAGS; fi
- if [ $TRAVIS_PHP_VERSION != '5.3.3' ]; then ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/; fi
- if [[ $TRAVIS_PHP_VERSION != '5.3.3' && $TRAVIS_PHP_VERSION != '5.4.29' && $TRAVIS_PHP_VERSION != '5.5.13' ]]; then php -n ./vendor/bin/athletic -p ./tests/DoctrineTest/InstantiatorPerformance/ -f GroupedFormatter; fi
after_script:
- if [ $TRAVIS_PHP_VERSION = '5.6' ]; then wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi

View File

@ -0,0 +1,35 @@
# Contributing
* Coding standard for the project is [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
* The project will follow strict [object calisthenics](http://www.slideshare.net/guilhermeblanco/object-calisthenics-applied-to-php)
* Any contribution must provide tests for additional introduced conditions
* Any un-confirmed issue needs a failing test case before being accepted
* Pull requests must be sent from a new hotfix/feature branch, not from `master`.
## Installation
To install the project and run the tests, you need to clone it first:
```sh
$ git clone git://github.com/doctrine/instantiator.git
```
You will then need to run a composer installation:
```sh
$ cd Instantiator
$ curl -s https://getcomposer.org/installer | php
$ php composer.phar update
```
## Testing
The PHPUnit version to be used is the one installed as a dev- dependency via composer:
```sh
$ ./vendor/bin/phpunit
```
Accepted coverage for new contributions is 80%. Any contribution not satisfying this requirement
won't be merged.

19
vendor/doctrine/instantiator/LICENSE vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2014 Doctrine Project
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

40
vendor/doctrine/instantiator/README.md vendored Normal file
View File

@ -0,0 +1,40 @@
# Instantiator
This library provides a way of avoiding usage of constructors when instantiating PHP classes.
[![Build Status](https://travis-ci.org/doctrine/instantiator.svg?branch=master)](https://travis-ci.org/doctrine/instantiator)
[![Code Coverage](https://scrutinizer-ci.com/g/doctrine/instantiator/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/doctrine/instantiator/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/doctrine/instantiator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/doctrine/instantiator/?branch=master)
[![Dependency Status](https://www.versioneye.com/package/php--doctrine--instantiator/badge.svg)](https://www.versioneye.com/package/php--doctrine--instantiator)
[![HHVM Status](http://hhvm.h4cc.de/badge/doctrine/instantiator.png)](http://hhvm.h4cc.de/package/doctrine/instantiator)
[![Latest Stable Version](https://poser.pugx.org/doctrine/instantiator/v/stable.png)](https://packagist.org/packages/doctrine/instantiator)
[![Latest Unstable Version](https://poser.pugx.org/doctrine/instantiator/v/unstable.png)](https://packagist.org/packages/doctrine/instantiator)
## Installation
The suggested installation method is via [composer](https://getcomposer.org/):
```sh
php composer.phar require "doctrine/instantiator:~1.0.3"
```
## Usage
The instantiator is able to create new instances of any class without using the constructor or any API of the class
itself:
```php
$instantiator = new \Doctrine\Instantiator\Instantiator();
$instance = $instantiator->instantiate('My\\ClassName\\Here');
```
## Contributing
Please read the [CONTRIBUTING.md](CONTRIBUTING.md) contents if you wish to help out!
## Credits
This library was migrated from [ocramius/instantiator](https://github.com/Ocramius/Instantiator), which
has been donated to the doctrine organization, and which is now deprecated in favour of this package.

View File

@ -0,0 +1,45 @@
{
"name": "doctrine/instantiator",
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"type": "library",
"license": "MIT",
"homepage": "https://github.com/doctrine/instantiator",
"keywords": [
"instantiate",
"constructor"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "http://ocramius.github.com/"
}
],
"require": {
"php": ">=5.3,<8.0-DEV"
},
"require-dev": {
"ext-phar": "*",
"ext-pdo": "*",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0",
"athletic/athletic": "~0.1.8"
},
"autoload": {
"psr-4": {
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"autoload-dev": {
"psr-0": {
"DoctrineTest\\InstantiatorPerformance\\": "tests",
"DoctrineTest\\InstantiatorTest\\": "tests",
"DoctrineTest\\InstantiatorTestAsset\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
}

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ruleset
name="Instantiator rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
>
<rule ref="rulesets/cleancode.xml">
<!-- static access is used for caching purposes -->
<exclude name="StaticAccess"/>
</rule>
<rule ref="rulesets/codesize.xml"/>
<rule ref="rulesets/controversial.xml"/>
<rule ref="rulesets/design.xml"/>
<rule ref="rulesets/naming.xml"/>
<rule ref="rulesets/unusedcode.xml"/>
<rule
name="NPathComplexity"
message="The {0} {1}() has an NPath complexity of {2}. The configured NPath complexity threshold is {3}."
class="PHP_PMD_Rule_Design_NpathComplexity"
>
<properties>
<property name="minimum" description="The npath reporting threshold" value="10"/>
</properties>
</rule>
</ruleset>

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<phpunit
bootstrap="./vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
stopOnFailure="false"
processIsolation="false"
backupGlobals="false"
syntaxCheck="true"
>
<testsuite name="Doctrine\Instantiator tests">
<directory>./tests/DoctrineTest/InstantiatorTest</directory>
</testsuite>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>

View File

@ -0,0 +1,29 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Instantiator\Exception;
/**
* Base exception marker interface for the instantiator component
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
interface ExceptionInterface
{
}

View File

@ -0,0 +1,62 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Instantiator\Exception;
use InvalidArgumentException as BaseInvalidArgumentException;
use ReflectionClass;
/**
* Exception for invalid arguments provided to the instantiator
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class InvalidArgumentException extends BaseInvalidArgumentException implements ExceptionInterface
{
/**
* @param string $className
*
* @return self
*/
public static function fromNonExistingClass($className)
{
if (interface_exists($className)) {
return new self(sprintf('The provided type "%s" is an interface, and can not be instantiated', $className));
}
if (PHP_VERSION_ID >= 50400 && trait_exists($className)) {
return new self(sprintf('The provided type "%s" is a trait, and can not be instantiated', $className));
}
return new self(sprintf('The provided class "%s" does not exist', $className));
}
/**
* @param ReflectionClass $reflectionClass
*
* @return self
*/
public static function fromAbstractClass(ReflectionClass $reflectionClass)
{
return new self(sprintf(
'The provided class "%s" is abstract, and can not be instantiated',
$reflectionClass->getName()
));
}
}

View File

@ -0,0 +1,79 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Instantiator\Exception;
use Exception;
use ReflectionClass;
use UnexpectedValueException as BaseUnexpectedValueException;
/**
* Exception for given parameters causing invalid/unexpected state on instantiation
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class UnexpectedValueException extends BaseUnexpectedValueException implements ExceptionInterface
{
/**
* @param ReflectionClass $reflectionClass
* @param Exception $exception
*
* @return self
*/
public static function fromSerializationTriggeredException(ReflectionClass $reflectionClass, Exception $exception)
{
return new self(
sprintf(
'An exception was raised while trying to instantiate an instance of "%s" via un-serialization',
$reflectionClass->getName()
),
0,
$exception
);
}
/**
* @param ReflectionClass $reflectionClass
* @param string $errorString
* @param int $errorCode
* @param string $errorFile
* @param int $errorLine
*
* @return UnexpectedValueException
*/
public static function fromUncleanUnSerialization(
ReflectionClass $reflectionClass,
$errorString,
$errorCode,
$errorFile,
$errorLine
) {
return new self(
sprintf(
'Could not produce an instance of "%s" via un-serialization, since an error was triggered '
. 'in file "%s" at line "%d"',
$reflectionClass->getName(),
$errorFile,
$errorLine
),
0,
new Exception($errorString, $errorCode)
);
}
}

View File

@ -0,0 +1,273 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Instantiator;
use Closure;
use Doctrine\Instantiator\Exception\InvalidArgumentException;
use Doctrine\Instantiator\Exception\UnexpectedValueException;
use Exception;
use ReflectionClass;
/**
* {@inheritDoc}
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
final class Instantiator implements InstantiatorInterface
{
/**
* Markers used internally by PHP to define whether {@see \unserialize} should invoke
* the method {@see \Serializable::unserialize()} when dealing with classes implementing
* the {@see \Serializable} interface.
*/
const SERIALIZATION_FORMAT_USE_UNSERIALIZER = 'C';
const SERIALIZATION_FORMAT_AVOID_UNSERIALIZER = 'O';
/**
* @var \Closure[] of {@see \Closure} instances used to instantiate specific classes
*/
private static $cachedInstantiators = array();
/**
* @var object[] of objects that can directly be cloned
*/
private static $cachedCloneables = array();
/**
* {@inheritDoc}
*/
public function instantiate($className)
{
if (isset(self::$cachedCloneables[$className])) {
return clone self::$cachedCloneables[$className];
}
if (isset(self::$cachedInstantiators[$className])) {
$factory = self::$cachedInstantiators[$className];
return $factory();
}
return $this->buildAndCacheFromFactory($className);
}
/**
* Builds the requested object and caches it in static properties for performance
*
* @param string $className
*
* @return object
*/
private function buildAndCacheFromFactory($className)
{
$factory = self::$cachedInstantiators[$className] = $this->buildFactory($className);
$instance = $factory();
if ($this->isSafeToClone(new ReflectionClass($instance))) {
self::$cachedCloneables[$className] = clone $instance;
}
return $instance;
}
/**
* Builds a {@see \Closure} capable of instantiating the given $className without
* invoking its constructor.
*
* @param string $className
*
* @return Closure
*/
private function buildFactory($className)
{
$reflectionClass = $this->getReflectionClass($className);
if ($this->isInstantiableViaReflection($reflectionClass)) {
return function () use ($reflectionClass) {
return $reflectionClass->newInstanceWithoutConstructor();
};
}
$serializedString = sprintf(
'%s:%d:"%s":0:{}',
$this->getSerializationFormat($reflectionClass),
strlen($className),
$className
);
$this->checkIfUnSerializationIsSupported($reflectionClass, $serializedString);
return function () use ($serializedString) {
return unserialize($serializedString);
};
}
/**
* @param string $className
*
* @return ReflectionClass
*
* @throws InvalidArgumentException
*/
private function getReflectionClass($className)
{
if (! class_exists($className)) {
throw InvalidArgumentException::fromNonExistingClass($className);
}
$reflection = new ReflectionClass($className);
if ($reflection->isAbstract()) {
throw InvalidArgumentException::fromAbstractClass($reflection);
}
return $reflection;
}
/**
* @param ReflectionClass $reflectionClass
* @param string $serializedString
*
* @throws UnexpectedValueException
*
* @return void
*/
private function checkIfUnSerializationIsSupported(ReflectionClass $reflectionClass, $serializedString)
{
set_error_handler(function ($code, $message, $file, $line) use ($reflectionClass, & $error) {
$error = UnexpectedValueException::fromUncleanUnSerialization(
$reflectionClass,
$message,
$code,
$file,
$line
);
});
$this->attemptInstantiationViaUnSerialization($reflectionClass, $serializedString);
restore_error_handler();
if ($error) {
throw $error;
}
}
/**
* @param ReflectionClass $reflectionClass
* @param string $serializedString
*
* @throws UnexpectedValueException
*
* @return void
*/
private function attemptInstantiationViaUnSerialization(ReflectionClass $reflectionClass, $serializedString)
{
try {
unserialize($serializedString);
} catch (Exception $exception) {
restore_error_handler();
throw UnexpectedValueException::fromSerializationTriggeredException($reflectionClass, $exception);
}
}
/**
* @param ReflectionClass $reflectionClass
*
* @return bool
*/
private function isInstantiableViaReflection(ReflectionClass $reflectionClass)
{
if (\PHP_VERSION_ID >= 50600) {
return ! ($this->hasInternalAncestors($reflectionClass) && $reflectionClass->isFinal());
}
return \PHP_VERSION_ID >= 50400 && ! $this->hasInternalAncestors($reflectionClass);
}
/**
* Verifies whether the given class is to be considered internal
*
* @param ReflectionClass $reflectionClass
*
* @return bool
*/
private function hasInternalAncestors(ReflectionClass $reflectionClass)
{
do {
if ($reflectionClass->isInternal()) {
return true;
}
} while ($reflectionClass = $reflectionClass->getParentClass());
return false;
}
/**
* Verifies if the given PHP version implements the `Serializable` interface serialization
* with an incompatible serialization format. If that's the case, use serialization marker
* "C" instead of "O".
*
* @link http://news.php.net/php.internals/74654
*
* @param ReflectionClass $reflectionClass
*
* @return string the serialization format marker, either self::SERIALIZATION_FORMAT_USE_UNSERIALIZER
* or self::SERIALIZATION_FORMAT_AVOID_UNSERIALIZER
*/
private function getSerializationFormat(ReflectionClass $reflectionClass)
{
if ($this->isPhpVersionWithBrokenSerializationFormat()
&& $reflectionClass->implementsInterface('Serializable')
) {
return self::SERIALIZATION_FORMAT_USE_UNSERIALIZER;
}
return self::SERIALIZATION_FORMAT_AVOID_UNSERIALIZER;
}
/**
* Checks whether the current PHP runtime uses an incompatible serialization format
*
* @return bool
*/
private function isPhpVersionWithBrokenSerializationFormat()
{
return PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513;
}
/**
* Checks if a class is cloneable
*
* @param ReflectionClass $reflection
*
* @return bool
*/
private function isSafeToClone(ReflectionClass $reflection)
{
if (method_exists($reflection, 'isCloneable') && ! $reflection->isCloneable()) {
return false;
}
// not cloneable if it implements `__clone`, as we want to avoid calling it
return ! $reflection->hasMethod('__clone');
}
}

View File

@ -0,0 +1,37 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Instantiator;
/**
* Instantiator provides utility methods to build objects without invoking their constructors
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
interface InstantiatorInterface
{
/**
* @param string $className
*
* @return object
*
* @throws \Doctrine\Instantiator\Exception\ExceptionInterface
*/
public function instantiate($className);
}

View File

@ -0,0 +1,96 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorPerformance;
use Athletic\AthleticEvent;
use Doctrine\Instantiator\Instantiator;
/**
* Performance tests for {@see \Doctrine\Instantiator\Instantiator}
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class InstantiatorPerformanceEvent extends AthleticEvent
{
/**
* @var \Doctrine\Instantiator\Instantiator
*/
private $instantiator;
/**
* {@inheritDoc}
*/
protected function setUp()
{
$this->instantiator = new Instantiator();
$this->instantiator->instantiate(__CLASS__);
$this->instantiator->instantiate('ArrayObject');
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset');
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset');
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset');
}
/**
* @iterations 20000
* @baseline
* @group instantiation
*/
public function testInstantiateSelf()
{
$this->instantiator->instantiate(__CLASS__);
}
/**
* @iterations 20000
* @group instantiation
*/
public function testInstantiateInternalClass()
{
$this->instantiator->instantiate('ArrayObject');
}
/**
* @iterations 20000
* @group instantiation
*/
public function testInstantiateSimpleSerializableAssetClass()
{
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset');
}
/**
* @iterations 20000
* @group instantiation
*/
public function testInstantiateSerializableArrayObjectAsset()
{
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset');
}
/**
* @iterations 20000
* @group instantiation
*/
public function testInstantiateUnCloneableAsset()
{
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset');
}
}

View File

@ -0,0 +1,83 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTest\Exception;
use Doctrine\Instantiator\Exception\InvalidArgumentException;
use PHPUnit_Framework_TestCase;
use ReflectionClass;
/**
* Tests for {@see \Doctrine\Instantiator\Exception\InvalidArgumentException}
*
* @author Marco Pivetta <ocramius@gmail.com>
*
* @covers \Doctrine\Instantiator\Exception\InvalidArgumentException
*/
class InvalidArgumentExceptionTest extends PHPUnit_Framework_TestCase
{
public function testFromNonExistingTypeWithNonExistingClass()
{
$className = __CLASS__ . uniqid();
$exception = InvalidArgumentException::fromNonExistingClass($className);
$this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\InvalidArgumentException', $exception);
$this->assertSame('The provided class "' . $className . '" does not exist', $exception->getMessage());
}
public function testFromNonExistingTypeWithTrait()
{
if (PHP_VERSION_ID < 50400) {
$this->markTestSkipped('Need at least PHP 5.4.0, as this test requires traits support to run');
}
$exception = InvalidArgumentException::fromNonExistingClass(
'DoctrineTest\\InstantiatorTestAsset\\SimpleTraitAsset'
);
$this->assertSame(
'The provided type "DoctrineTest\\InstantiatorTestAsset\\SimpleTraitAsset" is a trait, '
. 'and can not be instantiated',
$exception->getMessage()
);
}
public function testFromNonExistingTypeWithInterface()
{
$exception = InvalidArgumentException::fromNonExistingClass('Doctrine\\Instantiator\\InstantiatorInterface');
$this->assertSame(
'The provided type "Doctrine\\Instantiator\\InstantiatorInterface" is an interface, '
. 'and can not be instantiated',
$exception->getMessage()
);
}
public function testFromAbstractClass()
{
$reflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset');
$exception = InvalidArgumentException::fromAbstractClass($reflection);
$this->assertSame(
'The provided class "DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset" is abstract, '
. 'and can not be instantiated',
$exception->getMessage()
);
}
}

View File

@ -0,0 +1,69 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTest\Exception;
use Doctrine\Instantiator\Exception\UnexpectedValueException;
use Exception;
use PHPUnit_Framework_TestCase;
use ReflectionClass;
/**
* Tests for {@see \Doctrine\Instantiator\Exception\UnexpectedValueException}
*
* @author Marco Pivetta <ocramius@gmail.com>
*
* @covers \Doctrine\Instantiator\Exception\UnexpectedValueException
*/
class UnexpectedValueExceptionTest extends PHPUnit_Framework_TestCase
{
public function testFromSerializationTriggeredException()
{
$reflectionClass = new ReflectionClass($this);
$previous = new Exception();
$exception = UnexpectedValueException::fromSerializationTriggeredException($reflectionClass, $previous);
$this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\UnexpectedValueException', $exception);
$this->assertSame($previous, $exception->getPrevious());
$this->assertSame(
'An exception was raised while trying to instantiate an instance of "'
. __CLASS__ . '" via un-serialization',
$exception->getMessage()
);
}
public function testFromUncleanUnSerialization()
{
$reflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset');
$exception = UnexpectedValueException::fromUncleanUnSerialization($reflection, 'foo', 123, 'bar', 456);
$this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\UnexpectedValueException', $exception);
$this->assertSame(
'Could not produce an instance of "DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset" '
. 'via un-serialization, since an error was triggered in file "bar" at line "456"',
$exception->getMessage()
);
$previous = $exception->getPrevious();
$this->assertInstanceOf('Exception', $previous);
$this->assertSame('foo', $previous->getMessage());
$this->assertSame(123, $previous->getCode());
}
}

View File

@ -0,0 +1,219 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTest;
use Doctrine\Instantiator\Exception\UnexpectedValueException;
use Doctrine\Instantiator\Instantiator;
use PHPUnit_Framework_TestCase;
use ReflectionClass;
/**
* Tests for {@see \Doctrine\Instantiator\Instantiator}
*
* @author Marco Pivetta <ocramius@gmail.com>
*
* @covers \Doctrine\Instantiator\Instantiator
*/
class InstantiatorTest extends PHPUnit_Framework_TestCase
{
/**
* @var Instantiator
*/
private $instantiator;
/**
* {@inheritDoc}
*/
protected function setUp()
{
$this->instantiator = new Instantiator();
}
/**
* @param string $className
*
* @dataProvider getInstantiableClasses
*/
public function testCanInstantiate($className)
{
$this->assertInstanceOf($className, $this->instantiator->instantiate($className));
}
/**
* @param string $className
*
* @dataProvider getInstantiableClasses
*/
public function testInstantiatesSeparateInstances($className)
{
$instance1 = $this->instantiator->instantiate($className);
$instance2 = $this->instantiator->instantiate($className);
$this->assertEquals($instance1, $instance2);
$this->assertNotSame($instance1, $instance2);
}
public function testExceptionOnUnSerializationException()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped(
'As of facebook/hhvm#3432, HHVM has no PDORow, and therefore '
. ' no internal final classes that cannot be instantiated'
);
}
$className = 'DoctrineTest\\InstantiatorTestAsset\\UnserializeExceptionArrayObjectAsset';
if (\PHP_VERSION_ID >= 50600) {
$className = 'PDORow';
}
if (\PHP_VERSION_ID === 50429 || \PHP_VERSION_ID === 50513) {
$className = 'DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset';
}
$this->setExpectedException('Doctrine\\Instantiator\\Exception\\UnexpectedValueException');
$this->instantiator->instantiate($className);
}
public function testNoticeOnUnSerializationException()
{
if (\PHP_VERSION_ID >= 50600) {
$this->markTestSkipped(
'PHP 5.6 supports `ReflectionClass#newInstanceWithoutConstructor()` for some internal classes'
);
}
try {
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset');
$this->fail('No exception was raised');
} catch (UnexpectedValueException $exception) {
$wakeUpNoticesReflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset');
$previous = $exception->getPrevious();
$this->assertInstanceOf('Exception', $previous);
// in PHP 5.4.29 and PHP 5.5.13, this case is not a notice, but an exception being thrown
if (! (\PHP_VERSION_ID === 50429 || \PHP_VERSION_ID === 50513)) {
$this->assertSame(
'Could not produce an instance of "DoctrineTest\\InstantiatorTestAsset\WakeUpNoticesAsset" '
. 'via un-serialization, since an error was triggered in file "'
. $wakeUpNoticesReflection->getFileName() . '" at line "36"',
$exception->getMessage()
);
$this->assertSame('Something went bananas while un-serializing this instance', $previous->getMessage());
$this->assertSame(\E_USER_NOTICE, $previous->getCode());
}
}
}
/**
* @param string $invalidClassName
*
* @dataProvider getInvalidClassNames
*/
public function testInstantiationFromNonExistingClass($invalidClassName)
{
$this->setExpectedException('Doctrine\\Instantiator\\Exception\\InvalidArgumentException');
$this->instantiator->instantiate($invalidClassName);
}
public function testInstancesAreNotCloned()
{
$className = 'TemporaryClass' . uniqid();
eval('namespace ' . __NAMESPACE__ . '; class ' . $className . '{}');
$instance = $this->instantiator->instantiate(__NAMESPACE__ . '\\' . $className);
$instance->foo = 'bar';
$instance2 = $this->instantiator->instantiate(__NAMESPACE__ . '\\' . $className);
$this->assertObjectNotHasAttribute('foo', $instance2);
}
/**
* Provides a list of instantiable classes (existing)
*
* @return string[][]
*/
public function getInstantiableClasses()
{
$classes = array(
array('stdClass'),
array(__CLASS__),
array('Doctrine\\Instantiator\\Instantiator'),
array('Exception'),
array('PharException'),
array('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset'),
array('DoctrineTest\\InstantiatorTestAsset\\ExceptionAsset'),
array('DoctrineTest\\InstantiatorTestAsset\\FinalExceptionAsset'),
array('DoctrineTest\\InstantiatorTestAsset\\PharExceptionAsset'),
array('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset'),
array('DoctrineTest\\InstantiatorTestAsset\\XMLReaderAsset'),
);
if (\PHP_VERSION_ID === 50429 || \PHP_VERSION_ID === 50513) {
return $classes;
}
$classes = array_merge(
$classes,
array(
array('PharException'),
array('ArrayObject'),
array('DoctrineTest\\InstantiatorTestAsset\\ArrayObjectAsset'),
array('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset'),
)
);
if (\PHP_VERSION_ID >= 50600) {
$classes[] = array('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset');
$classes[] = array('DoctrineTest\\InstantiatorTestAsset\\UnserializeExceptionArrayObjectAsset');
}
return $classes;
}
/**
* Provides a list of instantiable classes (existing)
*
* @return string[][]
*/
public function getInvalidClassNames()
{
$classNames = array(
array(__CLASS__ . uniqid()),
array('Doctrine\\Instantiator\\InstantiatorInterface'),
array('DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset'),
);
if (\PHP_VERSION_ID >= 50400) {
$classNames[] = array('DoctrineTest\\InstantiatorTestAsset\\SimpleTraitAsset');
}
return $classNames;
}
}

View File

@ -0,0 +1,29 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
/**
* A simple asset for an abstract class
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
abstract class AbstractClassAsset
{
}

View File

@ -0,0 +1,41 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use ArrayObject;
use BadMethodCallException;
/**
* Test asset that extends an internal PHP class
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class ArrayObjectAsset extends ArrayObject
{
/**
* Constructor - should not be called
*
* @throws BadMethodCallException
*/
public function __construct()
{
throw new BadMethodCallException('Not supposed to be called!');
}
}

View File

@ -0,0 +1,41 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use BadMethodCallException;
use Exception;
/**
* Test asset that extends an internal PHP base exception
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class ExceptionAsset extends Exception
{
/**
* Constructor - should not be called
*
* @throws BadMethodCallException
*/
public function __construct()
{
throw new BadMethodCallException('Not supposed to be called!');
}
}

View File

@ -0,0 +1,41 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use BadMethodCallException;
use Exception;
/**
* Test asset that extends an internal PHP base exception
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
final class FinalExceptionAsset extends Exception
{
/**
* Constructor - should not be called
*
* @throws BadMethodCallException
*/
public function __construct()
{
throw new BadMethodCallException('Not supposed to be called!');
}
}

View File

@ -0,0 +1,41 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use BadMethodCallException;
use Phar;
/**
* Test asset that extends an internal PHP class
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class PharAsset extends Phar
{
/**
* Constructor - should not be called
*
* @throws BadMethodCallException
*/
public function __construct()
{
throw new BadMethodCallException('Not supposed to be called!');
}
}

View File

@ -0,0 +1,44 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use BadMethodCallException;
use PharException;
/**
* Test asset that extends an internal PHP class
* This class should be serializable without problems
* and without getting the "Erroneous data format for unserializing"
* error
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class PharExceptionAsset extends PharException
{
/**
* Constructor - should not be called
*
* @throws BadMethodCallException
*/
public function __construct()
{
throw new BadMethodCallException('Not supposed to be called!');
}
}

View File

@ -0,0 +1,62 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use ArrayObject;
use BadMethodCallException;
use Serializable;
/**
* Serializable test asset that also extends an internal class
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class SerializableArrayObjectAsset extends ArrayObject implements Serializable
{
/**
* Constructor - should not be called
*
* @throws BadMethodCallException
*/
public function __construct()
{
throw new BadMethodCallException('Not supposed to be called!');
}
/**
* {@inheritDoc}
*/
public function serialize()
{
return '';
}
/**
* {@inheritDoc}
*
* Should not be called
*
* @throws BadMethodCallException
*/
public function unserialize($serialized)
{
throw new BadMethodCallException('Not supposed to be called!');
}
}

View File

@ -0,0 +1,61 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use BadMethodCallException;
use Serializable;
/**
* Base serializable test asset
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class SimpleSerializableAsset implements Serializable
{
/**
* Constructor - should not be called
*
* @throws BadMethodCallException
*/
public function __construct()
{
throw new BadMethodCallException('Not supposed to be called!');
}
/**
* {@inheritDoc}
*/
public function serialize()
{
return '';
}
/**
* {@inheritDoc}
*
* Should not be called
*
* @throws BadMethodCallException
*/
public function unserialize($serialized)
{
throw new BadMethodCallException('Not supposed to be called!');
}
}

View File

@ -0,0 +1,29 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
/**
* A simple trait with no attached logic
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
trait SimpleTraitAsset
{
}

View File

@ -0,0 +1,50 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use BadMethodCallException;
/**
* Base un-cloneable asset
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class UnCloneableAsset
{
/**
* Constructor - should not be called
*
* @throws BadMethodCallException
*/
public function __construct()
{
throw new BadMethodCallException('Not supposed to be called!');
}
/**
* Magic `__clone` - should not be invoked
*
* @throws BadMethodCallException
*/
public function __clone()
{
throw new BadMethodCallException('Not supposed to be called!');
}
}

View File

@ -0,0 +1,39 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use ArrayObject;
use BadMethodCallException;
/**
* A simple asset for an abstract class
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class UnserializeExceptionArrayObjectAsset extends ArrayObject
{
/**
* {@inheritDoc}
*/
public function __wakeup()
{
throw new BadMethodCallException();
}
}

View File

@ -0,0 +1,38 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use ArrayObject;
/**
* A simple asset for an abstract class
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class WakeUpNoticesAsset extends ArrayObject
{
/**
* Wakeup method called after un-serialization
*/
public function __wakeup()
{
trigger_error('Something went bananas while un-serializing this instance');
}
}

View File

@ -0,0 +1,41 @@
<?php
/*
* 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace DoctrineTest\InstantiatorTestAsset;
use BadMethodCallException;
use XMLReader;
/**
* Test asset that extends an internal PHP class
*
* @author Dave Marshall <dave@atst.io>
*/
class XMLReaderAsset extends XMLReader
{
/**
* Constructor - should not be called
*
* @throws BadMethodCallException
*/
public function __construct()
{
throw new BadMethodCallException('Not supposed to be called!');
}
}

2
vendor/fzaninotto/faker/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
vendor
composer.lock

17
vendor/fzaninotto/faker/.travis.yml vendored Normal file
View File

@ -0,0 +1,17 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
sudo: false
before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source --dev
script: make sniff test

295
vendor/fzaninotto/faker/CHANGELOG.md vendored Normal file
View File

@ -0,0 +1,295 @@
CHANGELOG
=========
To be released, v1.5.0
----------------------
* Added ability to print custom text on the images fetched by the Image provider [\#583](https://github.com/fzaninotto/Faker/pull/583) ([fzaninotto](https://github.com/fzaninotto))
* Fixed typos in Preuvian (es\_PE) Person provider [\#581](https://github.com/fzaninotto/Faker/pull/581) [\#580](https://github.com/fzaninotto/Faker/pull/580) ([ysramirez](https://github.com/ysramirez))
* Added instructions for installing with composer to readme.md [\#572](https://github.com/fzaninotto/Faker/pull/572) ([totophe](https://github.com/totophe))
* Added Kazakh (kk\_KZ) locale [\#569](https://github.com/fzaninotto/Faker/pull/569) ([YerlenZhubangaliyev](https://github.com/YerlenZhubangaliyev))
* Added Korean (ko\_KR) locale [\#566](https://github.com/fzaninotto/Faker/pull/566) ([pearlc](https://github.com/pearlc))
* Fixed file provider to ignore unreadable and special files [\#565](https://github.com/fzaninotto/Faker/pull/565) ([svrnm](https://github.com/svrnm))
* Fixed Dutch (nl\_NL) Address and Person providers [\#560](https://github.com/fzaninotto/Faker/pull/560) ([killerog](https://github.com/killerog))
* Fixed Dutch (nl\_NL) Person provider [\#559](https://github.com/fzaninotto/Faker/pull/559) ([pauledenburg](https://github.com/pauledenburg))
* Added Russian (ru\_RU) Bank names provider [\#553](https://github.com/fzaninotto/Faker/pull/553) ([wizardjedi](https://github.com/wizardjedi))
* Added mobile phone function in French (fr\_FR) provider [\#552](https://github.com/fzaninotto/Faker/pull/552) ([kletellier](https://github.com/kletellier))
* Added phpdoc for new magic methods in Generator to help IntelliSense completion [\#550](https://github.com/fzaninotto/Faker/pull/550) ([stof](https://github.com/stof))
* Fixed File provider bug 'The first argument to copy() function cannot be a directory' [\#547](https://github.com/fzaninotto/Faker/pull/547) ([svrnm](https://github.com/svrnm))
* Added new Brazilian (pt\_BR) Providers [\#545](https://github.com/fzaninotto/Faker/pull/545) ([igorsantos07](https://github.com/igorsantos07))
* Fixed ability to seed the generator [\#543](https://github.com/fzaninotto/Faker/pull/543) ([schmengler](https://github.com/schmengler))
* Added streetAddress formatter to Russian (ru\_RU) provider [\#542](https://github.com/fzaninotto/Faker/pull/542) ([ZAYEC77](https://github.com/ZAYEC77))
* Fixed Internet provider warning "Could not create transliterator"* [\#541](https://github.com/fzaninotto/Faker/pull/541) ([fonsecas72](https://github.com/fonsecas72))
* Fixed Spanish for Argentina (es\_AR) Address provider [\#540](https://github.com/fzaninotto/Faker/pull/540) ([ivanmirson](https://github.com/ivanmirson))
* Fixed region names in French for Belgium (fr\_BE) address provider [\#536](https://github.com/fzaninotto/Faker/pull/536) ([miclf](https://github.com/miclf))
* Fixed broken Doctrine2 link in README [\#534](https://github.com/fzaninotto/Faker/pull/534) ([JonathanKryza](https://github.com/JonathanKryza))
* Added link to faker-context Behat extension in readme [\#532](https://github.com/fzaninotto/Faker/pull/532) ([denheck](https://github.com/denheck))
* Added PHP 7.0 nightly to Travis build targets [\#525](https://github.com/fzaninotto/Faker/pull/525) ([TomasVotruba](https://github.com/TomasVotruba))
* Added Dutch (nl\_NL) color names [\#523](https://github.com/fzaninotto/Faker/pull/523) ([belendel](https://github.com/belendel))
* Fixed Chinese (zh\_CN) Address provider (remove Taipei) [\#522](https://github.com/fzaninotto/Faker/pull/522) ([asika32764](https://github.com/asika32764))
* Fixed phonenumber formats in Dutch (nl\_NL) PhoneNumber provider [\#521](https://github.com/fzaninotto/Faker/pull/521) ([SpaceK33z](https://github.com/SpaceK33z))
* Fixed Russian (ru\_RU) Address provider [\#518](https://github.com/fzaninotto/Faker/pull/518) ([glagola](https://github.com/glagola))
* Added Italian (it\_IT) Text provider [\#517](https://github.com/fzaninotto/Faker/pull/517) ([endelwar](https://github.com/endelwar))
* Added Norwegian (no\_NO) locale [\#515](https://github.com/fzaninotto/Faker/pull/515) ([phaza](https://github.com/phaza))
* Added VAT number to Bulgarian (bg\_BG) Payment provider [\#512](https://github.com/fzaninotto/Faker/pull/512) ([ronanguilloux](https://github.com/ronanguilloux))
* Fixed UserAgent provider outdated user agents [\#511](https://github.com/fzaninotto/Faker/pull/511) ([ajbdev](https://github.com/ajbdev))
* Fixed `image()` formatter to make it work with temp dir of any (decent) OS [\#507](https://github.com/fzaninotto/Faker/pull/507) ([ronanguilloux](https://github.com/ronanguilloux))
* Added Persian (fa\_IR) locale [\#500](https://github.com/fzaninotto/Faker/pull/500) ([zoli](https://github.com/zoli))
* Added Currency Code formatter [\#497](https://github.com/fzaninotto/Faker/pull/497) ([stelgenhof](https://github.com/stelgenhof))
* Added VAT number to Belgium (be_BE) Payment provider [\#495](https://github.com/fzaninotto/Faker/pull/495) ([ronanguilloux](https://github.com/ronanguilloux))
* Fixed `imageUrl` formatter bug where it would always return the same image [\#494](https://github.com/fzaninotto/Faker/pull/494) ([fzaninotto](https://github.com/fzaninotto))
* Added more Indonesian (id\_ID) providers [\#493](https://github.com/fzaninotto/Faker/pull/493) ([deerawan](https://github.com/deerawan))
* Added Indonesian (id\_ID) locale [\#492](https://github.com/fzaninotto/Faker/pull/492) ([stoutZero](https://github.com/stoutZero))
* Fixed unique generator performance [\#491](https://github.com/fzaninotto/Faker/pull/491) ([ikwattro](https://github.com/ikwattro))
* Added transliterator to `email` and `username` [\#490](https://github.com/fzaninotto/Faker/pull/490) ([fzaninotto](https://github.com/fzaninotto))
* Added Hungarian (hu\_HU) Text provider [\#486](https://github.com/fzaninotto/Faker/pull/486) ([lintaba](https://github.com/lintaba))
* Fixed CakePHP Entity Popolator (some cases where no entities prev. inserted) [\#483](https://github.com/fzaninotto/Faker/pull/483) ([jadb](https://github.com/jadb))
* Added Color and DateTime Turkish (tr\_TR) Providers [\#481](https://github.com/fzaninotto/Faker/pull/481) ([behramcelen](https://github.com/behramcelen))
* Added Latvian (lv\_LV) `personalIdentityNumber` formatter [\#472](https://github.com/fzaninotto/Faker/pull/472) ([MatissJanis](https://github.com/MatissJanis))
* Added VAT number to Austrian (at_AT) Payment provider [\#470](https://github.com/fzaninotto/Faker/pull/470) ([ronanguilloux](https://github.com/ronanguilloux))
* Fixed missing @return phpDoc in Payment provider [\#469](https://github.com/fzaninotto/Faker/pull/469) ([ronanguilloux](https://github.com/ronanguilloux))
* Added SWIFT/BIC payment type formatter to the Payment provider [\#465](https://github.com/fzaninotto/Faker/pull/465) ([ronanguilloux](https://github.com/ronanguilloux))
* Fixed small typo in Base provider exception [\#460](https://github.com/fzaninotto/Faker/pull/460) ([miclf](https://github.com/miclf))
* Added Georgian (ka\_Ge) locale [\#457](https://github.com/fzaninotto/Faker/pull/457) ([lperto](https://github.com/lperto))
* Added PSR-4 Autoloading [\#455](https://github.com/fzaninotto/Faker/pull/455) ([GrahamCampbell](https://github.com/GrahamCampbell))
* Added Uganda (en_UG) locale [\#454](https://github.com/fzaninotto/Faker/pull/454) ([tharoldD](https://github.com/tharoldD))
* Added `regexify` formatter, generating a random string based on a regular expression [\#453](https://github.com/fzaninotto/Faker/pull/453) ([fzaninotto](https://github.com/fzaninotto))
* Added shuffle formatter, to shuffle an array or a string [\#452](https://github.com/fzaninotto/Faker/pull/452) ([fzaninotto](https://github.com/fzaninotto))
* Added ISBN-10 & ISBN-13 codes formatters to Barcode provider [\#451](https://github.com/fzaninotto/Faker/pull/451) ([gietos](https://github.com/gietos))
* Fixed Russian (ru\_RU) middle names (different for different genders) [\#450](https://github.com/fzaninotto/Faker/pull/450) ([gietos](https://github.com/gietos))
* Fixed Ukranian (uk\_UA) Person provider [\#448](https://github.com/fzaninotto/Faker/pull/448) ([aivus](https://github.com/aivus))
* Added Vietnamese (vi\_VN) locale [\#447](https://github.com/fzaninotto/Faker/pull/447) ([huy95](https://github.com/huy95))
* Added type hint to the Documentor constructor [\#446](https://github.com/fzaninotto/Faker/pull/446) ([JeroenDeDauw](https://github.com/JeroenDeDauw))
* Fixed Russian (ru\_RU) Person provider (joined names) [\#445](https://github.com/fzaninotto/Faker/pull/445) ([aivus](https://github.com/aivus))
* Added English (en\_GB) `mobileNumber` methods [\#438](https://github.com/fzaninotto/Faker/pull/438) ([daveblake](https://github.com/daveblake))
* Added Traditional Chinese (zh\_TW) Realtext provider [\#434](https://github.com/fzaninotto/Faker/pull/434) ([tzhuan](https://github.com/tzhuan))
* Fixed first name in Spanish for Argentina (es\_AR) Person provider [\#433](https://github.com/fzaninotto/Faker/pull/433) ([fzaninotto](https://github.com/fzaninotto))
* Fixed Canadian (en_CA) state abbreviation for Nunavut [\#430](https://github.com/fzaninotto/Faker/pull/430) ([julien-c](https://github.com/julien-c))
* Added CakePHP ORM entity populator [\#428](https://github.com/fzaninotto/Faker/pull/428) ([jadb](https://github.com/jadb))
* Added Traditional Chinese (zh\_TW) locale [\#427](https://github.com/fzaninotto/Faker/pull/427) ([tzhuan](https://github.com/tzhuan))
* Fixed typo in Doctrine Populator phpDoc [\#425](https://github.com/fzaninotto/Faker/pull/425) ([ihsanudin](https://github.com/ihsanudin))
* Added Chinese (zh_CN) Internet provider [\#424](https://github.com/fzaninotto/Faker/pull/424) ([Lisso-Me](https://github.com/Lisso-Me))
* Added Country ISO 3166-1 alpha-3 code to the Miscellaneous provider[\#422](https://github.com/fzaninotto/Faker/pull/422) ([gido](https://github.com/gido))
* Added English (en\_GB) Person provider [\#421](https://github.com/fzaninotto/Faker/pull/421) ([AlexCutts](https://github.com/AlexCutts))
* Added missing tests for the Color Provider [\#420](https://github.com/fzaninotto/Faker/pull/420) ([bessl](https://github.com/bessl))
* Added Nepali (ne\_NP) locale [\#419](https://github.com/fzaninotto/Faker/pull/419) ([ankitpokhrel](https://github.com/ankitpokhrel))
* Fixed latitude and longitude formatters bug (numeric value out of range for 32bits) [\#416](https://github.com/fzaninotto/Faker/pull/416) ([fzaninotto](https://github.com/fzaninotto))
* Added a dedicated calculator Luhn calculator service [\#414](https://github.com/fzaninotto/Faker/pull/414) ([fzaninotto](https://github.com/fzaninotto))
* Fixed Russian (ru_RU) Person provider (removed lowercase duplications) [\#413](https://github.com/fzaninotto/Faker/pull/413) ([Ragazzo](https://github.com/Ragazzo))
* Fixed barcode formatter (improved speed, added tests) [\#412](https://github.com/fzaninotto/Faker/pull/412) ([fzaninotto](https://github.com/fzaninotto))
* Added ipv4 and barcode formatters tests [\#410](https://github.com/fzaninotto/Faker/pull/410) ([bessl](https://github.com/bessl))
* Fixed typos in various comments blocks [\#409](https://github.com/fzaninotto/Faker/pull/409) ([bessl](https://github.com/bessl))
* Fixed InternetTest (replaced regex with PHP filter) [\#406](https://github.com/fzaninotto/Faker/pull/406) ([bessl](https://github.com/bessl))
* Added password formatter to the Internet provider[\#402](https://github.com/fzaninotto/Faker/pull/402) ([fzaninotto](https://github.com/fzaninotto))
* Added Company and Internet Austrian (de\_AT) Providers [\#400](https://github.com/fzaninotto/Faker/pull/400) ([bessl](https://github.com/bessl))
* Added third-party libraries section in README [\#399](https://github.com/fzaninotto/Faker/pull/399) ([fzaninotto](https://github.com/fzaninotto))
* Added Spanish for Venezuela (es\_VE) locale [\#398](https://github.com/fzaninotto/Faker/pull/398) ([DIOHz0r](https://github.com/DIOHz0r))
* Added PhoneNumber Autrian (de\_AT) Provider, and missing test for the 'locale' method. [\#395](https://github.com/fzaninotto/Faker/pull/395) ([bessl](https://github.com/bessl))
* Removed wrongly localized Lorem provider [\#394](https://github.com/fzaninotto/Faker/pull/394) ([fzaninotto](https://github.com/fzaninotto))
* Fixed Miscellaneous provider (made the `locale` formatter static) [\#390](https://github.com/fzaninotto/Faker/pull/390) ([bessl](https://github.com/bessl))
* Added a unit test file for the Miscellaneous Provider [\#389](https://github.com/fzaninotto/Faker/pull/389) ([bessl](https://github.com/bessl))
* Added warning in README about using `rand()`` and the seed functions [\#386](https://github.com/fzaninotto/Faker/pull/386) ([paulvalla](https://github.com/paulvalla))
* Fixed French (fr\_FR) Person provider (Uppercased a first name) [\#385](https://github.com/fzaninotto/Faker/pull/385) ([netcarver](https://github.com/netcarver))
* Added Russian (ru\_RU) and Ukrainian (uk\_UA) Text providers [\#383](https://github.com/fzaninotto/Faker/pull/383) ([terion-name](https://github.com/terion-name))
* Added more street prefixes to French (fr\_FR) Address provider [\#381](https://github.com/fzaninotto/Faker/pull/381) ([ronanguilloux](https://github.com/ronanguilloux))
* Added PHP 5.6 to CI targets [\#378](https://github.com/fzaninotto/Faker/pull/378) ([GrahamCampbell](https://github.com/GrahamCampbell))
* Fixed spaces remaining at the end of liine in various files [\#377](https://github.com/fzaninotto/Faker/pull/377) ([GrahamCampbell](https://github.com/GrahamCampbell))
* Fixed UserAgent provider (added space before processor on linux platform) [\#374](https://github.com/fzaninotto/Faker/pull/374) ([TomK](https://github.com/TomK))
* Added Company generator for Russian (ru\_RU) locale [\#371](https://github.com/fzaninotto/Faker/pull/371) ([kix](https://github.com/kix))
* Fixed Russian (ru\_RU) Color provider (uppercase letters) [\#370](https://github.com/fzaninotto/Faker/pull/370) ([semanser](https://github.com/semanser))
* Added more Polish (pl\_PL) phone numbers [\#369](https://github.com/fzaninotto/Faker/pull/369) ([piotrantosik](https://github.com/piotrantosik))
* Fixed Ruby Faker link in readme [\#368](https://github.com/fzaninotto/Faker/pull/368) ([philsturgeon](https://github.com/philsturgeon))
* Added more Japanese (ja\_JP) names in Person provider [\#366](https://github.com/fzaninotto/Faker/pull/366) ([kumamidori](https://github.com/kumamidori))
* Added Slovenian (sl\_SL) locale [\#363](https://github.com/fzaninotto/Faker/pull/363) ([alesf](https://github.com/alesf))
* Fixed German (de\_DE) Person provider (first names) [\#362](https://github.com/fzaninotto/Faker/pull/362) ([mikehaertl](https://github.com/mikehaertl))
* Fixed Ukrainian (uk\_UA) Person providr (there is no such letter "ы" in Ukrainian) [\#359](https://github.com/fzaninotto/Faker/pull/359) ([nazar-pc](https://github.com/nazar-pc))
* Fixed Chinese (zh\_CN) PhoneNumber provider (the length of mobile phone number is 11) [\#358](https://github.com/fzaninotto/Faker/pull/358) ([byan](https://github.com/byan))
* Added Arabic (ar_\JO) Locale [\#357](https://github.com/fzaninotto/Faker/pull/357) ([zrashwani](https://github.com/zrashwani))
* Fixed Czech (cs\_CZ) Person provider (missing lowercase in last name) [\#355](https://github.com/fzaninotto/Faker/pull/355) ([halaxa](https://github.com/halaxa))
* Fixed French for Belgium (fr\_BE) Address Provider (doubled city names) [\#354](https://github.com/fzaninotto/Faker/pull/354) ([miclf](https://github.com/miclf))
* Added Biased Integer Provider [\#332](https://github.com/fzaninotto/Faker/pull/332) ([TimWolla](https://github.com/TimWolla))
* Added Swedish (sv\_SE) locale [\#316](https://github.com/fzaninotto/Faker/pull/316) ([ulrikjohansson](https://github.com/ulrikjohansson))
* Added English for New Zealand (en\_NZ) locale [\#283](https://github.com/fzaninotto/Faker/pull/283) ([JasonMortonNZ](https://github.com/JasonMortonNZ))
* Added mention of external Provider for cron expressions to readme[\#498](https://github.com/fzaninotto/Faker/pull/498) ([swekaj](https://github.com/swekaj))
2014-06-04, v1.4.0
------------------
* Fixed typo in Slovak person names (cinan)
* Added tests for uk_UA providers (serge-kuharev)
* Fixed numerify() performance by making it 30% faster (fzaninotto)
* Added strict option to randomNumber to force number of digits (fzaninotto)
* Fixed randomNumber usage duplicating numberBetween (fzaninotto)
* Fixed address provider for latvian language (MatissJA)
* Added Czech Republic (cs_CZ) address, company, datetime and text providers (Mikulas)
* Fixed da_DK Person provider data containing an 'unnamed' person (tolnem)
* Added slug provider (fzaninotto)
* Fixed IDE insights for new local IP and MAC address providers (hugofonseca)
* Added firstname gender method to all Person providers (csanquer)
* Fixed tr_TR email service, city name, person, and phone number formats (ogunkarakus)
* Fixed US_en state list (fzaninotto)
* Fixed en_US address provider so state abbr are ISO 3166 codes (Garbee)
* Added local IP and MAC address providers (kielabokkie)
* Fixed typo in century list affecting the century provider (fzaninotto)
* Added default value to optional modifier (joshuajabbour)
* Fixed Portuguese phonenumbers have 9 digits (hugofonseca)
* Added fileCopy to File provider to simulate file upload (stefanosala)
* Added pt_PT providers (hugofonseca)
* Fixed dead code in text provider (hugofonseca)
* Fixed IDE insights for magic properties (hugofonseca)
* Added tin (NIF) generator for pt_PT provider (hugofonseca)
* Fixed numberBetween max default value handling (fzaninotto)
* Added pt_PT phone number provider (hugofonseca)
* Fixed PSR-2 standards and add make task to force it on Travis (terite)
* Added new ro_RO Personal Numerical Code (CNP) and phone number providers (avataru)
* Fixed Internet provider for sk_SK locale (cinan)
* Fixed typo in en_ZA Internet provider (bjorntheart)
* Fixed phpdoc for DateTime magic methods (stof)
* Added doc about seeding with maximum timestamp using dateTime formatters (fzaninotto)
* Added Maximum Timestamp option to get always same unix timestamp when using a fixed seed (csanquer)
* Added Montenegrian (me_ME) providers (ognjenm)
* Added ean barcode provider (nineinchnick)
* Added fullPath parameter to Image provider (stefanosala)
* Added more Polish company formats (nineinchnick)
* Added Polish realText provider (nineinchnick)
* Fixed remaining non-seedable random generators (terite)
* Added randomElements provider (terite)
* Added French realText provider (fzaninotto)
* Fixed realText provider bootstrap slowness (fzaninotto)
* Added realText provider for English and German, based on Markov Chains Generator (TimWolla)
* Fixed address format in nl_NL provider (doenietzomoeilijk)
* Fixed potentially offensive word from last name list (joshuajabbour)
* Fixed reamde documentation about the optional modifier (cryode)
* Fixed Image provider and documentor routine (fzaninotto)
* Fixed IDE insights for methods (PedroTroller)
* Fixed missing data in en_US Address provider (Garbee)
* Added Bengali (bn_BD) providers (masnun)
* Fixed warning on test file when short tags are on (bateller)
* Fixed Doctrine populator undefined index warning (dbojdo)
* Added French Canadian (fr_CA) Address and Person providers (marcaube)
* Fixed typo in NullGenerator (mhanson01)
* Fixed Doctrine populator issue with one-to-one nullable relationship (jpetitcolas)
* Added Canadian English (en_CA) address and phone number providers (cviebrock)
* Fixed duplicated Payment example in readme (Garbee)
* Fixed Polish (pl_PL) Person provider data (czogori)
* Added Hungarian (hu_HU) providers (sagikazarmark)
* Added 'kana' (ja_JP) name formatters (kzykhys)
* Added allow_failure for hhvm to travis-ci and test against php 5.5 (toin0u)
2013-12-16, v1.3.0
------------------
* Fixed state generator in Australian (en_AU) provider (sebklaus)
* Fixed IDE insights for locale specific providers (ulrikjohansson)
* Added English (South Africa) (en_ZA) person, address, Internet and phone number providers (dmfaux)
* Fixed integer values overflowing on signed INTEGER columns on Doctrine populator (Thinkscape)
* Fixed spelling error in French (fr_FR) address provider (leihog)
* Added improvements based on SensioLabsInsights analysis
* Fixed Italian (it_IT) email provider (garak)
* Added Spanish (es_ES) Internet provider (eusonlito)
* Added English Philippines (en_PH) address provider (kamote)
* Added Brazilian (pt_BR) email provider data (KennedyTedesco)
* Fixed UK country code (pgscandeias)
* Added Peruvian (es_PE) person, address, phone number, and company providers (cslucano)
* Added Ukrainian (uk_UA) color provider (ruden)
* Fixed Ukrainian (uk_UA) namespace and email translitteration (ruden)
* Added Romanian (Moldova) (ro_MD) person, address, and phone number providers (AlexanderC)
* Added IBAN generator for every currently known locale that uses it (nineinchnick)
* Added Image generation powered by LoremPixel (weotch)
* Fixed missing timezone with dateTimeBetween (baldurrensch)
* Fixed call to undefined method cardType in Payment (WMeldon)
* Added Romanian (ro_RO) address and person providers (calina-c)
* Fixed Doctrine populator to use ObjectManager instead of EntityManagerInterface (mgiustiniani)
* Fixed docblock for Provider\Base::unique() (pschultz)
* Added Payment providers (creditCardType, creditCardNumber, creditCardExpirationDate, creditCardExpirationDateString) (pomaxa)
* Added unique() modifier
* Added IDE insights to allow better intellisense/phpStorm autocompletion (thallisphp)
* Added Polish (pl_PL) address provider, personal identity number and pesel number generator (nineinchnick)
* Added Turkish (tr_TR) address provider, and improved internet provider (hasandz)
* Fixed Propel column number guesser to use signed range of values (gunnarlium)
* Added Greek (el_GR) person, address, and phone number providers (georgeharito)
* Added Austrian (en_AU) address, Internet, and phone number providers (rcuddy)
* Fixed phpDoc in Doctrine Entity populator (rogamoore)
* Added French (fr_FR) phone number formats (vchabot)
* Added optional() modifier (weotch)
* Fixed typo in the Person provider documentation (jtreminio)
* Fixed Russian (ru_RU) person format (alexshadow007)
* Added Japanese (ja_JP) person, address, Internet, phone number, and company providers (kumamidori)
* Added color providers, driver license and passport number formats for the ru_RU locale (pomaxa)
* Added Latvian (lv_LV) person, address, Internet, and phone number providers (pomaxa)
* Added Brazilian (pt_BR) Internet provider (vjnrv)
* Added more Czech (cs_CZ) lastnames (petrkle)
* Added Chinese Simplified (zh_CN) person, address, Internet, and phone number providers (tlikai)
* Fixed Typos (pborelli)
* Added Color provider with hexColor, rgbColor, rgbColorAsArray, rgbCssColor, safeColorName, and colorName formatters (lsv)
* Added support for associative arrays in `randomElement` (aRn0D)
2013-06-09, v1.2.0
------------------
* Added new provider for fr_BE locale (jflefebvre)
* Updated locale provider to use a static locale list (spawn-guy)
* Fixed invalid UTF-8 sequence in domain provider with the Bulgarian provider (Dynom)
* Fixed the nl_NL Person provider (Dynom)
* Removed all requires and added the autoload definition to composer (Dynom)
* Fixed encoding problems in nl_NL Address provider (Dynom)
* Added icelandic provider (is_IS) (birkir)
* Added en_CA address and phone numbers (cviebrock)
* Updated safeEmail provider to be really safe (TimWolla)
* Documented alternative randomNumber usage (Seldaek)
* Added basic file provider (anroots)
* Fixed use of fourth argument on Doctrine addEntity (ecentinela)
* Added nl_BE provider (wimvds)
* Added Random Float provider (csanquer)
* Fixed bug in Faker\ORM\Doctrine\Populator (mmf-amarcos)
* Updated ru_RU provider (rmrevin)
* Added safe email domain provider (csanquer)
* Fixed latitude provider (rumpl)
* Fixed unpredictability of fake data generated by Faker\Provider\Base::numberBetween() (goatherd)
* Added uuid provider (goatherd)
* Added possibility to call methods on Doctrine entities, possibility to generate unique id (nenadalm)
* Fixed prefixes typos in 'pl_PL' Person provider (krymen)
* Added more fake data to the Ukraininan providers (lysenkobv)
* Added more fake data to the Italian providers (EmanueleMinotto)
* Fixed spaces appearing in generated emails (alchy58)
* Added Armenian (hy_AM) provider (artash)
* Added Generation of valid SIREN & SIRET codes to French providers (alexsegura)
* Added Dutch (nl_NL) provider (WouterJ)
* Fixed missing typehint in Base::__construct() (benja-M-1)
* Fixed typo in README (benja-M-1)
* Added Ukrainian (ua_UA) provider (rsvasilyev)
* Added Turkish (tr_TR) Provider (faridmovsumov)
* Fixed executable bit in some PHP files (siwinski)
* Added Brazilian Portuguese (pt_BR) provider (oliveiraev)
* Added Spanish (es_ES) provider (ivannis)
* Fixed Doctrine populator to allow for the population of entity data that has associations to other entities (afishnamedsquish)
* Added Danish (da_DK) providers (toin0u)
* Cleaned up whitespaces (toin0u)
* Fixed utf-8 bug with lowercase generators (toin0u)
* Fixed composer.json (Seldaek)
* Fixed bug in Doctrine EntityPopulator (beberlei)
* Added Finnish (fi_FI) provider (drodil)
2012-10-29, v1.1.0
------------------
* Updated text provider to return paragraphs as a string instead of array. Great for populating markdown textarea fields (Seldaek)
* Updated dateTimeBetween to accept DateTime instances (Seldaek)
* Added random number generator between a and b, simply like rand() (Seldaek)
* Fixed spaces in generated emails (blaugueux)
* Fixed Person provider in Russian locale (Isamashii)
* Added new UserAgent provider (blaugueux)
* Added locale generator to Miscellaneous provider (blaugueux)
* Added timezone generator to DateTime provider (blaugueux)
* Added new generators to French Address providers (departments, regions) (geoffrey-brier)
* Added new generators to French Company provider (catch phrase, SIREN, and SIRET numbers) (geoffrey-brier)
* Added state generator to German Address provider (Powerhamster)
* Added Slovak provider (bazo)
* Added latitude and longitude formatters to Address provider (fixe)
* Added Serbian provider (umpirsky)
2012-07-10, v1.0.0
-----------------
* Initial Version

21
vendor/fzaninotto/faker/CONTRIBUTING.md vendored Normal file
View File

@ -0,0 +1,21 @@
Contributing
============
If you've written a new formatter, adapted Faker to a new locale, or fixed a bug, your contribution is welcome!
Before proposing a pull request, check the following:
* Your code should follow the [PSR-2 coding standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) (and use [php-cs-fixer](https://github.com/fabpot/PHP-CS-Fixer) to fix inconsistencies).
* Unit tests should still pass after your patch
* As much as possible, add unit tests for your code
* If you add new providers (or new locales) and that they embed a lot of data for random generation (e.g. first names in a new language), please add a link to the reference you used for this list (example [in the ru_RU locale](https://github.com/fzaninotto/Faker/blob/master/src/Faker/Provider/ru_RU/Person.php#L13)). This will ease future updates of the list and debates about the most relevant data for this provider.
* If you add long list of random data, please split the list into several lines. This makes diffs easier to read, and facilitates core review.
* If you add new formatters, please include documentation for it in the README. Don't forget to add a line about new formatters in the `@property` or `@method` phpDoc entries in [Generator.php](https://github.com/fzaninotto/Faker/blob/master/src/Faker/Generator.php#L6-L118) to help IDEs auto-complete your formatters.
* If your new formatters are specific to a certain locale, document them in the [Language-specific formatters](https://github.com/fzaninotto/Faker#language-specific-formatters) list instead.
* Avoid changing existing sets of data. Some developers use Faker with seeding for unit tests ; changing the data makes their tests fail.
* Speed is important in all Faker usages. Make sure your code is optimized to generate thousands of fake items in no time, without consuming too much memory or CPU.
* If you commit a new feature, be prepared to help maintaining it. Watch the project on GitHub, and please comment on issues or PRs regarding the feature you contributed.
Once your code is merged, it is available for free to everybody under the MIT License. Publishing your Pull Request on the Faker GitHub repository means that you agree with this license for your contribution.
Thank you for your contribution! Faker wouldn't be so great without you.

22
vendor/fzaninotto/faker/LICENSE vendored Normal file
View File

@ -0,0 +1,22 @@
Copyright (c) 2011 François Zaninotto
Portions Copyright (c) 2008 Caius Durling
Portions Copyright (c) 2008 Adam Royle
Portions Copyright (c) 2008 Fiona Burrows
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

10
vendor/fzaninotto/faker/Makefile vendored Normal file
View File

@ -0,0 +1,10 @@
vendor/autoload.php:
composer install --no-interaction --prefer-source --dev
.PHONY: sniff
sniff: vendor/autoload.php
vendor/bin/phpcs --standard=PSR2 src -n
.PHONY: test
test: vendor/autoload.php
vendor/bin/phpunit --verbose

37
vendor/fzaninotto/faker/composer.json vendored Normal file
View File

@ -0,0 +1,37 @@
{
"name": "fzaninotto/faker",
"type": "library",
"description": "Faker is a PHP library that generates fake data for you.",
"keywords": ["faker", "fixtures", "data"],
"license": "MIT",
"authors": [
{
"name": "François Zaninotto"
}
],
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~1.5"
},
"suggest": {
"ext-intl": "*"
},
"autoload": {
"psr-4": {
"Faker\\": "src/Faker/"
}
},
"autoload-dev": {
"psr-4": {
"Faker\\PHPUnit\\": "test/Faker/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.5.x-dev"
}
}
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Faker Test Suite">
<directory>./test/Faker/</directory>
</testsuite>
</testsuites>
</phpunit>

1048
vendor/fzaninotto/faker/readme.md vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
<?php
namespace Faker\Calculator;
/**
* Utility class for generating Luhn checksum and validating a number
*
* Luhn algorithm is used to validate credit card numbers, IMEI numbers, and
* National Provider Identifier numbers.
*
* @see http://en.wikipedia.org/wiki/Luhn_algorithm
*/
class Luhn
{
/**
* @return int
*/
private static function checksum($number)
{
$number = (string) $number;
$length = strlen($number);
$sum = 0;
for ($i = $length - 1; $i >= 0; $i -= 2) {
$sum += $number{$i};
}
for ($i = $length - 2; $i >= 0; $i -= 2) {
$sum += array_sum(str_split($number{$i} * 2));
}
return $sum % 10;
}
/**
* @return string
*/
public static function computeCheckDigit($partialNumber)
{
$checkDigit = self::checksum($partialNumber . '0');
if ($checkDigit === 0) {
return 0;
}
return (string) (10 - $checkDigit);
}
/**
* Checks whether a number (partial number + check digit) is Luhn compliant
*
* @return boolean
*/
public static function isValid($number)
{
return self::checksum($number) === 0;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Faker;
/**
* This generator returns a default value for all called properties
* and methods. It works with Faker\Generator\Base->optional().
*/
class DefaultGenerator
{
protected $default = null;
public function __construct($default = null)
{
$this->default = $default;
}
public function __get($attribute)
{
return $this->default;
}
public function __call($method, $attributes)
{
return $this->default;
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace Faker;
class Documentor
{
protected $generator;
public function __construct(Generator $generator)
{
$this->generator = $generator;
}
public function getFormatters()
{
$formatters = array();
$providers = array_reverse($this->generator->getProviders());
$providers[]= new \Faker\Provider\Base($this->generator);
foreach ($providers as $provider) {
$providerClass = get_class($provider);
$formatters[$providerClass] = array();
$refl = new \ReflectionObject($provider);
foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflmethod) {
if ($reflmethod->getDeclaringClass()->getName() == 'Faker\Provider\Base' && $providerClass != 'Faker\Provider\Base') {
continue;
}
$methodName = $reflmethod->name;
if ($reflmethod->isConstructor()) {
continue;
}
$parameters = array();
foreach ($reflmethod->getParameters() as $reflparameter) {
$parameter = '$'. $reflparameter->getName();
if ($reflparameter->isDefaultValueAvailable()) {
$parameter .= ' = ' . var_export($reflparameter->getDefaultValue(), true);
}
$parameters []= $parameter;
}
$parameters = $parameters ? '('. join(', ', $parameters) . ')' : '';
try {
$example = $this->generator->format($methodName);
} catch (\InvalidArgumentException $e) {
$example = '';
}
if (is_array($example)) {
$example = "array('". join("', '", $example) . "')";
} elseif ($example instanceof \DateTime) {
$example = "DateTime('" . $example->format('Y-m-d H:i:s') . "')";
} elseif ($example instanceof Generator || $example instanceof UniqueGenerator) { // modifier
$example = '';
} else {
$example = var_export($example, true);
}
$formatters[$providerClass][$methodName . $parameters] = $example;
}
}
return $formatters;
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace Faker;
class Factory
{
const DEFAULT_LOCALE = 'en_US';
protected static $defaultProviders = array('Address', 'Barcode', 'Biased', 'Color', 'Company', 'DateTime', 'File', 'Image', 'Internet', 'Lorem', 'Miscellaneous', 'Payment', 'Person', 'PhoneNumber', 'Text', 'UserAgent', 'Uuid');
public static function create($locale = self::DEFAULT_LOCALE)
{
$generator = new Generator();
foreach (static::$defaultProviders as $provider) {
$providerClassName = self::getProviderClassname($provider, $locale);
$generator->addProvider(new $providerClassName($generator));
}
return $generator;
}
protected static function getProviderClassname($provider, $locale = '')
{
if ($providerClass = self::findProviderClassname($provider, $locale)) {
return $providerClass;
}
// fallback to default locale
if ($providerClass = self::findProviderClassname($provider, static::DEFAULT_LOCALE)) {
return $providerClass;
}
// fallback to no locale
$providerClass = self::findProviderClassname($provider);
if (class_exists($providerClass)) {
return $providerClass;
}
throw new \InvalidArgumentException(sprintf('Unable to find provider "%s" with locale "%s"', $provider, $locale));
}
protected static function findProviderClassname($provider, $locale = '')
{
$providerClass = 'Faker\\' . ($locale ? sprintf('Provider\%s\%s', $locale, $provider) : sprintf('Provider\%s', $provider));
if (class_exists($providerClass, true)) {
return $providerClass;
}
}
}

View File

@ -0,0 +1,239 @@
<?php
namespace Faker;
/**
* @property string $name
* @property string $firstName
* @property string $firstNameMale
* @property string $firstNameFemale
* @property string $lastName
* @property string $title
* @property string $titleMale
* @property string $titleFemale
*
* @property string $citySuffix
* @property string $streetSuffix
* @property string $buildingNumber
* @property string $city
* @property string $streetName
* @property string $streetAddress
* @property string $postcode
* @property string $address
* @property string $country
* @property float $latitude
* @property float $longitude
*
* @property string $ean13
* @property string $ean8
* @property string $isbn13
* @property string $isbn10
*
* @property string $phoneNumber
*
* @property string $company
* @property string $companySuffix
*
* @property string $creditCardType
* @property string $creditCardNumber
* @method string creditCardNumber($type = null, $formatted = false, $separator = '-')
* @property \DateTime $creditCardExpirationDate
* @property string $creditCardExpirationDateString
* @property string $creditCardDetails
* @property string $bankAccountNumber
* @property string $swiftBicNumber
* @property string $vat
*
* @property string $word
* @property string|array $words
* @method string|array words($nb = 3, $asText = false)
* @property string $sentence
* @method string sentence($nbWords = 6, $variableNbWords = true)
* @property string|array $sentences
* @method string|array sentences($nb = 3, $asText = false)
* @property string $paragraph
* @method string paragraph($nbSentences = 3, $variableNbSentences = true)
* @property string|array $paragraphs
* @method string|array paragraphs($nb = 3, $asText = false)
* @property string $text
* @method string text($maxNbChars = 200)
*
* @method string realText($maxNbChars = 200, $indexSize = 2)
*
* @property string $email
* @property string $safeEmail
* @property string $freeEmail
* @property string $companyEmail
* @property string $freeEmailDomain
* @property string $safeEmailDomain
* @property string $userName
* @property string $password
* @method string password($minLength = 6, $maxLength = 20)
* @property string $domainName
* @property string $domainWord
* @property string $tld
* @property string $url
* @property string $slug
* @method string slug($nbWords = 6, $variableNbWords = true)
* @property string $ipv4
* @property string $ipv6
* @property string $localIpv4
* @property string $macAddress
*
* @property int $unixTime
* @property \DateTime $dateTime
* @property \DateTime $dateTimeAD
* @property string $iso8601
* @property \DateTime $dateTimeThisCentury
* @property \DateTime $dateTimeThisDecade
* @property \DateTime $dateTimeThisYear
* @property \DateTime $dateTimeThisMonth
* @property string $amPm
* @property int $dayOfMonth
* @property int $dayOfWeek
* @property int $month
* @property string $monthName
* @property int $year
* @property int $century
* @property string $timezone
* @method string date($format = 'Y-m-d', $max = 'now')
* @method string time($format = 'H:i:s', $max = 'now')
* @method \DateTime dateTimeBetween($startDate = '-30 years', $endDate = 'now')
*
* @property string $md5
* @property string $sha1
* @property string $sha256
* @property string $locale
* @property string $countryCode
* @property string $countryISOAlpha3
* @property string $languageCode
* @property string $currencyCode
* @method boolean boolean($chanceOfGettingTrue = 50)
*
* @property int $randomDigit
* @property int $randomDigitNotNull
* @property string $randomLetter
* @property string $randomAscii
* @method int randomNumber($nbDigits = null, $strict = false)
* @method int|string|null randomKey(array $array = array())
* @method int numberBetween($min = 0, $max = 2147483647)
* @method float randomFloat($nbMaxDecimals = null, $min = 0, $max = null)
* @method mixed randomElement(array $array = array('a', 'b', 'c'))
* @method array randomElements(array $array = array('a', 'b', 'c'), $count = 1)
* @method array|string shuffle($arg = '')
* @method array shuffleArray(array $array = array())
* @method string shuffleString($string = '', $encoding = 'UTF-8')
* @method string numerify($string = '###')
* @method string lexify($string = '????')
* @method string bothify($string = '## ??')
* @method string asciify($string = '****')
* @method string regexify($regex = '')
* @method string toLower($string = '')
* @method string toUpper($string = '')
* @method Generator optional($weight = 0.5, $default = null)
* @method Generator unique($reset = false, $maxRetries = 10000)
*
* @method integer biasedNumberBetween($min = 0, $max = 100, $function = 'sqrt')
*
* @property string $macProcessor
* @property string $linuxProcessor
* @property string $userAgent
* @property string $chrome
* @property string $firefox
* @property string $safari
* @property string $opera
* @property string $internetExplorer
* @property string $windowsPlatformToken
* @property string $macPlatformToken
* @property string $linuxPlatformToken
*
* @property string $uuid
*
* @property string $mimeType
* @property string $fileExtension
* @method string file($sourceDirectory = '/tmp', $targetDirectory = '/tmp', $fullPath = true)
*
* @method string imageUrl($width = 640, $height = 480, $category = null, $randomize = true)
* @method string image($dir = null, $width = 640, $height = 480, $category = null, $fullPath = true)
*
* @property string $hexColor
* @property string $safeHexColor
* @property string $rgbColor
* @property array $rgbColorAsArray
* @property string $rgbCssColor
* @property string $safeColorName
* @property string $colorName
*/
class Generator
{
protected $providers = array();
protected $formatters = array();
public function addProvider($provider)
{
array_unshift($this->providers, $provider);
}
public function getProviders()
{
return $this->providers;
}
public function seed($seed = null)
{
if ($seed === null) {
mt_srand();
} else {
mt_srand($seed);
}
}
public function format($formatter, $arguments = array())
{
return call_user_func_array($this->getFormatter($formatter), $arguments);
}
/**
* @return Callable
*/
public function getFormatter($formatter)
{
if (isset($this->formatters[$formatter])) {
return $this->formatters[$formatter];
}
foreach ($this->providers as $provider) {
if (method_exists($provider, $formatter)) {
$this->formatters[$formatter] = array($provider, $formatter);
return $this->formatters[$formatter];
}
}
throw new \InvalidArgumentException(sprintf('Unknown formatter "%s"', $formatter));
}
/**
* Replaces tokens ('{{ tokenName }}') with the result from the token method call
*
* @param string $string String that needs to bet parsed
* @return string
*/
public function parse($string)
{
return preg_replace_callback('/\{\{\s?(\w+)\s?\}\}/u', array($this, 'callFormatWithMatches'), $string);
}
protected function callFormatWithMatches($matches)
{
return $this->format($matches[1]);
}
public function __get($attribute)
{
return $this->format($attribute);
}
public function __call($method, $attributes)
{
return $this->format($method, $attributes);
}
}

View File

@ -0,0 +1,92 @@
<?php
namespace Faker\Guesser;
use \Faker\Provider\Base;
class Name
{
protected $generator;
public function __construct(\Faker\Generator $generator)
{
$this->generator = $generator;
}
public function guessFormat($name)
{
$name = Base::toLower($name);
$generator = $this->generator;
if (preg_match('/^is[_A-Z]/', $name)) {
return function () use ($generator) {
return $generator->boolean;
};
}
if (preg_match('/(_a|A)t$/', $name)) {
return function () use ($generator) {
return $generator->dateTime;
};
}
switch ($name) {
case 'first_name':
case 'firstname':
return function () use ($generator) {
return $generator->firstName;
};
case 'last_name':
case 'lastname':
return function () use ($generator) {
return $generator->lastName;
};
case 'username':
case 'login':
return function () use ($generator) {
return $generator->userName;
};
case 'email':
return function () use ($generator) {
return $generator->email;
};
case 'phone_number':
case 'phonenumber':
case 'phone':
return function () use ($generator) {
return $generator->phoneNumber;
};
case 'address':
return function () use ($generator) {
return $generator->address;
};
case 'city':
return function () use ($generator) {
return $generator->city;
};
case 'streetaddress':
return function () use ($generator) {
return $generator->streetAddress;
};
case 'postcode':
case 'zipcode':
return function () use ($generator) {
return $generator->postcode;
};
case 'state':
return function () use ($generator) {
return $generator->state;
};
case 'country':
return function () use ($generator) {
return $generator->country;
};
case 'title':
return function () use ($generator) {
return $generator->sentence;
};
case 'body':
case 'summary':
return function () use ($generator) {
return $generator->text;
};
}
}
}

View File

@ -0,0 +1,64 @@
<?php
namespace Faker\ORM\CakePHP;
class ColumnTypeGuesser
{
protected $generator;
public function __construct(\Faker\Generator $generator)
{
$this->generator = $generator;
}
public function guessFormat($column, $table)
{
$generator = $this->generator;
$schema = $table->schema();
switch ($schema->columnType($column)) {
case 'boolean':
return function () use ($generator) {
return $generator->boolean;
};
case 'integer':
return function () use ($generator) {
return $generator->randomNumber(10);
};
case 'biginteger':
return function () use ($generator) {
return $generator->randomNumber(20);
};
case 'decimal':
case 'float':
return function () use ($generator) {
return $generator->randomFloat();
};
case 'uuid':
return function () use ($generator) {
return $generator->uuid();
};
case 'string':
$columnData = $schema->column($column);
$length = $columnData['length'];
return function () use ($generator, $length) {
return $generator->text($length);
};
case 'text':
return function () use ($generator) {
return $generator->text();
};
case 'date':
case 'datetime':
case 'timestamp':
case 'time':
return function () use ($generator) {
return $generator->datetime();
};
case 'binary':
default:
return null;
}
}
}

View File

@ -0,0 +1,149 @@
<?php
namespace Faker\ORM\CakePHP;
use Cake\ORM\TableRegistry;
use Faker\Guesser\Name as NameGuesser;
class EntityPopulator
{
protected $class;
protected $connectionName;
protected $columnFormatters = [];
protected $modifiers = [];
public function __construct($class)
{
$this->class = $class;
}
public function __get($name)
{
return $this->{$name};
}
public function __set($name, $value)
{
$this->{$name} = $value;
}
public function mergeColumnFormattersWith($columnFormatters)
{
$this->columnFormatters = array_merge($this->columnFormatters, $columnFormatters);
}
public function mergeModifiersWith($modifiers)
{
$this->modifiers = array_merge($this->modifiers, $modifiers);
}
public function guessColumnFormatters($populator)
{
$formatters = [];
$class = $this->class;
$table = $this->getTable($class);
$schema = $table->schema();
$pk = $schema->primaryKey();
$guessers = $populator->getGuessers() + ['ColumnTypeGuesser' => new ColumnTypeGuesser($populator->getGenerator())];
$isForeignKey = function ($column) use ($table) {
foreach ($table->associations()->type('BelongsTo') as $assoc) {
if ($column == $assoc->foreignKey()) {
return true;
}
}
return false;
};
foreach ($schema->columns() as $column) {
if ($column == $pk[0] || $isForeignKey($column)) {
continue;
}
foreach ($guessers as $guesser) {
if ($formatter = $guesser->guessFormat($column, $table)) {
$formatters[$column] = $formatter;
break;
}
}
}
return $formatters;
}
public function guessModifiers($populator)
{
$modifiers = [];
$table = $this->getTable($this->class);
$belongsTo = $table->associations()->type('BelongsTo');
foreach ($belongsTo as $assoc) {
$modifiers['belongsTo' . $assoc->name()] = function ($data, $insertedEntities) use ($assoc) {
$table = $assoc->target();
$foreignModel = $table->alias();
$foreignKeys = [];
if (!empty($insertedEntities[$foreignModel])) {
$foreignKeys = $insertedEntities[$foreignModel];
} else {
$foreignKeys = $table->find('all')
->select(['id'])
->map(function ($row) {
return $row->id;
})
->toArray();
}
if (empty($foreignKeys)) {
throw new \Exception(sprintf('%s belongsTo %s, which seems empty at this point.', $this->getTable($this->class)->table(), $assoc->table()));
}
$foreignKey = $foreignKeys[array_rand($foreignKeys)];
$primaryKey = $table->primaryKey();
$data[$assoc->foreignKey()] = $foreignKey;
return $data;
};
}
// TODO check if TreeBehavior attached to modify lft/rgt cols
return $modifiers;
}
public function execute($class, $insertedEntities, $options = [])
{
$table = $this->getTable($class);
$entity = $table->newEntity();
foreach ($this->columnFormatters as $column => $format) {
if (!is_null($format)) {
$entity->{$column} = is_callable($format) ? $format($insertedEntities, $table) : $format;
}
}
foreach ($this->modifiers as $modifier) {
$entity = $modifier($entity, $insertedEntities);
}
if (!$entity = $table->save($entity, $options)) {
throw new \RuntimeException("Failed saving $class record");
}
$pk = $table->primaryKey();
return $entity->{$pk};
}
public function setConnection($name)
{
$this->connectionName = $name;
}
protected function getTable($class)
{
$options = [];
if (!empty($this->connectionName)) {
$options['connection'] = $this->connectionName;
}
return TableRegistry::get($class, $options);
}
}

View File

@ -0,0 +1,84 @@
<?php
namespace Faker\ORM\CakePHP;
class Populator
{
protected $generator;
protected $entities = [];
protected $quantities = [];
protected $guessers = [];
public function __construct(\Faker\Generator $generator)
{
$this->generator = $generator;
}
public function getGenerator()
{
return $this->generator;
}
public function getGuessers()
{
return $this->guessers;
}
public function removeGuesser($name)
{
if ($this->guessers[$name]) {
unset($this->guessers[$name]);
}
return $this;
}
public function addGuesser($class)
{
if (!is_object($class)) {
$class = new $class($this->generator);
}
if (!method_exists($class, 'guessFormat')) {
throw new \Exception('Missing required custom guesser method: ' . get_class($class) . '::guessFormat()');
}
$this->guessers[get_class($class)] = $class;
return $this;
}
public function addEntity($entity, $number, $customColumnFormatters = [], $customModifiers = [])
{
if (!$entity instanceof EntityPopulator) {
$entity = new EntityPopulator($entity);
}
$entity->columnFormatters = $entity->guessColumnFormatters($this);
if ($customColumnFormatters) {
$entity->mergeColumnFormattersWith($customColumnFormatters);
}
$entity->modifiers = $entity->guessModifiers($this);
if ($customModifiers) {
$entity->mergeModifiers($customModifiers);
}
$class = $entity->class;
$this->entities[$class] = $entity;
$this->quantities[$class] = $number;
return $this;
}
public function execute($options = [])
{
$insertedEntities = [];
foreach ($this->quantities as $class => $number) {
for ($i = 0; $i < $number; $i++) {
$insertedEntities[$class][] = $this->entities[$class]->execute($class, $insertedEntities, $options);
}
}
return $insertedEntities;
}
}

View File

@ -0,0 +1,68 @@
<?php
namespace Faker\ORM\Doctrine;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
class ColumnTypeGuesser
{
protected $generator;
public function __construct(\Faker\Generator $generator)
{
$this->generator = $generator;
}
public function guessFormat($fieldName, ClassMetadata $class)
{
$generator = $this->generator;
$type = $class->getTypeOfField($fieldName);
switch ($type) {
case 'boolean':
return function () use ($generator) {
return $generator->boolean;
};
case 'decimal':
$size = isset($class->fieldMappings[$fieldName]['precision']) ? $class->fieldMappings[$fieldName]['precision'] : 2;
return function () use ($generator, $size) {
return $generator->randomNumber($size + 2) / 100;
};
case 'smallint':
return function () {
return mt_rand(0, 65535);
};
case 'integer':
return function () {
return mt_rand(0, intval('2147483647'));
};
case 'bigint':
return function () {
return mt_rand(0, intval('18446744073709551615'));
};
case 'float':
return function () {
return mt_rand(0, intval('4294967295'))/mt_rand(1, intval('4294967295'));
};
case 'string':
$size = isset($class->fieldMappings[$fieldName]['length']) ? $class->fieldMappings[$fieldName]['length'] : 255;
return function () use ($generator, $size) {
return $generator->text($size);
};
case 'text':
return function () use ($generator) {
return $generator->text;
};
case 'datetime':
case 'date':
case 'time':
return function () use ($generator) {
return $generator->datetime;
};
default:
// no smart way to guess what the user expects here
return null;
}
}
}

View File

@ -0,0 +1,193 @@
<?php
namespace Faker\ORM\Doctrine;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
/**
* Service class for populating a table through a Doctrine Entity class.
*/
class EntityPopulator
{
/**
* @var ClassMetadata
*/
protected $class;
/**
* @var array
*/
protected $columnFormatters = array();
/**
* @var array
*/
protected $modifiers = array();
/**
* Class constructor.
*
* @param ClassMetadata $class
*/
public function __construct(ClassMetadata $class)
{
$this->class = $class;
}
/**
* @return string
*/
public function getClass()
{
return $this->class->getName();
}
public function setColumnFormatters($columnFormatters)
{
$this->columnFormatters = $columnFormatters;
}
public function getColumnFormatters()
{
return $this->columnFormatters;
}
public function mergeColumnFormattersWith($columnFormatters)
{
$this->columnFormatters = array_merge($this->columnFormatters, $columnFormatters);
}
public function setModifiers(array $modifiers)
{
$this->modifiers = $modifiers;
}
public function getModifiers()
{
return $this->modifiers;
}
public function mergeModifiersWith(array $modifiers)
{
$this->modifiers = array_merge($this->modifiers, $modifiers);
}
public function guessColumnFormatters(\Faker\Generator $generator)
{
$formatters = array();
$nameGuesser = new \Faker\Guesser\Name($generator);
$columnTypeGuesser = new ColumnTypeGuesser($generator);
foreach ($this->class->getFieldNames() as $fieldName) {
if ($this->class->isIdentifier($fieldName) || !$this->class->hasField($fieldName)) {
continue;
}
if ($formatter = $nameGuesser->guessFormat($fieldName)) {
$formatters[$fieldName] = $formatter;
continue;
}
if ($formatter = $columnTypeGuesser->guessFormat($fieldName, $this->class)) {
$formatters[$fieldName] = $formatter;
continue;
}
}
foreach ($this->class->getAssociationNames() as $assocName) {
if ($this->class->isCollectionValuedAssociation($assocName)) {
continue;
}
$relatedClass = $this->class->getAssociationTargetClass($assocName);
$unique = $optional = false;
$mappings = $this->class->getAssociationMappings();
foreach ($mappings as $mapping) {
if ($mapping['targetEntity'] == $relatedClass) {
if ($mapping['type'] == ClassMetadata::ONE_TO_ONE) {
$unique = true;
$optional = isset($mapping['joinColumns'][0]['nullable']) ? $mapping['joinColumns'][0]['nullable'] : false;
break;
}
}
}
$index = 0;
$formatters[$assocName] = function ($inserted) use ($relatedClass, &$index, $unique, $optional) {
if ($unique && isset($inserted[$relatedClass])) {
$related = null;
if (isset($inserted[$relatedClass][$index]) || !$optional) {
$related = $inserted[$relatedClass][$index];
}
$index++;
return $related;
} elseif (isset($inserted[$relatedClass])) {
return $inserted[$relatedClass][mt_rand(0, count($inserted[$relatedClass]) - 1)];
}
return null;
};
}
return $formatters;
}
/**
* Insert one new record using the Entity class.
*/
public function execute(ObjectManager $manager, $insertedEntities, $generateId = false)
{
$obj = $this->class->newInstance();
$this->fillColumns($obj, $insertedEntities);
$this->callMethods($obj, $insertedEntities);
if ($generateId) {
$idsName = $this->class->getIdentifier();
foreach ($idsName as $idName) {
$id = $this->generateId($obj, $idName, $manager);
$this->class->reflFields[$idName]->setValue($obj, $id);
}
}
$manager->persist($obj);
return $obj;
}
private function fillColumns($obj, $insertedEntities)
{
foreach ($this->columnFormatters as $field => $format) {
if (null !== $format) {
$value = is_callable($format) ? $format($insertedEntities, $obj) : $format;
$this->class->reflFields[$field]->setValue($obj, $value);
}
}
}
private function callMethods($obj, $insertedEntities)
{
foreach ($this->getModifiers() as $modifier) {
$modifier($obj, $insertedEntities);
}
}
private function generateId($obj, $column, EntityManagerInterface $manager)
{
/* @var $repository \Doctrine\ORM\EntityRepository */
$repository = $manager->getRepository(get_class($obj));
$result = $repository->createQueryBuilder('e')
->select(sprintf('e.%s', $column))
->getQuery()
->getResult();
$ids = array_map('current', $result);
$id = null;
do {
$id = rand();
} while (in_array($id, $ids));
return $id;
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace Faker\ORM\Doctrine;
use Doctrine\Common\Persistence\ObjectManager;
/**
* Service class for populating a database using the Doctrine ORM or ODM.
* A Populator can populate several tables using ActiveRecord classes.
*/
class Populator
{
protected $generator;
protected $manager;
protected $entities = array();
protected $quantities = array();
protected $generateId = array();
public function __construct(\Faker\Generator $generator, ObjectManager $manager = null)
{
$this->generator = $generator;
$this->manager = $manager;
}
/**
* Add an order for the generation of $number records for $entity.
*
* @param mixed $entity A Doctrine classname, or a \Faker\ORM\Doctrine\EntityPopulator instance
* @param int $number The number of entities to populate
*/
public function addEntity($entity, $number, $customColumnFormatters = array(), $customModifiers = array(), $generateId = false)
{
if (!$entity instanceof \Faker\ORM\Doctrine\EntityPopulator) {
if (null === $this->manager) {
throw new \InvalidArgumentException("No entity manager passed to Doctrine Populator.");
}
$entity = new \Faker\ORM\Doctrine\EntityPopulator($this->manager->getClassMetadata($entity));
}
$entity->setColumnFormatters($entity->guessColumnFormatters($this->generator));
if ($customColumnFormatters) {
$entity->mergeColumnFormattersWith($customColumnFormatters);
}
$entity->mergeModifiersWith($customModifiers);
$this->generateId[$entity->getClass()] = $generateId;
$class = $entity->getClass();
$this->entities[$class] = $entity;
$this->quantities[$class] = $number;
}
/**
* Populate the database using all the Entity classes previously added.
*
* @param EntityManager $entityManager A Doctrine connection object
*
* @return array A list of the inserted PKs
*/
public function execute($entityManager = null)
{
if (null === $entityManager) {
$entityManager = $this->manager;
}
if (null === $entityManager) {
throw new \InvalidArgumentException("No entity manager passed to Doctrine Populator.");
}
$insertedEntities = array();
foreach ($this->quantities as $class => $number) {
$generateId = $this->generateId[$class];
for ($i=0; $i < $number; $i++) {
$insertedEntities[$class][]= $this->entities[$class]->execute($entityManager, $insertedEntities, $generateId);
}
$entityManager->flush();
}
return $insertedEntities;
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace Faker\ORM\Mandango;
class ColumnTypeGuesser
{
protected $generator;
public function __construct(\Faker\Generator $generator)
{
$this->generator = $generator;
}
public function guessFormat($field)
{
$generator = $this->generator;
switch ($field['type']) {
case 'boolean':
return function () use ($generator) {
return $generator->boolean;
};
case 'integer':
return function () {
return mt_rand(0, intval('4294967295'));
};
case 'float':
return function () {
return mt_rand(0, intval('4294967295'))/mt_rand(1, intval('4294967295'));
};
case 'string':
return function () use ($generator) {
return $generator->text(255);
};
case 'date':
return function () use ($generator) {
return $generator->datetime;
};
default:
// no smart way to guess what the user expects here
return null;
}
}
}

View File

@ -0,0 +1,110 @@
<?php
namespace Faker\ORM\Mandango;
use Mandango\Mandango;
use Faker\Provider\Base;
/**
* Service class for populating a table through a Mandango ActiveRecord class.
*/
class EntityPopulator
{
protected $class;
protected $columnFormatters = array();
/**
* Class constructor.
*
* @param string $class A Mandango ActiveRecord classname
*/
public function __construct($class)
{
$this->class = $class;
}
public function getClass()
{
return $this->class;
}
public function setColumnFormatters($columnFormatters)
{
$this->columnFormatters = $columnFormatters;
}
public function getColumnFormatters()
{
return $this->columnFormatters;
}
public function mergeColumnFormattersWith($columnFormatters)
{
$this->columnFormatters = array_merge($this->columnFormatters, $columnFormatters);
}
public function guessColumnFormatters(\Faker\Generator $generator, Mandango $mandango)
{
$formatters = array();
$nameGuesser = new \Faker\Guesser\Name($generator);
$columnTypeGuesser = new \Faker\ORM\Mandango\ColumnTypeGuesser($generator);
$metadata = $mandango->getMetadata($this->class);
// fields
foreach ($metadata['fields'] as $fieldName => $field) {
if ($formatter = $nameGuesser->guessFormat($fieldName)) {
$formatters[$fieldName] = $formatter;
continue;
}
if ($formatter = $columnTypeGuesser->guessFormat($field)) {
$formatters[$fieldName] = $formatter;
continue;
}
}
// references
foreach (array_merge($metadata['referencesOne'], $metadata['referencesMany']) as $referenceName => $reference) {
if (!isset($reference['class'])) {
continue;
}
$referenceClass = $reference['class'];
$formatters[$referenceName] = function ($insertedEntities) use ($referenceClass) {
if (isset($insertedEntities[$referenceClass])) {
return Base::randomElement($insertedEntities[$referenceClass]);
}
};
}
return $formatters;
}
/**
* Insert one new record using the Entity class.
*/
public function execute(Mandango $mandango, $insertedEntities)
{
$metadata = $mandango->getMetadata($this->class);
$obj = $mandango->create($this->class);
foreach ($this->columnFormatters as $column => $format) {
if (null !== $format) {
$value = is_callable($format) ? $format($insertedEntities, $obj) : $format;
if (isset($metadata['fields'][$column]) ||
isset($metadata['referencesOne'][$column])) {
$obj->set($column, $value);
}
if (isset($metadata['referencesMany'][$column])) {
$adder = 'add'.ucfirst($column);
$obj->$adder($value);
}
}
}
$mandango->persist($obj);
return $obj;
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace Faker\ORM\Mandango;
use Mandango\Mandango;
/**
* Service class for populating a database using Mandango.
* A Populator can populate several tables using ActiveRecord classes.
*/
class Populator
{
protected $generator;
protected $mandango;
protected $entities = array();
protected $quantities = array();
public function __construct(\Faker\Generator $generator, Mandango $mandango)
{
$this->generator = $generator;
$this->mandango = $mandango;
}
/**
* Add an order for the generation of $number records for $entity.
*
* @param mixed $entity A Propel ActiveRecord classname, or a \Faker\ORM\Propel\EntityPopulator instance
* @param int $number The number of entities to populate
*/
public function addEntity($entity, $number, $customColumnFormatters = array())
{
if (!$entity instanceof \Faker\ORM\Mandango\EntityPopulator) {
$entity = new \Faker\ORM\Mandango\EntityPopulator($entity);
}
$entity->setColumnFormatters($entity->guessColumnFormatters($this->generator, $this->mandango));
if ($customColumnFormatters) {
$entity->mergeColumnFormattersWith($customColumnFormatters);
}
$class = $entity->getClass();
$this->entities[$class] = $entity;
$this->quantities[$class] = $number;
}
/**
* Populate the database using all the Entity classes previously added.
*
* @return array A list of the inserted entities.
*/
public function execute()
{
$insertedEntities = array();
foreach ($this->quantities as $class => $number) {
for ($i=0; $i < $number; $i++) {
$insertedEntities[$class][]= $this->entities[$class]->execute($this->mandango, $insertedEntities);
}
}
$this->mandango->flush();
return $insertedEntities;
}
}

View File

@ -0,0 +1,99 @@
<?php
namespace Faker\ORM\Propel;
use \PropelColumnTypes;
use \ColumnMap;
class ColumnTypeGuesser
{
protected $generator;
public function __construct(\Faker\Generator $generator)
{
$this->generator = $generator;
}
public function guessFormat(ColumnMap $column)
{
$generator = $this->generator;
if ($column->isTemporal()) {
if ($column->isEpochTemporal()) {
return function () use ($generator) {
return $generator->dateTime;
};
} else {
return function () use ($generator) {
return $generator->dateTimeAD;
};
}
}
$type = $column->getType();
switch ($type) {
case PropelColumnTypes::BOOLEAN:
case PropelColumnTypes::BOOLEAN_EMU:
return function () use ($generator) {
return $generator->boolean;
};
case PropelColumnTypes::NUMERIC:
case PropelColumnTypes::DECIMAL:
$size = $column->getSize();
return function () use ($generator, $size) {
return $generator->randomNumber($size + 2) / 100;
};
case PropelColumnTypes::TINYINT:
return function () {
return mt_rand(0, 127);
};
case PropelColumnTypes::SMALLINT:
return function () {
return mt_rand(0, 32767);
};
case PropelColumnTypes::INTEGER:
return function () {
return mt_rand(0, intval('2147483647'));
};
case PropelColumnTypes::BIGINT:
return function () {
return mt_rand(0, intval('9223372036854775807'));
};
case PropelColumnTypes::FLOAT:
return function () {
return mt_rand(0, intval('2147483647'))/mt_rand(1, intval('2147483647'));
};
case PropelColumnTypes::DOUBLE:
case PropelColumnTypes::REAL:
return function () {
return mt_rand(0, intval('9223372036854775807'))/mt_rand(1, intval('9223372036854775807'));
};
case PropelColumnTypes::CHAR:
case PropelColumnTypes::VARCHAR:
case PropelColumnTypes::BINARY:
case PropelColumnTypes::VARBINARY:
$size = $column->getSize();
return function () use ($generator, $size) {
return $generator->text($size);
};
case PropelColumnTypes::LONGVARCHAR:
case PropelColumnTypes::LONGVARBINARY:
case PropelColumnTypes::CLOB:
case PropelColumnTypes::CLOB_EMU:
case PropelColumnTypes::BLOB:
return function () use ($generator) {
return $generator->text;
};
case PropelColumnTypes::ENUM:
$valueSet = $column->getValueSet();
return function () use ($generator, $valueSet) {
return $generator->randomElement($valueSet);
};
case PropelColumnTypes::OBJECT:
case PropelColumnTypes::PHP_ARRAY:
// no smart way to guess what the user expects here
return null;
}
}
}

View File

@ -0,0 +1,170 @@
<?php
namespace Faker\ORM\Propel;
use \Faker\Provider\Base;
use \ColumnMap;
/**
* Service class for populating a table through a Propel ActiveRecord class.
*/
class EntityPopulator
{
protected $class;
protected $columnFormatters = array();
protected $modifiers = array();
/**
* Class constructor.
*
* @param string $class A Propel ActiveRecord classname
*/
public function __construct($class)
{
$this->class = $class;
}
public function getClass()
{
return $this->class;
}
public function setColumnFormatters($columnFormatters)
{
$this->columnFormatters = $columnFormatters;
}
public function getColumnFormatters()
{
return $this->columnFormatters;
}
public function mergeColumnFormattersWith($columnFormatters)
{
$this->columnFormatters = array_merge($this->columnFormatters, $columnFormatters);
}
public function guessColumnFormatters(\Faker\Generator $generator)
{
$formatters = array();
$class = $this->class;
$peerClass = $class::PEER;
$tableMap = $peerClass::getTableMap();
$nameGuesser = new \Faker\Guesser\Name($generator);
$columnTypeGuesser = new \Faker\ORM\Propel\ColumnTypeGuesser($generator);
foreach ($tableMap->getColumns() as $columnMap) {
// skip behavior columns, handled by modifiers
if ($this->isColumnBehavior($columnMap)) {
continue;
}
if ($columnMap->isForeignKey()) {
$relatedClass = $columnMap->getRelation()->getForeignTable()->getClassname();
$formatters[$columnMap->getPhpName()] = function ($inserted) use ($relatedClass) {
return isset($inserted[$relatedClass]) ? $inserted[$relatedClass][mt_rand(0, count($inserted[$relatedClass]) - 1)] : null;
};
continue;
}
if ($columnMap->isPrimaryKey()) {
continue;
}
if ($formatter = $nameGuesser->guessFormat($columnMap->getPhpName())) {
$formatters[$columnMap->getPhpName()] = $formatter;
continue;
}
if ($formatter = $columnTypeGuesser->guessFormat($columnMap)) {
$formatters[$columnMap->getPhpName()] = $formatter;
continue;
}
}
return $formatters;
}
protected function isColumnBehavior(ColumnMap $columnMap)
{
foreach ($columnMap->getTable()->getBehaviors() as $name => $params) {
$columnName = Base::toLower($columnMap->getName());
switch ($name) {
case 'nested_set':
$columnNames = array($params['left_column'], $params['right_column'], $params['level_column']);
if (in_array($columnName, $columnNames)) {
return true;
}
break;
case 'timestampable':
$columnNames = array($params['create_column'], $params['update_column']);
if (in_array($columnName, $columnNames)) {
return true;
}
break;
}
}
return false;
}
public function setModifiers($modifiers)
{
$this->modifiers = $modifiers;
}
public function getModifiers()
{
return $this->modifiers;
}
public function mergeModifiersWith($modifiers)
{
$this->modifiers = array_merge($this->modifiers, $modifiers);
}
public function guessModifiers(\Faker\Generator $generator)
{
$modifiers = array();
$class = $this->class;
$peerClass = $class::PEER;
$tableMap = $peerClass::getTableMap();
foreach ($tableMap->getBehaviors() as $name => $params) {
switch ($name) {
case 'nested_set':
$modifiers['nested_set'] = function ($obj, $inserted) use ($class, $generator) {
if (isset($inserted[$class])) {
$queryClass = $class . 'Query';
$parent = $queryClass::create()->findPk($generator->randomElement($inserted[$class]));
$obj->insertAsLastChildOf($parent);
} else {
$obj->makeRoot();
}
};
break;
case 'sortable':
$modifiers['sortable'] = function ($obj, $inserted) use ($class, $generator) {
$maxRank = isset($inserted[$class]) ? count($inserted[$class]) : 0;
$obj->insertAtRank(mt_rand(1, $maxRank + 1));
};
break;
}
}
return $modifiers;
}
/**
* Insert one new record using the Entity class.
*/
public function execute($con, $insertedEntities)
{
$obj = new $this->class();
foreach ($this->getColumnFormatters() as $column => $format) {
if (null !== $format) {
$obj->setByName($column, is_callable($format) ? $format($insertedEntities, $obj) : $format);
}
}
foreach ($this->getModifiers() as $modifier) {
$modifier($obj, $insertedEntities);
}
$obj->save($con);
return $obj->getPrimaryKey();
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace Faker\ORM\Propel;
/**
* Service class for populating a database using the Propel ORM.
* A Populator can populate several tables using ActiveRecord classes.
*/
class Populator
{
protected $generator;
protected $entities = array();
protected $quantities = array();
public function __construct(\Faker\Generator $generator)
{
$this->generator = $generator;
}
/**
* Add an order for the generation of $number records for $entity.
*
* @param mixed $entity A Propel ActiveRecord classname, or a \Faker\ORM\Propel\EntityPopulator instance
* @param int $number The number of entities to populate
*/
public function addEntity($entity, $number, $customColumnFormatters = array(), $customModifiers = array())
{
if (!$entity instanceof \Faker\ORM\Propel\EntityPopulator) {
$entity = new \Faker\ORM\Propel\EntityPopulator($entity);
}
$entity->setColumnFormatters($entity->guessColumnFormatters($this->generator));
if ($customColumnFormatters) {
$entity->mergeColumnFormattersWith($customColumnFormatters);
}
$entity->setModifiers($entity->guessModifiers($this->generator));
if ($customModifiers) {
$entity->mergeModifiersWith($customModifiers);
}
$class = $entity->getClass();
$this->entities[$class] = $entity;
$this->quantities[$class] = $number;
}
/**
* Populate the database using all the Entity classes previously added.
*
* @param PropelPDO $con A Propel connection object
*
* @return array A list of the inserted PKs
*/
public function execute($con = null)
{
if (null === $con) {
$con = $this->getConnection();
}
$isInstancePoolingEnabled = \Propel::isInstancePoolingEnabled();
\Propel::disableInstancePooling();
$insertedEntities = array();
$con->beginTransaction();
foreach ($this->quantities as $class => $number) {
for ($i=0; $i < $number; $i++) {
$insertedEntities[$class][]= $this->entities[$class]->execute($con, $insertedEntities);
}
}
$con->commit();
if ($isInstancePoolingEnabled) {
\Propel::enableInstancePooling();
}
return $insertedEntities;
}
protected function getConnection()
{
// use the first connection available
$class = key($this->entities);
if (!$class) {
throw new \RuntimeException('No class found from entities. Did you add entities to the Populator ?');
}
$peer = $class::PEER;
return \Propel::getConnection($peer::DATABASE_NAME, \Propel::CONNECTION_WRITE);
}
}

View File

@ -0,0 +1,123 @@
<?php
namespace Faker\Provider;
class Address extends \Faker\Provider\Base
{
protected static $citySuffix = array('Ville');
protected static $streetSuffix = array('Street');
protected static $cityFormats = array(
'{{firstName}}{{citySuffix}}',
);
protected static $streetNameFormats = array(
'{{lastName}} {{streetSuffix}}'
);
protected static $streetAddressFormats = array(
'{{buildingNumber}} {{streetName}}'
);
protected static $addressFormats = array(
'{{streetAddress}} {{postcode}} {{city}}',
);
protected static $buildingNumber = array('##');
protected static $postcode = array('#####');
protected static $country = array();
/**
* @example 'town'
*/
public static function citySuffix()
{
return static::randomElement(static::$citySuffix);
}
/**
* @example 'Avenue'
*/
public static function streetSuffix()
{
return static::randomElement(static::$streetSuffix);
}
/**
* @example '791'
*/
public static function buildingNumber()
{
return static::numerify(static::randomElement(static::$buildingNumber));
}
/**
* @example 'Sashabury'
*/
public function city()
{
$format = static::randomElement(static::$cityFormats);
return $this->generator->parse($format);
}
/**
* @example 'Crist Parks'
*/
public function streetName()
{
$format = static::randomElement(static::$streetNameFormats);
return $this->generator->parse($format);
}
/**
* @example '791 Crist Parks'
*/
public function streetAddress()
{
$format = static::randomElement(static::$streetAddressFormats);
return $this->generator->parse($format);
}
/**
* @example 86039-9874
*/
public static function postcode()
{
return static::toUpper(static::bothify(static::randomElement(static::$postcode)));
}
/**
* @example '791 Crist Parks, Sashabury, IL 86039-9874'
*/
public function address()
{
$format = static::randomElement(static::$addressFormats);
return $this->generator->parse($format);
}
/**
* @example 'Japan'
*/
public static function country()
{
return static::randomElement(static::$country);
}
/**
* @example 77.147489
* @return float Uses signed degrees format (returns a float number between -90 and 90)
*/
public static function latitude()
{
return static::randomFloat(6, 0, 180) - 90;
}
/**
* @example 86.211205
* @return float Uses signed degrees format (returns a float number between -180 and 180)
*/
public static function longitude()
{
return static::randomFloat(6, 0, 360) - 180;
}
}

View File

@ -0,0 +1,110 @@
<?php
namespace Faker\Provider;
/**
* @see http://en.wikipedia.org/wiki/EAN-13
* @see http://en.wikipedia.org/wiki/ISBN
*/
class Barcode extends \Faker\Provider\Base
{
private function ean($length = 13)
{
$code = $this->numerify(str_repeat('#', $length - 1));
return $code . static::eanChecksum($code);
}
/**
* Utility function for computing EAN checksums
*/
protected static function eanChecksum($input)
{
$sequence = (strlen($input) - 1) == 8 ? array(3, 1) : array(1, 3);
$sums = 0;
foreach (str_split($input) as $n => $digit) {
$sums += $digit * $sequence[$n % 2];
}
return (10 - $sums % 10) % 10;
}
/**
* ISBN-10 check digit
* @link http://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digits
*
* @param string $input ISBN without check-digit
* @throws \LengthException When wrong input length passed
*
* @return integer Check digit
*/
protected static function isbnChecksum($input)
{
// We're calculating check digit for ISBN-10
// so, the length of the input should be 9
$length = 9;
if (strlen($input) != $length) {
throw new \LengthException(sprintf('Input length should be equal to %d', $length));
}
$digits = str_split($input);
array_walk(
$digits,
function (&$digit, $position) {
$digit = (10 - $position) * $digit;
}
);
$result = (11 - array_sum($digits) % 11) % 11;
// 10 is replaced by X
return ($result < 10)?$result:'X';
}
/**
* Get a random EAN13 barcode.
* @return string
* @example '4006381333931'
*/
public function ean13()
{
return $this->ean(13);
}
/**
* Get a random EAN8 barcode.
* @return string
* @example '73513537'
*/
public function ean8()
{
return $this->ean(8);
}
/**
* Get a random ISBN-10 code
* @link http://en.wikipedia.org/wiki/International_Standard_Book_Number
*
* @return string
* @example '4881416324'
*/
public function isbn10()
{
$code = $this->numerify(str_repeat('#', 9));
return $code . static::isbnChecksum($code);
}
/**
* Get a random ISBN-13 code
* @link http://en.wikipedia.org/wiki/International_Standard_Book_Number
*
* @return string
* @example '9790404436093'
*/
public function isbn13()
{
$code = '97' . static::numberBetween(8, 9) . $this->numerify(str_repeat('#', 9));
return $code . static::eanChecksum($code);
}
}

View File

@ -0,0 +1,509 @@
<?php
namespace Faker\Provider;
use Faker\Generator;
use Faker\DefaultGenerator;
use Faker\UniqueGenerator;
class Base
{
/**
* @var \Faker\Generator
*/
protected $generator;
/**
* @var \Faker\UniqueGenerator
*/
protected $unique;
/**
* @param \Faker\Generator $generator
*/
public function __construct(Generator $generator)
{
$this->generator = $generator;
}
/**
* Returns a random number between 0 and 9
*
* @return integer
*/
public static function randomDigit()
{
return mt_rand(0, 9);
}
/**
* Returns a random number between 1 and 9
*
* @return integer
*/
public static function randomDigitNotNull()
{
return mt_rand(1, 9);
}
/**
* Returns a random integer with 0 to $nbDigits digits.
*
* The maximum value returned is mt_getrandmax()
*
* @param integer $nbDigits Defaults to a random number between 1 and 9
* @param boolean $strict Whether the returned number should have exactly $nbDigits
* @example 79907610
*
* @return integer
*/
public static function randomNumber($nbDigits = null, $strict = false)
{
if (!is_bool($strict)) {
throw new \InvalidArgumentException('randomNumber() generates numbers of fixed width. To generate numbers between two boundaries, use numberBetween() instead.');
}
if (null === $nbDigits) {
$nbDigits = static::randomDigitNotNull();
}
$max = pow(10, $nbDigits) - 1;
if ($max > mt_getrandmax()) {
throw new \InvalidArgumentException('randomNumber() can only generate numbers up to mt_getrandmax()');
}
if ($strict) {
return mt_rand(pow(10, $nbDigits - 1), $max);
}
return mt_rand(0, $max);
}
/**
* Return a random float number
*
* @param int $nbMaxDecimals
* @param int|float $min
* @param int|float $max
* @example 48.8932
*
* @return float
*/
public static function randomFloat($nbMaxDecimals = null, $min = 0, $max = null)
{
if (null === $nbMaxDecimals) {
$nbMaxDecimals = static::randomDigit();
}
if (null === $max) {
$max = static::randomNumber();
}
if ($min > $max) {
$tmp = $min;
$min = $max;
$max = $tmp;
}
return round($min + mt_rand() / mt_getrandmax() * ($max - $min), $nbMaxDecimals);
}
/**
* Returns a random number between $min and $max
*
* @param integer $min default to 0
* @param integer $max defaults to 32 bit max integer, ie 2147483647
* @example 79907610
*
* @return integer
*/
public static function numberBetween($min = 0, $max = 2147483647)
{
return mt_rand($min, $max);
}
/**
* Returns a random letter from a to z
*
* @return string
*/
public static function randomLetter()
{
return chr(mt_rand(97, 122));
}
/**
* Returns a random ASCII character (excluding accents and special chars)
*/
public static function randomAscii()
{
return chr(mt_rand(33, 126));
}
/**
* Returns random elements from a provided array
*
* @param array $array Array to take elements from. Defaults to a-f
* @param integer $count Number of elements to take.
* @throws \LengthException When requesting more elements than provided
*
* @return array New array with $count elements from $array
*/
public static function randomElements(array $array = array('a', 'b', 'c'), $count = 1)
{
$allKeys = array_keys($array);
$numKeys = count($allKeys);
if ($numKeys < $count) {
throw new \LengthException(sprintf('Cannot get %d elements, only %d in array', $count, $numKeys));
}
$highKey = $numKeys - 1;
$keys = $elements = array();
$numElements = 0;
while ($numElements < $count) {
$num = mt_rand(0, $highKey);
if (isset($keys[$num])) {
continue;
}
$keys[$num] = true;
$elements[] = $array[$allKeys[$num]];
$numElements++;
}
return $elements;
}
/**
* Returns a random element from a passed array
*
* @param array $array
* @return mixed
*/
public static function randomElement($array = array('a', 'b', 'c'))
{
if (!$array) {
return null;
}
$elements = static::randomElements($array, 1);
return $elements[0];
}
/**
* Returns a random key from a passed associative array
*
* @param array $array
* @return int|string|null
*/
public static function randomKey($array = array())
{
if (!$array) {
return null;
}
$keys = array_keys($array);
$key = $keys[mt_rand(0, count($keys) - 1)];
return $key;
}
/**
* Returns a shuffled version of the argument.
*
* This function accepts either an array, or a string.
*
* @example $faker->shuffle([1, 2, 3]); // [2, 1, 3]
* @example $faker->shuffle('hello, world'); // 'rlo,h eold!lw'
*
* @see shuffleArray()
* @see shuffleString()
*
* @param array|string $arg The set to shuffle
* @return array|string The shuffled set
*/
public static function shuffle($arg = '')
{
if (is_array($arg)) {
return static::shuffleArray($arg);
}
if (is_string($arg)) {
return static::shuffleString($arg);
}
throw new \InvalidArgumentException('shuffle() only supports strings or arrays');
}
/**
* Returns a shuffled version of the array.
*
* This function does not mutate the original array. It uses the
* FisherYates algorithm, which is unbiaised, together with a Mersenne
* twister random generator. This function is therefore more random than
* PHP's shuffle() function, and it is seedable.
*
* @link http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
*
* @example $faker->shuffleArray([1, 2, 3]); // [2, 1, 3]
*
* @param array $array The set to shuffle
* @return array The shuffled set
*/
public static function shuffleArray($array = array())
{
$shuffledArray = array();
$i = 0;
reset($array);
while (list($key, $value) = each($array)) {
if ($i == 0) {
$j = 0;
} else {
$j = mt_rand(0, $i);
}
if ($j == $i) {
$shuffledArray[]= $value;
} else {
$shuffledArray[]= $shuffledArray[$j];
$shuffledArray[$j] = $value;
}
$i++;
}
return $shuffledArray;
}
/**
* Returns a shuffled version of the string.
*
* This function does not mutate the original string. It uses the
* FisherYates algorithm, which is unbiaised, together with a Mersenne
* twister random generator. This function is therefore more random than
* PHP's shuffle() function, and it is seedable. Additionally, it is
* UTF8 safe if the mb extension is available.
*
* @link http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
*
* @example $faker->shuffleString('hello, world'); // 'rlo,h eold!lw'
*
* @param string $string The set to shuffle
* @param string $encoding The string encoding (defaults to UTF-8)
* @return string The shuffled set
*/
public static function shuffleString($string = '', $encoding = 'UTF-8')
{
if (function_exists('mb_strlen')) {
// UTF8-safe str_split()
$array = array();
$strlen = mb_strlen($string, $encoding);
for ($i = 0; $i < $strlen; $i++) {
$array []= mb_substr($string, $i, 1, $encoding);
}
} else {
$array = str_split($string, 1);
}
return join('', static::shuffleArray($array));
}
/**
* Replaces all hash sign ('#') occurrences with a random number
* Replaces all percentage sign ('%') occurrences with a not null number
*
* @param string $string String that needs to bet parsed
* @return string
*/
public static function numerify($string = '###')
{
// instead of using randomDigit() several times, which is slow,
// count the number of hashes and generate once a large number
$toReplace = array();
for ($i = 0, $count = strlen($string); $i < $count; $i++) {
if ($string[$i] === '#') {
$toReplace []= $i;
}
}
if ($nbReplacements = count($toReplace)) {
$maxAtOnce = strlen((string) mt_getrandmax()) - 1;
$numbers = '';
$i = 0;
while ($i < $nbReplacements) {
$size = min($nbReplacements - $i, $maxAtOnce);
$numbers .= str_pad(static::randomNumber($size), $size, '0', STR_PAD_LEFT);
$i += $size;
}
for ($i = 0; $i < $nbReplacements; $i++) {
$string[$toReplace[$i]] = $numbers[$i];
}
}
$string = preg_replace_callback('/\%/u', 'static::randomDigitNotNull', $string);
return $string;
}
/**
* Replaces all question mark ('?') occurrences with a random letter
*
* @param string $string String that needs to bet parsed
* @return string
*/
public static function lexify($string = '????')
{
return preg_replace_callback('/\?/u', 'static::randomLetter', $string);
}
/**
* Replaces hash signs and question marks with random numbers and letters
*
* @param string $string String that needs to bet parsed
* @return string
*/
public static function bothify($string = '## ??')
{
return static::lexify(static::numerify($string));
}
/**
* Replaces * signs with random numbers and letters and special characters
*
* @example $faker->asciify(''********'); // "s5'G!uC3"
*
* @param string $string String that needs to bet parsed
* @return string
*/
public static function asciify($string = '****')
{
return preg_replace_callback('/\*/u', 'static::randomAscii', $string);
}
/**
* Transforms a basic regular expression into a random string satisfying the expression.
*
* @example $faker->regexify('[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}'); // sm0@y8k96a.ej
*
* Regex delimiters '/.../' and begin/end markers '^...$' are ignored.
*
* Only supports a small subset of the regex syntax. For instance,
* unicode, negated classes, unbouned ranges, subpatterns, back references,
* assertions, recursive patterns, and comments are not supported. Escaping
* support is extremely fragile.
*
* This method is also VERY slow. Use it only when no other formatter
* can generate the fake data you want. For instance, prefer calling
* `$faker->email` rather than `regexify` with the previous regular
* expression.
*
* Also note than `bothify` can probably do most of what this method does,
* but much faster. For instance, for a dummy email generation, try
* `$faker->bothify('?????????@???.???')`.
*
* @see https://github.com/icomefromthenet/ReverseRegex for a more robust implementation
*
* @param string $regex A regular expression (delimiters are optional)
* @return string
*/
public static function regexify($regex = '')
{
// ditch the anchors
$regex = preg_replace('/^\/?\^?/', '', $regex);
$regex = preg_replace('/\$?\/?$/', '', $regex);
// All {2} become {2,2}
$regex = preg_replace('/\{(\d+)\}/', '{\1,\1}', $regex);
// Single-letter quantifiers (?, *, +) become bracket quantifiers ({0,1}, {0,rand}, {1, rand})
$regex = preg_replace('/(?<!\\\)\?/', '{0,1}', $regex);
$regex = preg_replace('/(?<!\\\)\*/', '{0,' . static::randomDigitNotNull() . '}', $regex);
$regex = preg_replace('/(?<!\\\)\+/', '{1,' . static::randomDigitNotNull() . '}', $regex);
// [12]{1,2} becomes [12] or [12][12]
$regex = preg_replace_callback('/(\[[^\]]+\])\{(\d+),(\d+)\}/', function ($matches) {
return str_repeat($matches[1], Base::randomElement(range($matches[2], $matches[3])));
}, $regex);
// (12|34){1,2} becomes (12|34) or (12|34)(12|34)
$regex = preg_replace_callback('/(\([^\)]+\))\{(\d+),(\d+)\}/', function ($matches) {
return str_repeat($matches[1], Base::randomElement(range($matches[2], $matches[3])));
}, $regex);
// A{1,2} becomes A or AA or \d{3} becomes \d\d\d
$regex = preg_replace_callback('/(\\\?.)\{(\d+),(\d+)\}/', function ($matches) {
return str_repeat($matches[1], Base::randomElement(range($matches[2], $matches[3])));
}, $regex);
// (this|that) becomes 'this' or 'that'
$regex = preg_replace_callback('/\((.*?)\)/', function ($matches) {
return Base::randomElement(explode('|', str_replace(array('(', ')'), '', $matches[1])));
}, $regex);
// All A-F inside of [] become ABCDEF
$regex = preg_replace_callback('/\[([^\]]+)\]/', function ($matches) {
return '[' . preg_replace_callback('/(\w|\d)\-(\w|\d)/', function ($range) {
return join(range($range[1], $range[2]), '');
}, $matches[1]) . ']';
}, $regex);
// All [ABC] become B (or A or C)
$regex = preg_replace_callback('/\[([^\]]+)\]/', function ($matches) {
return Base::randomElement(str_split($matches[1]));
}, $regex);
// replace \d with number and \w with letter and . with ascii
$regex = preg_replace_callback('/\\\w/', 'static::randomLetter', $regex);
$regex = preg_replace_callback('/\\\d/', 'static::randomDigit', $regex);
$regex = preg_replace_callback('/(?<!\\\)\./', 'static::randomAscii', $regex);
// remove remaining backslashes
$regex = str_replace('\\', '', $regex);
// phew
return $regex;
}
/**
* Converts string to lowercase.
* Uses mb_string extension if available.
*
* @param string $string String that should be converted to lowercase
* @return string
*/
public static function toLower($string = '')
{
return extension_loaded('mbstring') ? mb_strtolower($string, 'UTF-8') : strtolower($string);
}
/**
* Converts string to uppercase.
* Uses mb_string extension if available.
*
* @param string $string String that should be converted to uppercase
* @return string
*/
public static function toUpper($string = '')
{
return extension_loaded('mbstring') ? mb_strtoupper($string, 'UTF-8') : strtoupper($string);
}
/**
* Chainable method for making any formatter optional.
*
* @param float $weight Set the probability of receiving a null value.
* "0" will always return null, "1" will always return the generator.
* @return Generator|DefaultGenerator
*/
public function optional($weight = 0.5, $default = null)
{
if (mt_rand() / mt_getrandmax() <= $weight) {
return $this->generator;
}
return new DefaultGenerator($default);
}
/**
* Chainable method for making any formatter unique.
*
* <code>
* // will never return twice the same value
* $faker->unique()->randomElement(array(1, 2, 3));
* </code>
*
* @param boolean $reset If set to true, resets the list of existing values
* @param integer $maxRetries Maximum number of retries to find a unique value,
* After which an OverflowException is thrown.
* @throws \OverflowException When no unique value can be found by iterating $maxRetries times
*
* @return UniqueGenerator A proxy class returning only non-existing values
*/
public function unique($reset = false, $maxRetries = 10000)
{
if ($reset || !$this->unique) {
$this->unique = new UniqueGenerator($this->generator, $maxRetries);
}
return $this->unique;
}
}

View File

@ -0,0 +1,64 @@
<?php
namespace Faker\Provider;
class Biased extends \Faker\Provider\Base
{
/**
* Returns a biased integer between $min and $max (both inclusive).
* The distribution depends on $function.
*
* The algorithm creates two doubles, x [0, 1], y [0, 1) and checks whether the
* return value of $function for x is greater than or equal to y. If this is
* the case the number is accepted and x is mapped to the appropriate integer
* between $min and $max. Otherwise two new doubles are created until the pair
* is accepted.
*
* @param integer $min Minimum value of the generated integers.
* @param integer $max Maximum value of the generated integers.
* @param callable $function A function mapping x [0, 1] onto a double [0, 1]
* @return integer An integer between $min and $max.
*/
public function biasedNumberBetween($min = 0, $max = 100, $function = 'sqrt')
{
do {
$x = mt_rand() / mt_getrandmax();
$y = mt_rand() / (mt_getrandmax() + 1);
} while (call_user_func($function, $x) < $y);
return floor($x * ($max - $min + 1) + $min);
}
/**
* 'unbiased' creates an unbiased distribution by giving
* each value the same value of one.
*
* @return integer
*/
protected static function unbiased($x)
{
return 1;
}
/**
* 'linearLow' favors lower numbers. The probability decreases
* in a linear fashion.
*
* @return integer
*/
protected static function linearLow($x)
{
return 1 - $x;
}
/**
* 'linearHigh' favors higher numbers. The probability increases
* in a linear fashion.
*
* @return integer
*/
protected static function linearHigh($x)
{
return $x;
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace Faker\Provider;
/**
* @author lsv
*/
class Color extends Base
{
protected static $safeColorNames = array(
'black', 'maroon', 'green', 'navy', 'olive',
'purple', 'teal', 'lime', 'blue', 'silver',
'gray', 'yellow', 'fuchsia', 'aqua', 'white'
);
protected static $allColorNames = array(
'AliceBlue', 'AntiqueWhite', 'Aqua', 'Aquamarine',
'Azure', 'Beige', 'Bisque', 'Black', 'BlanchedAlmond',
'Blue', 'BlueViolet', 'Brown', 'BurlyWood', 'CadetBlue',
'Chartreuse', 'Chocolate', 'Coral', 'CornflowerBlue',
'Cornsilk', 'Crimson', 'Cyan', 'DarkBlue', 'DarkCyan',
'DarkGoldenRod', 'DarkGray', 'DarkGreen', 'DarkKhaki',
'DarkMagenta', 'DarkOliveGreen', 'Darkorange', 'DarkOrchid',
'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue',
'DarkSlateGray', 'DarkTurquoise', 'DarkViolet', 'DeepPink',
'DeepSkyBlue', 'DimGray', 'DimGrey', 'DodgerBlue', 'FireBrick',
'FloralWhite', 'ForestGreen', 'Fuchsia', 'Gainsboro', 'GhostWhite',
'Gold', 'GoldenRod', 'Gray', 'Green', 'GreenYellow', 'HoneyDew',
'HotPink', 'IndianRed ', 'Indigo ', 'Ivory', 'Khaki', 'Lavender',
'LavenderBlush', 'LawnGreen', 'LemonChiffon', 'LightBlue', 'LightCoral',
'LightCyan', 'LightGoldenRodYellow', 'LightGray', 'LightGreen', 'LightPink',
'LightSalmon', 'LightSeaGreen', 'LightSkyBlue', 'LightSlateGray', 'LightSteelBlue',
'LightYellow', 'Lime', 'LimeGreen', 'Linen', 'Magenta', 'Maroon', 'MediumAquaMarine',
'MediumBlue', 'MediumOrchid', 'MediumPurple', 'MediumSeaGreen', 'MediumSlateBlue',
'MediumSpringGreen', 'MediumTurquoise', 'MediumVioletRed', 'MidnightBlue',
'MintCream', 'MistyRose', 'Moccasin', 'NavajoWhite', 'Navy', 'OldLace', 'Olive',
'OliveDrab', 'Orange', 'OrangeRed', 'Orchid', 'PaleGoldenRod', 'PaleGreen',
'PaleTurquoise', 'PaleVioletRed', 'PapayaWhip', 'PeachPuff', 'Peru', 'Pink', 'Plum',
'PowderBlue', 'Purple', 'Red', 'RosyBrown', 'RoyalBlue', 'SaddleBrown', 'Salmon',
'SandyBrown', 'SeaGreen', 'SeaShell', 'Sienna', 'Silver', 'SkyBlue', 'SlateBlue',
'SlateGray', 'Snow', 'SpringGreen', 'SteelBlue', 'Tan', 'Teal', 'Thistle', 'Tomato',
'Turquoise', 'Violet', 'Wheat', 'White', 'WhiteSmoke', 'Yellow', 'YellowGreen'
);
/**
* @example '#fa3cc2'
*/
public static function hexColor()
{
return '#' . str_pad(dechex(mt_rand(1, 16777215)), 6, '0', STR_PAD_LEFT);
}
/**
* @example '#ff0044'
*/
public static function safeHexColor()
{
$color = str_pad(dechex(mt_rand(0, 255)), 3, '0', STR_PAD_LEFT);
return '#' . $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
}
/**
* @example 'array(0,255,122)'
*/
public static function rgbColorAsArray()
{
$color = static::hexColor();
return array(
hexdec(substr($color, 1, 2)),
hexdec(substr($color, 3, 2)),
hexdec(substr($color, 5, 2))
);
}
/**
* @example '0,255,122'
*/
public static function rgbColor()
{
return implode(',', static::rgbColorAsArray());
}
/**
* @example 'rgb(0,255,122)'
*/
public static function rgbCssColor()
{
return 'rgb(' . static::rgbColor() . ')';
}
/**
* @example 'blue'
*/
public static function safeColorName()
{
return static::randomElement(static::$safeColorNames);
}
/**
* @example 'NavajoWhite'
*/
public static function colorName()
{
return static::randomElement(static::$allColorNames);
}
}

Some files were not shown because too many files have changed in this diff Show More