Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -153,7 +153,7 @@ class ClassLoader
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'));
|
||||
spl_autoload_register([$this, 'loadClass']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,7 +163,7 @@ class ClassLoader
|
|||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
spl_autoload_unregister([$this, 'loadClass']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,6 +275,6 @@ class ClassLoader
|
|||
{
|
||||
return class_exists($type, $autoload)
|
||||
|| interface_exists($type, $autoload)
|
||||
|| (function_exists('trait_exists') && trait_exists($type, $autoload));
|
||||
|| trait_exists($type, $autoload);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class EventManager
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_listeners = array();
|
||||
private $_listeners = [];
|
||||
|
||||
/**
|
||||
* Dispatches an event to all registered listeners.
|
||||
|
|
|
@ -141,7 +141,7 @@ abstract class AbstractManagerRegistry implements ManagerRegistry
|
|||
*/
|
||||
public function getConnections()
|
||||
{
|
||||
$connections = array();
|
||||
$connections = [];
|
||||
foreach ($this->connections as $name => $id) {
|
||||
$connections[$name] = $this->getService($id);
|
||||
}
|
||||
|
@ -195,8 +195,13 @@ abstract class AbstractManagerRegistry implements ManagerRegistry
|
|||
}
|
||||
|
||||
$proxyClass = new \ReflectionClass($class);
|
||||
|
||||
if ($proxyClass->implementsInterface($this->proxyInterfaceName)) {
|
||||
$class = $proxyClass->getParentClass()->getName();
|
||||
if (! $parentClass = $proxyClass->getParentClass()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$class = $parentClass->getName();
|
||||
}
|
||||
|
||||
foreach ($this->managers as $id) {
|
||||
|
@ -221,7 +226,7 @@ abstract class AbstractManagerRegistry implements ManagerRegistry
|
|||
*/
|
||||
public function getManagers()
|
||||
{
|
||||
$dms = array();
|
||||
$dms = [];
|
||||
foreach ($this->managers as $name => $id) {
|
||||
$dms[$name] = $this->getService($id);
|
||||
}
|
||||
|
@ -253,5 +258,7 @@ abstract class AbstractManagerRegistry implements ManagerRegistry
|
|||
// force the creation of a new document manager
|
||||
// if the current one is closed
|
||||
$this->resetService($this->managers[$name]);
|
||||
|
||||
return $this->getManager($name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
|||
/**
|
||||
* @var ClassMetadata[]
|
||||
*/
|
||||
private $loadedMetadata = array();
|
||||
private $loadedMetadata = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
|
@ -110,7 +110,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
|||
}
|
||||
|
||||
$driver = $this->getDriver();
|
||||
$metadata = array();
|
||||
$metadata = [];
|
||||
foreach ($driver->getAllClassNames() as $className) {
|
||||
$metadata[] = $this->getMetadataFor($className);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
|||
|
||||
try {
|
||||
if ($this->cacheDriver) {
|
||||
if (($cached = $this->cacheDriver->fetch($realClassName . $this->cacheSalt)) !== false) {
|
||||
if (($cached = $this->cacheDriver->fetch($realClassName . $this->cacheSalt)) instanceof ClassMetadata) {
|
||||
$this->loadedMetadata[$realClassName] = $cached;
|
||||
|
||||
$this->wakeupReflection($cached, $this->getReflectionService());
|
||||
|
@ -277,7 +277,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
|||
protected function getParentClasses($name)
|
||||
{
|
||||
// Collect parent classes, ignoring transient (not-mapped) classes.
|
||||
$parentClasses = array();
|
||||
$parentClasses = [];
|
||||
foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) {
|
||||
if ( ! $this->getDriver()->isTransient($parentClass)) {
|
||||
$parentClasses[] = $parentClass;
|
||||
|
@ -306,7 +306,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
|||
$this->initialize();
|
||||
}
|
||||
|
||||
$loaded = array();
|
||||
$loaded = [];
|
||||
|
||||
$parentClasses = $this->getParentClasses($name);
|
||||
$parentClasses[] = $name;
|
||||
|
@ -314,7 +314,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
|||
// Move down the hierarchy of parent classes, starting from the topmost class
|
||||
$parent = null;
|
||||
$rootEntityFound = false;
|
||||
$visited = array();
|
||||
$visited = [];
|
||||
$reflService = $this->getReflectionService();
|
||||
foreach ($parentClasses as $className) {
|
||||
if (isset($this->loadedMetadata[$className])) {
|
||||
|
|
|
@ -45,14 +45,14 @@ abstract class AnnotationDriver implements MappingDriver
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $paths = array();
|
||||
protected $paths = [];
|
||||
|
||||
/**
|
||||
* The paths excluded from path where to look for mapping files.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $excludePaths = array();
|
||||
protected $excludePaths = [];
|
||||
|
||||
/**
|
||||
* The file extension of mapping documents.
|
||||
|
@ -73,7 +73,7 @@ abstract class AnnotationDriver implements MappingDriver
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $entityAnnotationClasses = array();
|
||||
protected $entityAnnotationClasses = [];
|
||||
|
||||
/**
|
||||
* Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
|
||||
|
@ -200,8 +200,8 @@ abstract class AnnotationDriver implements MappingDriver
|
|||
throw MappingException::pathRequired();
|
||||
}
|
||||
|
||||
$classes = array();
|
||||
$includedFiles = array();
|
||||
$classes = [];
|
||||
$includedFiles = [];
|
||||
|
||||
foreach ($this->paths as $path) {
|
||||
if ( ! is_dir($path)) {
|
||||
|
|
|
@ -37,7 +37,7 @@ class DefaultFileLocator implements FileLocator
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $paths = array();
|
||||
protected $paths = [];
|
||||
|
||||
/**
|
||||
* The file extension of mapping documents.
|
||||
|
@ -125,7 +125,7 @@ class DefaultFileLocator implements FileLocator
|
|||
*/
|
||||
public function getAllClassNames($globalBasename)
|
||||
{
|
||||
$classes = array();
|
||||
$classes = [];
|
||||
|
||||
if ($this->paths) {
|
||||
foreach ($this->paths as $path) {
|
||||
|
|
|
@ -117,6 +117,8 @@ abstract class FileDriver implements MappingDriver
|
|||
throw MappingException::invalidMappingFile($className, str_replace('\\', '.', $className) . $this->locator->getFileExtension());
|
||||
}
|
||||
|
||||
$this->classCache[$className] = $result[$className];
|
||||
|
||||
return $result[$className];
|
||||
}
|
||||
|
||||
|
@ -145,11 +147,14 @@ abstract class FileDriver implements MappingDriver
|
|||
$this->initialize();
|
||||
}
|
||||
|
||||
$classNames = (array)$this->locator->getAllClassNames($this->globalBasename);
|
||||
if ($this->classCache) {
|
||||
$classNames = array_merge(array_keys($this->classCache), $classNames);
|
||||
if (! $this->classCache) {
|
||||
return (array) $this->locator->getAllClassNames($this->globalBasename);
|
||||
}
|
||||
return $classNames;
|
||||
|
||||
return array_merge(
|
||||
array_keys($this->classCache),
|
||||
(array) $this->locator->getAllClassNames($this->globalBasename)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,7 +180,7 @@ abstract class FileDriver implements MappingDriver
|
|||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
$this->classCache = array();
|
||||
$this->classCache = [];
|
||||
if (null !== $this->globalBasename) {
|
||||
foreach ($this->locator->getPaths() as $path) {
|
||||
$file = $path.'/'.$this->globalBasename.$this->locator->getFileExtension();
|
||||
|
|
|
@ -39,12 +39,12 @@ class MappingDriverChain implements MappingDriver
|
|||
*
|
||||
* @var MappingDriver|null
|
||||
*/
|
||||
private $defaultDriver = null;
|
||||
private $defaultDriver;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $drivers = array();
|
||||
private $drivers = [];
|
||||
|
||||
/**
|
||||
* Gets the default driver.
|
||||
|
@ -117,8 +117,8 @@ class MappingDriverChain implements MappingDriver
|
|||
*/
|
||||
public function getAllClassNames()
|
||||
{
|
||||
$classNames = array();
|
||||
$driverClasses = array();
|
||||
$classNames = [];
|
||||
$driverClasses = [];
|
||||
|
||||
/* @var $driver MappingDriver */
|
||||
foreach ($this->drivers AS $namespace => $driver) {
|
||||
|
|
|
@ -44,8 +44,7 @@ class PHPDriver extends FileDriver
|
|||
*/
|
||||
public function __construct($locator, $fileExtension = null)
|
||||
{
|
||||
$fileExtension = ".php";
|
||||
parent::__construct($locator, $fileExtension);
|
||||
parent::__construct($locator, '.php');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,6 +53,7 @@ class PHPDriver extends FileDriver
|
|||
public function loadMetadataForClass($className, ClassMetadata $metadata)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
|
||||
$this->loadMappingFile($this->locator->findMappingFile($className));
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,6 @@ class PHPDriver extends FileDriver
|
|||
$metadata = $this->metadata;
|
||||
include $file;
|
||||
|
||||
return array($metadata->getName() => $metadata);
|
||||
return [$metadata->getName() => $metadata];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class StaticPHPDriver implements MappingDriver
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $paths = array();
|
||||
private $paths = [];
|
||||
|
||||
/**
|
||||
* Map of all class names.
|
||||
|
@ -93,8 +93,8 @@ class StaticPHPDriver implements MappingDriver
|
|||
throw MappingException::pathRequired();
|
||||
}
|
||||
|
||||
$classes = array();
|
||||
$includedFiles = array();
|
||||
$classes = [];
|
||||
$includedFiles = [];
|
||||
|
||||
foreach ($this->paths as $path) {
|
||||
if (!is_dir($path)) {
|
||||
|
|
|
@ -37,14 +37,14 @@ class SymfonyFileLocator implements FileLocator
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $paths = array();
|
||||
protected $paths = [];
|
||||
|
||||
/**
|
||||
* A map of mapping directory path to namespace prefix used to expand class shortnames.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $prefixes = array();
|
||||
protected $prefixes = [];
|
||||
|
||||
/**
|
||||
* File extension that is searched for.
|
||||
|
@ -153,7 +153,9 @@ class SymfonyFileLocator implements FileLocator
|
|||
}
|
||||
|
||||
$filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', $this->nsSeparator).$this->fileExtension;
|
||||
return is_file($filename);
|
||||
if (is_file($filename)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -164,7 +166,7 @@ class SymfonyFileLocator implements FileLocator
|
|||
*/
|
||||
public function getAllClassNames($globalBasename = null)
|
||||
{
|
||||
$classes = array();
|
||||
$classes = [];
|
||||
|
||||
if ($this->paths) {
|
||||
foreach ((array) $this->paths as $path) {
|
||||
|
@ -194,7 +196,7 @@ class SymfonyFileLocator implements FileLocator
|
|||
'\\'
|
||||
);
|
||||
|
||||
$classes[] = $this->prefixes[$path] . $nsSuffix . '\\' .str_replace($this->nsSeparator, '\\', $fileName);
|
||||
$classes[] = $this->prefixes[$path] . str_replace(DIRECTORY_SEPARATOR, '\\', $nsSuffix) . '\\' .str_replace($this->nsSeparator, '\\', $fileName);
|
||||
} else {
|
||||
$classes[] = str_replace($this->nsSeparator, '\\', $fileName);
|
||||
}
|
||||
|
@ -230,8 +232,6 @@ class SymfonyFileLocator implements FileLocator
|
|||
if (is_file($filename)) {
|
||||
return $filename;
|
||||
}
|
||||
|
||||
throw MappingException::mappingFileNotFound($className, $filename);
|
||||
}
|
||||
|
||||
throw MappingException::mappingFileNotFound($className, substr($className, strrpos($className, '\\') + 1).$this->fileExtension);
|
||||
|
|
|
@ -31,7 +31,7 @@ class StaticReflectionService implements ReflectionService
|
|||
*/
|
||||
public function getParentClasses($class)
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,7 @@ interface ObjectRepository
|
|||
*
|
||||
* @param mixed $id The identifier.
|
||||
*
|
||||
* @return object The object.
|
||||
* @return object|null The object.
|
||||
*/
|
||||
public function find($id);
|
||||
|
||||
|
@ -68,7 +68,7 @@ interface ObjectRepository
|
|||
*
|
||||
* @param array $criteria The criteria.
|
||||
*
|
||||
* @return object The object.
|
||||
* @return object|null The object.
|
||||
*/
|
||||
public function findOneBy(array $criteria);
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ abstract class PersistentObject implements ObjectManagerAware
|
|||
throw new \InvalidArgumentException("Expected persistent object of type '".$targetClass."'");
|
||||
}
|
||||
if (!($this->$field instanceof Collection)) {
|
||||
$this->$field = new ArrayCollection($this->$field ?: array());
|
||||
$this->$field = new ArrayCollection($this->$field ?: []);
|
||||
}
|
||||
$this->$field->add($args[0]);
|
||||
$this->completeOwningSide($field, $targetClass, $args[0]);
|
||||
|
|
|
@ -87,7 +87,7 @@ abstract class AbstractProxyFactory
|
|||
/**
|
||||
* @var \Doctrine\Common\Proxy\ProxyDefinition[]
|
||||
*/
|
||||
private $definitions = array();
|
||||
private $definitions = [];
|
||||
|
||||
/**
|
||||
* @param \Doctrine\Common\Proxy\ProxyGenerator $proxyGenerator
|
||||
|
|
|
@ -49,9 +49,13 @@ class Autoloader
|
|||
throw InvalidArgumentException::notProxyClass($className, $proxyNamespace);
|
||||
}
|
||||
|
||||
$className = str_replace('\\', '', substr($className, strlen($proxyNamespace) + 1));
|
||||
// remove proxy namespace from class name
|
||||
$classNameRelativeToProxyNamespace = substr($className, strlen($proxyNamespace));
|
||||
|
||||
return $proxyDir . DIRECTORY_SEPARATOR . $className . '.php';
|
||||
// remove namespace separators from remaining class name
|
||||
$fileName = str_replace('\\', '', $classNameRelativeToProxyNamespace);
|
||||
|
||||
return $proxyDir . DIRECTORY_SEPARATOR . $fileName . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,15 +41,19 @@ class UnexpectedValueException extends BaseUnexpectedValueException implements P
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $methodName
|
||||
* @param string $parameterName
|
||||
* @param \Exception $previous
|
||||
* @param string $className
|
||||
* @param string $methodName
|
||||
* @param string $parameterName
|
||||
* @param \Exception|null $previous
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function invalidParameterTypeHint($className, $methodName, $parameterName, \Exception $previous)
|
||||
{
|
||||
public static function invalidParameterTypeHint(
|
||||
$className,
|
||||
$methodName,
|
||||
$parameterName,
|
||||
\Exception $previous = null
|
||||
) {
|
||||
return new self(
|
||||
sprintf(
|
||||
'The type hint of parameter "%s" in method "%s" in class "%s" is invalid.',
|
||||
|
@ -61,4 +65,24 @@ class UnexpectedValueException extends BaseUnexpectedValueException implements P
|
|||
$previous
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $className
|
||||
* @param $methodName
|
||||
* @param \Exception|null $previous
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function invalidReturnTypeHint($className, $methodName, \Exception $previous = null)
|
||||
{
|
||||
return new self(
|
||||
sprintf(
|
||||
'The return type of method "%s" in class "%s" is invalid.',
|
||||
$methodName,
|
||||
$className
|
||||
),
|
||||
0,
|
||||
$previous
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class ProxyGenerator
|
|||
* Used to match very simple id methods that don't need
|
||||
* to be decorated since the identifier is known.
|
||||
*/
|
||||
const PATTERN_MATCH_ID_METHOD = '((public\s+)?(function\s+%s\s*\(\)\s*)\s*{\s*return\s*\$this->%s;\s*})i';
|
||||
const PATTERN_MATCH_ID_METHOD = '((public\s+)?(function\s+%s\s*\(\)\s*)\s*(?::\s*\??\s*\\\\?[a-z_\x7f-\xff][\w\x7f-\xff]*(?:\\\\[a-z_\x7f-\xff][\w\x7f-\xff]*)*\s*)?{\s*return\s*\$this->%s;\s*})i';
|
||||
|
||||
/**
|
||||
* The namespace that contains all proxy classes.
|
||||
|
@ -58,10 +58,10 @@ class ProxyGenerator
|
|||
*
|
||||
* @var string[]|callable[]
|
||||
*/
|
||||
protected $placeholders = array(
|
||||
'baseProxyInterface' => 'Doctrine\Common\Proxy\Proxy',
|
||||
protected $placeholders = [
|
||||
'baseProxyInterface' => Proxy::class,
|
||||
'additionalProperties' => '',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Template used as a blueprint to generate proxies.
|
||||
|
@ -106,7 +106,7 @@ class <proxyShortClassName> extends \<className> implements \<baseProxyInterface
|
|||
*
|
||||
* @see \Doctrine\Common\Persistence\Proxy::__getLazyProperties
|
||||
*/
|
||||
public static $lazyPropertiesDefaults = array(<lazyPropertiesDefaults>);
|
||||
public static $lazyPropertiesDefaults = [<lazyPropertiesDefaults>];
|
||||
|
||||
<additionalProperties>
|
||||
|
||||
|
@ -129,7 +129,7 @@ class <proxyShortClassName> extends \<className> implements \<baseProxyInterface
|
|||
*/
|
||||
public function __load()
|
||||
{
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, \'__load\', array());
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, \'__load\', []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -263,12 +263,12 @@ class <proxyShortClassName> extends \<className> implements \<baseProxyInterface
|
|||
preg_match_all('(<([a-zA-Z]+)>)', $this->proxyClassTemplate, $placeholderMatches);
|
||||
|
||||
$placeholderMatches = array_combine($placeholderMatches[0], $placeholderMatches[1]);
|
||||
$placeholders = array();
|
||||
$placeholders = [];
|
||||
|
||||
foreach ($placeholderMatches as $placeholder => $name) {
|
||||
$placeholders[$placeholder] = isset($this->placeholders[$name])
|
||||
? $this->placeholders[$name]
|
||||
: array($this, 'generate' . $name);
|
||||
: [$this, 'generate' . $name];
|
||||
}
|
||||
|
||||
foreach ($placeholders as & $placeholder) {
|
||||
|
@ -302,7 +302,7 @@ class <proxyShortClassName> extends \<className> implements \<baseProxyInterface
|
|||
$tmpFileName = $fileName . '.' . uniqid('', true);
|
||||
|
||||
file_put_contents($tmpFileName, $proxyCode);
|
||||
chmod($tmpFileName, 0664);
|
||||
@chmod($tmpFileName, 0664);
|
||||
rename($tmpFileName, $fileName);
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ class <proxyShortClassName> extends \<className> implements \<baseProxyInterface
|
|||
private function generateLazyPropertiesDefaults(ClassMetadata $class)
|
||||
{
|
||||
$lazyPublicProperties = $this->getLazyLoadedPublicProperties($class);
|
||||
$values = array();
|
||||
$values = [];
|
||||
|
||||
foreach ($lazyPublicProperties as $key => $value) {
|
||||
$values[] = var_export($key, true) . ' => ' . var_export($value, true);
|
||||
|
@ -385,7 +385,7 @@ class <proxyShortClassName> extends \<className> implements \<baseProxyInterface
|
|||
{
|
||||
|
||||
EOT;
|
||||
$toUnset = array();
|
||||
$toUnset = [];
|
||||
|
||||
foreach ($this->getLazyLoadedPublicProperties($class) as $lazyPublicProperty => $unused) {
|
||||
$toUnset[] = '$this->' . $lazyPublicProperty;
|
||||
|
@ -443,7 +443,7 @@ EOT;
|
|||
if ( ! empty($lazyPublicProperties)) {
|
||||
$magicGet .= <<<'EOT'
|
||||
if (array_key_exists($name, $this->__getLazyProperties())) {
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__get', array($name));
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__get', [$name]);
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ EOT;
|
|||
|
||||
if ($hasParentGet) {
|
||||
$magicGet .= <<<'EOT'
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__get', array($name));
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__get', [$name]);
|
||||
|
||||
return parent::__get($name);
|
||||
|
||||
|
@ -502,7 +502,7 @@ EOT;
|
|||
if ( ! empty($lazyPublicProperties)) {
|
||||
$magicSet .= <<<'EOT'
|
||||
if (array_key_exists($name, $this->__getLazyProperties())) {
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__set', array($name, $value));
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__set', [$name, $value]);
|
||||
|
||||
$this->$name = $value;
|
||||
|
||||
|
@ -515,7 +515,7 @@ EOT;
|
|||
|
||||
if ($hasParentSet) {
|
||||
$magicSet .= <<<'EOT'
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__set', array($name, $value));
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__set', [$name, $value]);
|
||||
|
||||
return parent::__set($name, $value);
|
||||
EOT;
|
||||
|
@ -559,7 +559,7 @@ EOT;
|
|||
if ( ! empty($lazyPublicProperties)) {
|
||||
$magicIsset .= <<<'EOT'
|
||||
if (array_key_exists($name, $this->__getLazyProperties())) {
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', array($name));
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', [$name]);
|
||||
|
||||
return isset($this->$name);
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ EOT;
|
|||
|
||||
if ($hasParentIsset) {
|
||||
$magicIsset .= <<<'EOT'
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', array($name));
|
||||
$this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', [$name]);
|
||||
|
||||
return parent::__isset($name);
|
||||
|
||||
|
@ -605,7 +605,7 @@ EOT;
|
|||
|
||||
if ($hasParentSleep) {
|
||||
return $sleepImpl . <<<'EOT'
|
||||
$properties = array_merge(array('__isInitialized__'), parent::__sleep());
|
||||
$properties = array_merge(['__isInitialized__'], parent::__sleep());
|
||||
|
||||
if ($this->__isInitialized__) {
|
||||
$properties = array_diff($properties, array_keys($this->__getLazyProperties()));
|
||||
|
@ -616,7 +616,7 @@ EOT;
|
|||
EOT;
|
||||
}
|
||||
|
||||
$allProperties = array('__isInitialized__');
|
||||
$allProperties = ['__isInitialized__'];
|
||||
|
||||
/* @var $prop \ReflectionProperty */
|
||||
foreach ($class->getReflectionClass()->getProperties() as $prop) {
|
||||
|
@ -645,10 +645,10 @@ EOT;
|
|||
|
||||
return $sleepImpl . <<<EOT
|
||||
if (\$this->__isInitialized__) {
|
||||
return array($allProperties);
|
||||
return [$allProperties];
|
||||
}
|
||||
|
||||
return array($protectedProperties);
|
||||
return [$protectedProperties];
|
||||
}
|
||||
EOT;
|
||||
}
|
||||
|
@ -662,7 +662,7 @@ EOT;
|
|||
*/
|
||||
private function generateWakeupImpl(ClassMetadata $class)
|
||||
{
|
||||
$unsetPublicProperties = array();
|
||||
$unsetPublicProperties = [];
|
||||
$hasWakeup = $class->getReflectionClass()->hasMethod('__wakeup');
|
||||
|
||||
foreach (array_keys($this->getLazyLoadedPublicProperties($class)) as $lazyPublicProperty) {
|
||||
|
@ -727,7 +727,7 @@ EOT;
|
|||
*/
|
||||
public function __clone()
|
||||
{
|
||||
\$this->__cloner__ && \$this->__cloner__->__invoke(\$this, '__clone', array());
|
||||
\$this->__cloner__ && \$this->__cloner__->__invoke(\$this, '__clone', []);
|
||||
$callParentClone }
|
||||
EOT;
|
||||
}
|
||||
|
@ -742,16 +742,16 @@ EOT;
|
|||
private function generateMethods(ClassMetadata $class)
|
||||
{
|
||||
$methods = '';
|
||||
$methodNames = array();
|
||||
$methodNames = [];
|
||||
$reflectionMethods = $class->getReflectionClass()->getMethods(\ReflectionMethod::IS_PUBLIC);
|
||||
$skippedMethods = array(
|
||||
$skippedMethods = [
|
||||
'__sleep' => true,
|
||||
'__clone' => true,
|
||||
'__wakeup' => true,
|
||||
'__get' => true,
|
||||
'__set' => true,
|
||||
'__isset' => true,
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($reflectionMethods as $method) {
|
||||
$name = $method->getName();
|
||||
|
@ -778,15 +778,18 @@ EOT;
|
|||
}
|
||||
|
||||
$methods .= $name . '(' . $this->buildParametersString($class, $method, $method->getParameters()) . ')';
|
||||
$methods .= $this->getMethodReturnType($method);
|
||||
$methods .= "\n" . ' {' . "\n";
|
||||
|
||||
if ($this->isShortIdentifierGetter($method, $class)) {
|
||||
$identifier = lcfirst(substr($name, 3));
|
||||
$fieldType = $class->getTypeOfField($identifier);
|
||||
$cast = in_array($fieldType, array('integer', 'smallint')) ? '(int) ' : '';
|
||||
$cast = in_array($fieldType, ['integer', 'smallint']) ? '(int) ' : '';
|
||||
|
||||
$methods .= ' if ($this->__isInitialized__ === false) {' . "\n";
|
||||
$methods .= ' return ' . $cast . ' parent::' . $method->getName() . "();\n";
|
||||
$methods .= ' ';
|
||||
$methods .= $this->shouldProxiedMethodReturn($method) ? 'return ' : '';
|
||||
$methods .= $cast . ' parent::' . $method->getName() . "();\n";
|
||||
$methods .= ' }' . "\n\n";
|
||||
}
|
||||
|
||||
|
@ -795,8 +798,10 @@ EOT;
|
|||
|
||||
$methods .= "\n \$this->__initializer__ "
|
||||
. "&& \$this->__initializer__->__invoke(\$this, " . var_export($name, true)
|
||||
. ", array(" . $invokeParamsString . "));"
|
||||
. "\n\n return parent::" . $name . '(' . $callParamsString . ');'
|
||||
. ", [" . $invokeParamsString . "]);"
|
||||
. "\n\n "
|
||||
. ($this->shouldProxiedMethodReturn($method) ? 'return ' : '')
|
||||
. "parent::" . $name . '(' . $callParamsString . ');'
|
||||
. "\n" . ' }' . "\n";
|
||||
}
|
||||
|
||||
|
@ -872,7 +877,7 @@ EOT;
|
|||
private function getLazyLoadedPublicProperties(ClassMetadata $class)
|
||||
{
|
||||
$defaultProperties = $class->getReflectionClass()->getDefaultProperties();
|
||||
$properties = array();
|
||||
$properties = [];
|
||||
|
||||
foreach ($class->getReflectionClass()->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
|
||||
$name = $property->getName();
|
||||
|
@ -894,7 +899,7 @@ EOT;
|
|||
*/
|
||||
private function buildParametersString(ClassMetadata $class, \ReflectionMethod $method, array $parameters)
|
||||
{
|
||||
$parameterDefinitions = array();
|
||||
$parameterDefinitions = [];
|
||||
|
||||
/* @var $param \ReflectionParameter */
|
||||
foreach ($parameters as $param) {
|
||||
|
@ -908,10 +913,8 @@ EOT;
|
|||
$parameterDefinition .= '&';
|
||||
}
|
||||
|
||||
if (method_exists($param, 'isVariadic')) {
|
||||
if ($param->isVariadic()) {
|
||||
$parameterDefinition .= '...';
|
||||
}
|
||||
if (method_exists($param, 'isVariadic') && $param->isVariadic()) {
|
||||
$parameterDefinition .= '...';
|
||||
}
|
||||
|
||||
$parameters[] = '$' . $param->getName();
|
||||
|
@ -936,13 +939,20 @@ EOT;
|
|||
*/
|
||||
private function getParameterType(ClassMetadata $class, \ReflectionMethod $method, \ReflectionParameter $parameter)
|
||||
{
|
||||
if (method_exists($parameter, 'hasType')) {
|
||||
if ( ! $parameter->hasType()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// We need to pick the type hint class too
|
||||
return $this->formatType($parameter->getType(), $parameter->getDeclaringFunction(), $parameter);
|
||||
}
|
||||
|
||||
// For PHP 5.x, we need to pick the type hint in the old way (to be removed for PHP 7.0+)
|
||||
if ($parameter->isArray()) {
|
||||
return 'array';
|
||||
}
|
||||
|
||||
if (method_exists($parameter, 'isCallable') && $parameter->isCallable()) {
|
||||
if ($parameter->isCallable()) {
|
||||
return 'callable';
|
||||
}
|
||||
|
||||
|
@ -990,10 +1000,8 @@ EOT;
|
|||
function (\ReflectionParameter $parameter) {
|
||||
$name = '';
|
||||
|
||||
if (method_exists($parameter, 'isVariadic')) {
|
||||
if ($parameter->isVariadic()) {
|
||||
$name .= '...';
|
||||
}
|
||||
if (method_exists($parameter, 'isVariadic') && $parameter->isVariadic()) {
|
||||
$name .= '...';
|
||||
}
|
||||
|
||||
$name .= '$' . $parameter->getName();
|
||||
|
@ -1003,4 +1011,83 @@ EOT;
|
|||
$parameters
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Param \ReflectionMethod $method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getMethodReturnType(\ReflectionMethod $method)
|
||||
{
|
||||
if ( ! method_exists($method, 'hasReturnType') || ! $method->hasReturnType()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return ': ' . $this->formatType($method->getReturnType(), $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ReflectionMethod $method
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function shouldProxiedMethodReturn(\ReflectionMethod $method)
|
||||
{
|
||||
if ( ! method_exists($method, 'hasReturnType') || ! $method->hasReturnType()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return 'void' !== strtolower($this->formatType($method->getReturnType(), $method));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ReflectionType $type
|
||||
* @param \ReflectionMethod $method
|
||||
* @param \ReflectionParameter|null $parameter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function formatType(
|
||||
\ReflectionType $type,
|
||||
\ReflectionMethod $method,
|
||||
\ReflectionParameter $parameter = null
|
||||
) {
|
||||
$name = method_exists($type, 'getName') ? $type->getName() : (string) $type;
|
||||
$nameLower = strtolower($name);
|
||||
|
||||
if ('self' === $nameLower) {
|
||||
$name = $method->getDeclaringClass()->getName();
|
||||
}
|
||||
|
||||
if ('parent' === $nameLower) {
|
||||
$name = $method->getDeclaringClass()->getParentClass()->getName();
|
||||
}
|
||||
|
||||
if ( ! $type->isBuiltin() && ! class_exists($name) && ! interface_exists($name)) {
|
||||
if (null !== $parameter) {
|
||||
throw UnexpectedValueException::invalidParameterTypeHint(
|
||||
$method->getDeclaringClass()->getName(),
|
||||
$method->getName(),
|
||||
$parameter->getName()
|
||||
);
|
||||
}
|
||||
|
||||
throw UnexpectedValueException::invalidReturnTypeHint(
|
||||
$method->getDeclaringClass()->getName(),
|
||||
$method->getName()
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $type->isBuiltin()) {
|
||||
$name = '\\' . $name;
|
||||
}
|
||||
|
||||
if ($type->allowsNull()
|
||||
&& (null === $parameter || ! $parameter->isDefaultValueAvailable() || null !== $parameter->getDefaultValue())
|
||||
) {
|
||||
$name = '?' . $name;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ class StaticReflectionClass extends ReflectionClass
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function newInstanceArgs(array $args = array())
|
||||
public function newInstanceArgs(array $args = [])
|
||||
{
|
||||
throw new ReflectionException('Method not implemented');
|
||||
}
|
||||
|
|
|
@ -69,18 +69,18 @@ class StaticReflectionParser implements ReflectionProviderInterface
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $useStatements = array();
|
||||
protected $useStatements = [];
|
||||
|
||||
/**
|
||||
* The docComment of the class.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $docComment = array(
|
||||
protected $docComment = [
|
||||
'class' => '',
|
||||
'property' => array(),
|
||||
'method' => array()
|
||||
);
|
||||
'property' => [],
|
||||
'method' => []
|
||||
];
|
||||
|
||||
/**
|
||||
* The name of the class this class extends, if any.
|
||||
|
|
|
@ -91,7 +91,7 @@ class StaticReflectionProperty extends ReflectionProperty
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function export ($class, $name, $return = false)
|
||||
public static function export($class, $name, $return = false)
|
||||
{
|
||||
throw new ReflectionException('Method not implemented');
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ class StaticReflectionProperty extends ReflectionProperty
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setAccessible ($accessible)
|
||||
public function setAccessible($accessible)
|
||||
{
|
||||
throw new ReflectionException('Method not implemented');
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ class StaticReflectionProperty extends ReflectionProperty
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setValue ($object, $value = null)
|
||||
public function setValue($object, $value = null)
|
||||
{
|
||||
throw new ReflectionException('Method not implemented');
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
namespace Doctrine\Common\Util;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Persistence\Proxy;
|
||||
|
||||
/**
|
||||
|
@ -64,7 +65,7 @@ final class Debug
|
|||
ini_set('xdebug.var_display_max_depth', $maxDepth);
|
||||
}
|
||||
|
||||
$var = self::export($var, $maxDepth++);
|
||||
$var = self::export($var, $maxDepth);
|
||||
|
||||
ob_start();
|
||||
var_dump($var);
|
||||
|
@ -76,11 +77,11 @@ final class Debug
|
|||
$dumpText = ($stripTags ? strip_tags(html_entity_decode($dump)) : $dump);
|
||||
|
||||
ini_set('html_errors', $html);
|
||||
|
||||
|
||||
if ($echo) {
|
||||
echo $dumpText;
|
||||
}
|
||||
|
||||
|
||||
return $dumpText;
|
||||
}
|
||||
|
||||
|
@ -95,51 +96,90 @@ final class Debug
|
|||
$return = null;
|
||||
$isObj = is_object($var);
|
||||
|
||||
if ($isObj && in_array('Doctrine\Common\Collections\Collection', class_implements($var))) {
|
||||
if ($var instanceof Collection) {
|
||||
$var = $var->toArray();
|
||||
}
|
||||
|
||||
if ($maxDepth) {
|
||||
if (is_array($var)) {
|
||||
$return = array();
|
||||
|
||||
foreach ($var as $k => $v) {
|
||||
$return[$k] = self::export($v, $maxDepth - 1);
|
||||
}
|
||||
} else if ($isObj) {
|
||||
$return = new \stdclass();
|
||||
if ($var instanceof \DateTime) {
|
||||
$return->__CLASS__ = "DateTime";
|
||||
$return->date = $var->format('c');
|
||||
$return->timezone = $var->getTimeZone()->getName();
|
||||
} else {
|
||||
$reflClass = ClassUtils::newReflectionObject($var);
|
||||
$return->__CLASS__ = ClassUtils::getClass($var);
|
||||
|
||||
if ($var instanceof Proxy) {
|
||||
$return->__IS_PROXY__ = true;
|
||||
$return->__PROXY_INITIALIZED__ = $var->__isInitialized();
|
||||
}
|
||||
|
||||
if ($var instanceof \ArrayObject || $var instanceof \ArrayIterator) {
|
||||
$return->__STORAGE__ = self::export($var->getArrayCopy(), $maxDepth - 1);
|
||||
}
|
||||
|
||||
foreach ($reflClass->getProperties() as $reflProperty) {
|
||||
$name = $reflProperty->getName();
|
||||
|
||||
$reflProperty->setAccessible(true);
|
||||
$return->$name = self::export($reflProperty->getValue($var), $maxDepth - 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$return = $var;
|
||||
}
|
||||
} else {
|
||||
$return = is_object($var) ? get_class($var)
|
||||
if (! $maxDepth) {
|
||||
return is_object($var) ? get_class($var)
|
||||
: (is_array($var) ? 'Array(' . count($var) . ')' : $var);
|
||||
}
|
||||
|
||||
if (is_array($var)) {
|
||||
$return = [];
|
||||
|
||||
foreach ($var as $k => $v) {
|
||||
$return[$k] = self::export($v, $maxDepth - 1);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
if (! $isObj) {
|
||||
return $var;
|
||||
}
|
||||
|
||||
$return = new \stdclass();
|
||||
if ($var instanceof \DateTimeInterface) {
|
||||
$return->__CLASS__ = get_class($var);
|
||||
$return->date = $var->format('c');
|
||||
$return->timezone = $var->getTimezone()->getName();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
$return->__CLASS__ = ClassUtils::getClass($var);
|
||||
|
||||
if ($var instanceof Proxy) {
|
||||
$return->__IS_PROXY__ = true;
|
||||
$return->__PROXY_INITIALIZED__ = $var->__isInitialized();
|
||||
}
|
||||
|
||||
if ($var instanceof \ArrayObject || $var instanceof \ArrayIterator) {
|
||||
$return->__STORAGE__ = self::export($var->getArrayCopy(), $maxDepth - 1);
|
||||
}
|
||||
|
||||
return self::fillReturnWithClassAttributes($var, $return, $maxDepth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the $return variable with class attributes
|
||||
*
|
||||
* @param object $var
|
||||
* @param stdClass $return
|
||||
* @param int $maxDepth
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private static function fillReturnWithClassAttributes($var, \stdClass $return, $maxDepth)
|
||||
{
|
||||
$reflClass = ClassUtils::newReflectionObject($var);
|
||||
$parsedAttributes = array();
|
||||
do {
|
||||
$currentClassName = $reflClass->getName();
|
||||
|
||||
foreach ($reflClass->getProperties() as $reflProperty) {
|
||||
$attributeKey = $reflProperty->isPrivate() ? $currentClassName . '#' : '';
|
||||
$attributeKey .= $reflProperty->getName();
|
||||
|
||||
if (isset($parsedAttributes[$attributeKey])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parsedAttributes[$attributeKey] = true;
|
||||
|
||||
$name =
|
||||
$reflProperty->getName()
|
||||
. ($return->__CLASS__ !== $currentClassName || $reflProperty->isPrivate() ? ':' . $currentClassName : '')
|
||||
. ($reflProperty->isPrivate() ? ':private' : '')
|
||||
. ($reflProperty->isProtected() ? ':protected' : '')
|
||||
;
|
||||
|
||||
$reflProperty->setAccessible(true);
|
||||
$return->$name = self::export($reflProperty->getValue($var), $maxDepth - 1);
|
||||
}
|
||||
} while ($reflClass = $reflClass->getParentClass());
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Version
|
|||
/**
|
||||
* Current Doctrine Version.
|
||||
*/
|
||||
const VERSION = '2.6.0-DEV';
|
||||
const VERSION = '2.7.0-DEV';
|
||||
|
||||
/**
|
||||
* Compares a Doctrine version with the current one.
|
||||
|
|
Reference in a new issue