Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Majkl578 committed Jan 8, 2018
1 parent 8be1e3f commit 2b69bd9
Show file tree
Hide file tree
Showing 177 changed files with 871 additions and 96 deletions.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
"symfony/console": "~3.0|~4.0"
},
"require-dev": {
"doctrine/coding-standard": "^1.0",
"phpunit/phpunit": "^6.5",
"squizlabs/php_codesniffer": "^3.2"
"doctrine/coding-standard": "dev-reference-global-fn-const-in-use-only",
"phpunit/phpunit": "^6.5"
},
"autoload": {
"psr-4": { "Doctrine\\ORM\\": "lib/Doctrine/ORM" }
Expand Down
11 changes: 11 additions & 0 deletions lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
use Doctrine\ORM\Cache\QueryCacheKey;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\ORM\Utility\StaticClassNameConverter;
use function is_array;
use function is_scalar;
use function reset;
use function is_object;
use function array_map;
use function count;
use function array_shift;
use function is_numeric;
use function ksort;
use function sha1;
use function serialize;

/**
* Base contract for ORM queries. Base class for Query and NativeQuery.
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Cache/CacheException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\ORM\Cache;

use Doctrine\ORM\ORMException;
use function sprintf;

/**
* Exception for cache.
Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Cache/CollectionCacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
declare(strict_types=1);

namespace Doctrine\ORM\Cache;
use function ksort;
use function str_replace;
use function strtolower;
use function implode;

/**
* Defines entity collection roles to be stored in the cache region.
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Cache/DefaultCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Doctrine\ORM\Mapping\ToManyAssociationMetadata;
use Doctrine\ORM\ORMInvalidArgumentException;
use Doctrine\ORM\Utility\StaticClassNameConverter;
use function is_array;
use function is_object;

/**
* Provides an API for querying/managing the second level cache regions.
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Cache/DefaultCacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Persisters\Collection\CollectionPersister;
use Doctrine\ORM\Persisters\Entity\EntityPersister;
use function sprintf;
use const DIRECTORY_SEPARATOR;

/**
* @since 2.5
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Doctrine\ORM\Mapping\ToOneAssociationMetadata;
use Doctrine\ORM\Query;
use Doctrine\ORM\Utility\StaticClassNameConverter;
use function array_merge;

/**
* Default hydrator cache for entities
Expand Down
7 changes: 7 additions & 0 deletions lib/Doctrine/ORM/Cache/DefaultQueryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
use Doctrine\ORM\Cache;
use Doctrine\ORM\Query;
use ProxyManager\Proxy\GhostObjectInterface;
use function reset;
use function array_map;
use function is_array;
use function count;
use function key;
use function array_unshift;
use function array_shift;

/**
* Default query cache implementation.
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Cache/EntityCacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Doctrine\ORM\Cache;

use Doctrine\ORM\EntityManagerInterface;
use function array_map;

/**
* Entity cache entry
Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Cache/EntityCacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
declare(strict_types=1);

namespace Doctrine\ORM\Cache;
use function ksort;
use function str_replace;
use function strtolower;
use function implode;

/**
* Defines entity classes roles to be stored in the cache region.
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Cache/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
declare(strict_types=1);

namespace Doctrine\ORM\Cache;
use function time;
use function uniqid;

/**
* Cache Lock
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\ORM\Cache\CollectionCacheKey;
use Doctrine\ORM\Cache\EntityCacheKey;
use Doctrine\ORM\Cache\QueryCacheKey;
use function array_sum;

/**
* Provide basic second level cache statistics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Persisters\Collection\CollectionPersister;
use Doctrine\ORM\Utility\StaticClassNameConverter;
use function array_values;
use function count;

/**
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
Expand Down Expand Up @@ -166,7 +168,7 @@ public function storeCollectionCache(CollectionCacheKey $key, $elements)
// Only preserve ordering if association configured it
if (! ($association instanceof ToManyAssociationMetadata && $association->getIndexedBy())) {
// Elements may be an array or a Collection
$elements = \array_values($elements instanceof Collection ? $elements->getValues() : $elements);
$elements = array_values($elements instanceof Collection ? $elements->getValues() : $elements);
}

$entry = $this->hydrator->buildCacheEntry($this->targetEntity, $key, $elements);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\ORM\Cache\CollectionCacheKey;
use Doctrine\ORM\Mapping\ToManyAssociationMetadata;
use Doctrine\ORM\PersistentCollection;
use function spl_object_id;

/**
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Doctrine\ORM\Mapping\AssociationMetadata;
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Persisters\Collection\CollectionPersister;
use function spl_object_id;

/**
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Persisters\Entity\EntityPersister;
use Doctrine\ORM\Utility\StaticClassNameConverter;
use function sha1;
use function serialize;

/**
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Doctrine\ORM\Cache\Persister\Entity;

use Doctrine\ORM\Cache\EntityCacheKey;
use function get_class;

/**
* Specific non-strict read/write cached entity persister
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Cache/QueryCacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
declare(strict_types=1);

namespace Doctrine\ORM\Cache;
use function microtime;

/**
* Query cache entry
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Doctrine\Common\Cache\MultiGetCache;
use Doctrine\ORM\Cache\CollectionCacheEntry;
use function count;

/**
* A cache region that enables the retrieval of multiple elements with one call
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Cache/Region/DefaultRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Doctrine\ORM\Cache\CollectionCacheEntry;
use Doctrine\ORM\Cache\Lock;
use Doctrine\ORM\Cache\Region;
use function sprintf;
use function get_class;

/**
* The simplest cache region compatible with all doctrine-cache drivers.
Expand Down
16 changes: 16 additions & 0 deletions lib/Doctrine/ORM/Cache/Region/FileLockRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
use Doctrine\ORM\Cache\CacheKey;
use Doctrine\ORM\Cache\CacheEntry;
use Doctrine\ORM\Cache\ConcurrentRegion;
use function is_dir;
use function mkdir;
use function sprintf;
use function is_writable;
use function is_file;
use function unlink;
use function time;
use const DIRECTORY_SEPARATOR;
use function file_get_contents;
use function fileatime;
use function array_filter;
use function array_map;
use function glob;
use function file_put_contents;
use const LOCK_EX;
use function chmod;

/**
* Very naive concurrent region, based on file locks.
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Cache/TimestampCacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
declare(strict_types=1);

namespace Doctrine\ORM\Cache;
use function microtime;

/**
* Timestamp cache entry
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
declare(strict_types=1);

namespace Doctrine\ORM\Cache;
use function microtime;

/**
* @since 2.5
Expand Down
14 changes: 8 additions & 6 deletions lib/Doctrine/ORM/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
use ProxyManager\FileLocator\FileLocator;
use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy;
use ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy;
use function trim;
use function strtolower;

/**
* Configuration container for all configuration options of Doctrine.
Expand Down Expand Up @@ -408,7 +410,7 @@ public function ensureProductionSettings() : void
*/
public function addCustomStringFunction(string $functionName, $classNameOrFactory) : void
{
$this->customStringFunctions[\strtolower($functionName)] = $classNameOrFactory;
$this->customStringFunctions[strtolower($functionName)] = $classNameOrFactory;
}

/**
Expand All @@ -418,7 +420,7 @@ public function addCustomStringFunction(string $functionName, $classNameOrFactor
*/
public function getCustomStringFunction(string $functionName)
{
return $this->customStringFunctions[\strtolower($functionName)] ?? null;
return $this->customStringFunctions[strtolower($functionName)] ?? null;
}

/**
Expand Down Expand Up @@ -449,7 +451,7 @@ public function setCustomStringFunctions(array $functions) : void
*/
public function addCustomNumericFunction(string $functionName, $classNameOrFactory) : void
{
$this->customNumericFunctions[\strtolower($functionName)] = $classNameOrFactory;
$this->customNumericFunctions[strtolower($functionName)] = $classNameOrFactory;
}

/**
Expand All @@ -459,7 +461,7 @@ public function addCustomNumericFunction(string $functionName, $classNameOrFacto
*/
public function getCustomNumericFunction(string $functionName)
{
return $this->customNumericFunctions[\strtolower($functionName)] ?? null;
return $this->customNumericFunctions[strtolower($functionName)] ?? null;
}

/**
Expand Down Expand Up @@ -490,7 +492,7 @@ public function setCustomNumericFunctions(array $functions) : void
*/
public function addCustomDatetimeFunction(string $functionName, $classNameOrFactory)
{
$this->customDatetimeFunctions[\strtolower($functionName)] = $classNameOrFactory;
$this->customDatetimeFunctions[strtolower($functionName)] = $classNameOrFactory;
}

/**
Expand All @@ -500,7 +502,7 @@ public function addCustomDatetimeFunction(string $functionName, $classNameOrFact
*/
public function getCustomDatetimeFunction(string $functionName)
{
return $this->customDatetimeFunctions[\strtolower($functionName)] ?? null;
return $this->customDatetimeFunctions[strtolower($functionName)] ?? null;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions lib/Doctrine/ORM/Configuration/MetadataConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Doctrine\ORM\Mapping\Factory\ClassMetadataResolver;
use Doctrine\ORM\Mapping\Factory\DefaultNamingStrategy;
use Doctrine\ORM\Mapping\Factory\NamingStrategy;
use function ltrim;
use function rtrim;
use const DIRECTORY_SEPARATOR;

/**
* Configuration container for class metadata options of Doctrine.
Expand Down
7 changes: 7 additions & 0 deletions lib/Doctrine/ORM/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\Utility\IdentifierFlattener;
use Doctrine\ORM\Utility\StaticClassNameConverter;
use function ltrim;
use function is_array;
use function is_object;
use function array_keys;
use function sprintf;
use function get_class;
use function gettype;

/**
* The EntityManager is the central access point to ORM functionality.
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/EntityNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

namespace Doctrine\ORM;
use function implode;

/**
* Exception thrown when a Proxy fails to retrieve an Entity result.
Expand Down
5 changes: 5 additions & 0 deletions lib/Doctrine/ORM/EntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\Common\Collections\Selectable;
use Doctrine\Common\Collections\Criteria;
use function str_replace;
use function strpos;
use function substr;
use function lcfirst;
use function array_slice;

/**
* An EntityRepository serves as a repository for entities with generic as well as
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Event/OnClearEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\ORM\Event;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Common\EventArgs;

/**
* Provides event arguments for the onClear event.
Expand All @@ -15,7 +16,7 @@
* @author Roman Borschel <roman@code-factory.de>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class OnClearEventArgs extends \Doctrine\Common\EventArgs
class OnClearEventArgs extends EventArgs
{
/**
* @var EntityManagerInterface
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Event/PreUpdateEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace Doctrine\ORM\Event;

use Doctrine\ORM\EntityManagerInterface;
use function sprintf;
use function get_class;

/**
* Class that holds event arguments for a preInsert/preUpdate event.
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Internal/CommitOrderCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
declare(strict_types=1);

namespace Doctrine\ORM\Internal;
use function array_reverse;

/**
* CommitOrderCalculator implements topological sorting, which is an ordering
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Events;
use PDO;
use function array_merge;

/**
* Base class for all hydrators. A hydrator is a class that provides some form
Expand Down Expand Up @@ -379,7 +380,7 @@ protected function hydrateColumnInfo($key)
// the current discriminator value must be saved in order to disambiguate fields hydration,
// should there be field name collisions
if ($classMetadata->getParent() && isset($this->rsm->discriminatorColumns[$ownerMap])) {
return $this->cache[$key] = \array_merge(
return $this->cache[$key] = array_merge(
$columnInfo,
[
'discriminatorColumn' => $this->rsm->discriminatorColumns[$ownerMap],
Expand Down
Loading

0 comments on commit 2b69bd9

Please sign in to comment.