@@ -12,11 +12,11 @@ |
||
| 12 | 12 | use Entities\Address; |
| 13 | 13 | use Entities\User; |
| 14 | 14 | |
| 15 | -$em = require_once __DIR__ . '/bootstrap.php'; |
|
| 15 | +$em = require_once __DIR__.'/bootstrap.php'; |
|
| 16 | 16 | |
| 17 | 17 | ## PUT YOUR TEST CODE BELOW |
| 18 | 18 | |
| 19 | 19 | $user = new User; |
| 20 | 20 | $address = new Address; |
| 21 | 21 | |
| 22 | -echo 'Hello World!' . PHP_EOL; |
|
| 22 | +echo 'Hello World!'.PHP_EOL; |
|
@@ -5,8 +5,8 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | // Path to composer autoloader. You can use different provided by your favorite framework, |
| 7 | 7 | // if you want to. |
| 8 | -$loaderPath = __DIR__ . '/../../vendor/autoload.php'; |
|
| 9 | -if(!is_readable($loaderPath)){ |
|
| 8 | +$loaderPath = __DIR__.'/../../vendor/autoload.php'; |
|
| 9 | +if ( ! is_readable($loaderPath)) { |
|
| 10 | 10 | throw new LogicException('Run php composer.phar install at first'); |
| 11 | 11 | } |
| 12 | 12 | $loader = require $loaderPath; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | $config = new \Doctrine\ORM\Configuration(); |
| 20 | 20 | |
| 21 | 21 | // Set up Metadata Drivers |
| 22 | -$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . "/Entities")); |
|
| 22 | +$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities")); |
|
| 23 | 23 | $config->setMetadataDriverImpl($driverImpl); |
| 24 | 24 | |
| 25 | 25 | // Set up caches, depending on $debug variable. |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $config->setQueryCacheImpl($cache); |
| 30 | 30 | |
| 31 | 31 | // Proxy configuration |
| 32 | -$config->setProxyDir(__DIR__ . '/Proxies'); |
|
| 32 | +$config->setProxyDir(__DIR__.'/Proxies'); |
|
| 33 | 33 | $config->setProxyNamespace('Proxies'); |
| 34 | 34 | |
| 35 | 35 | // Database connection information |
@@ -22,13 +22,10 @@ |
||
| 22 | 22 | use Shitty\Common\Util\ClassUtils; |
| 23 | 23 | use Shitty\Common\Collections\Collection; |
| 24 | 24 | use Shitty\Common\Collections\ArrayCollection; |
| 25 | - |
|
| 26 | 25 | use Shitty\ORM\Query\Parameter; |
| 27 | 26 | use Shitty\ORM\Cache\QueryCacheKey; |
| 28 | 27 | use Shitty\DBAL\Cache\QueryCacheProfile; |
| 29 | - |
|
| 30 | 28 | use Shitty\ORM\Cache; |
| 31 | -use Shitty\ORM\Query\QueryException; |
|
| 32 | 29 | |
| 33 | 30 | /** |
| 34 | 31 | * Base contract for ORM queries. Base class for Query and NativeQuery. |
@@ -212,10 +212,10 @@ |
||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | - * Obtain the name of the second level query cache region in which query results will be stored |
|
| 216 | - * |
|
| 217 | - * @return string|null The cache region name; NULL indicates the default region. |
|
| 218 | - */ |
|
| 215 | + * Obtain the name of the second level query cache region in which query results will be stored |
|
| 216 | + * |
|
| 217 | + * @return string|null The cache region name; NULL indicates the default region. |
|
| 218 | + */ |
|
| 219 | 219 | public function getCacheRegion() |
| 220 | 220 | { |
| 221 | 221 | return $this->cacheRegion; |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | public function getParameter($key) |
| 325 | 325 | { |
| 326 | 326 | $filteredParameters = $this->parameters->filter( |
| 327 | - function ($parameter) use ($key) |
|
| 327 | + function($parameter) use ($key) |
|
| 328 | 328 | { |
| 329 | 329 | // Must not be identical because of string to integer conversion |
| 330 | 330 | return ($key == $parameter->getName()); |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | public function setParameter($key, $value, $type = null) |
| 374 | 374 | { |
| 375 | 375 | $filteredParameters = $this->parameters->filter( |
| 376 | - function ($parameter) use ($key) |
|
| 376 | + function($parameter) use ($key) |
|
| 377 | 377 | { |
| 378 | 378 | // Must not be identical because of string to integer conversion |
| 379 | 379 | return ($key == $parameter->getName()); |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | */ |
| 470 | 470 | private function translateNamespaces(Query\ResultSetMapping $rsm) |
| 471 | 471 | { |
| 472 | - $translate = function ($alias) { |
|
| 472 | + $translate = function($alias) { |
|
| 473 | 473 | return $this->_em->getClassMetadata($alias)->getName(); |
| 474 | 474 | }; |
| 475 | 475 | |
@@ -1114,6 +1114,6 @@ discard block |
||
| 1114 | 1114 | |
| 1115 | 1115 | ksort($hints); |
| 1116 | 1116 | |
| 1117 | - return sha1($query . '-' . serialize($params) . '-' . serialize($hints)); |
|
| 1117 | + return sha1($query.'-'.serialize($params).'-'.serialize($hints)); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | } |
@@ -282,7 +282,7 @@ |
||
| 282 | 282 | /** |
| 283 | 283 | * Generates a string of currently query |
| 284 | 284 | * |
| 285 | - * @param array $query |
|
| 285 | + * @param string $query |
|
| 286 | 286 | * @param string $criteria |
| 287 | 287 | * @param array $orderBy |
| 288 | 288 | * @param integer $limit |
@@ -21,7 +21,6 @@ |
||
| 21 | 21 | |
| 22 | 22 | use Doctrine\Common\Collections\ArrayCollection; |
| 23 | 23 | use Doctrine\Common\Collections\Criteria; |
| 24 | - |
|
| 25 | 24 | use Doctrine\ORM\Query\Expr; |
| 26 | 25 | use Doctrine\ORM\Query\QueryExpressionVisitor; |
| 27 | 26 | |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | abstract class AbstractEntityPersister implements CachedEntityPersister |
| 43 | 43 | { |
| 44 | - /** |
|
| 45 | - * @var \Shitty\ORM\UnitOfWork |
|
| 46 | - */ |
|
| 44 | + /** |
|
| 45 | + * @var \Shitty\ORM\UnitOfWork |
|
| 46 | + */ |
|
| 47 | 47 | protected $uow; |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | protected $class; |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @var array |
|
| 66 | - */ |
|
| 64 | + /** |
|
| 65 | + * @var array |
|
| 66 | + */ |
|
| 67 | 67 | protected $queuedCache = array(); |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -297,7 +297,7 @@ |
||
| 297 | 297 | ? $this->persister->expandCriteriaParameters($criteria) |
| 298 | 298 | : $this->persister->expandParameters($criteria); |
| 299 | 299 | |
| 300 | - return sha1($query . serialize($params) . serialize($orderBy) . $limit . $offset . $timestamp); |
|
| 300 | + return sha1($query.serialize($params).serialize($orderBy).$limit.$offset.$timestamp); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -211,6 +211,7 @@ |
||
| 211 | 211 | |
| 212 | 212 | /** |
| 213 | 213 | * {@inheritdoc} |
| 214 | + * @return boolean |
|
| 214 | 215 | */ |
| 215 | 216 | public function evictAll() |
| 216 | 217 | { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | private function getLockFileName(CacheKey $key) |
| 120 | 120 | { |
| 121 | - return $this->directory . DIRECTORY_SEPARATOR . $key->hash . '.' . self::LOCK_EXTENSION; |
|
| 121 | + return $this->directory.DIRECTORY_SEPARATOR.$key->hash.'.'.self::LOCK_EXTENSION; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | { |
| 217 | 217 | // The check below is necessary because on some platforms glob returns false |
| 218 | 218 | // when nothing matched (even though no errors occurred) |
| 219 | - $filenames = glob(sprintf("%s/*.%s" , $this->directory, self::LOCK_EXTENSION)); |
|
| 219 | + $filenames = glob(sprintf("%s/*.%s", $this->directory, self::LOCK_EXTENSION)); |
|
| 220 | 220 | |
| 221 | 221 | if ($filenames) { |
| 222 | 222 | foreach ($filenames as $filename) { |
@@ -918,7 +918,7 @@ |
||
| 918 | 918 | * @since 2.5 |
| 919 | 919 | * |
| 920 | 920 | * @param string $name The name of the hint. |
| 921 | - * @param mixed $value The value of the hint. |
|
| 921 | + * @param string $value The value of the hint. |
|
| 922 | 922 | */ |
| 923 | 923 | public function setDefaultQueryHint($name, $value) |
| 924 | 924 | { |
@@ -151,7 +151,7 @@ |
||
| 151 | 151 | */ |
| 152 | 152 | public function newDefaultAnnotationDriver($paths = array(), $useSimpleAnnotationReader = true) |
| 153 | 153 | { |
| 154 | - AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php'); |
|
| 154 | + AnnotationRegistry::registerFile(__DIR__.'/Mapping/Driver/DoctrineAnnotations.php'); |
|
| 155 | 155 | |
| 156 | 156 | if ($useSimpleAnnotationReader) { |
| 157 | 157 | // Register the ORM Annotations in the AnnotationRegistry |
@@ -24,9 +24,6 @@ |
||
| 24 | 24 | use Shitty\ORM\Mapping\ClassMetadata; |
| 25 | 25 | use Shitty\ORM\PersistentCollection; |
| 26 | 26 | use Shitty\ORM\Query; |
| 27 | -use Shitty\ORM\Events; |
|
| 28 | -use Shitty\ORM\Event\LifecycleEventArgs; |
|
| 29 | -use Shitty\ORM\Event\PostLoadEventDispatcher; |
|
| 30 | 27 | use Shitty\Common\Collections\ArrayCollection; |
| 31 | 28 | use Shitty\ORM\Proxy\Proxy; |
| 32 | 29 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $class->reflFields[$fieldName]->setValue($entity, $value); |
| 203 | 203 | $this->_uow->setOriginalEntityProperty($oid, $fieldName, $value); |
| 204 | 204 | |
| 205 | - $this->initializedCollections[$oid . $fieldName] = $value; |
|
| 205 | + $this->initializedCollections[$oid.$fieldName] = $value; |
|
| 206 | 206 | } else if ( |
| 207 | 207 | isset($this->_hints[Query::HINT_REFRESH]) || |
| 208 | 208 | isset($this->_hints['fetched'][$parentDqlAlias][$fieldName]) && |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | $value->setInitialized(true); |
| 214 | 214 | $value->unwrap()->clear(); |
| 215 | 215 | |
| 216 | - $this->initializedCollections[$oid . $fieldName] = $value; |
|
| 216 | + $this->initializedCollections[$oid.$fieldName] = $value; |
|
| 217 | 217 | } else { |
| 218 | 218 | // Is already PersistentCollection, and DON'T REFRESH or FETCH-JOIN! |
| 219 | - $this->existingCollections[$oid . $fieldName] = $value; |
|
| 219 | + $this->existingCollections[$oid.$fieldName] = $value; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | return $value; |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $idHash = ''; |
| 290 | 290 | |
| 291 | 291 | foreach ($class->identifier as $fieldName) { |
| 292 | - $idHash .= ' ' . (isset($class->associationMappings[$fieldName]) |
|
| 292 | + $idHash .= ' '.(isset($class->associationMappings[$fieldName]) |
|
| 293 | 293 | ? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']] |
| 294 | 294 | : $data[$fieldName]); |
| 295 | 295 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | $parentAlias = $this->_rsm->parentAliasMap[$dqlAlias]; |
| 343 | 343 | // we need the $path to save into the identifier map which entities were already |
| 344 | 344 | // seen for this parent-child relationship |
| 345 | - $path = $parentAlias . '.' . $dqlAlias; |
|
| 345 | + $path = $parentAlias.'.'.$dqlAlias; |
|
| 346 | 346 | |
| 347 | 347 | // We have a RIGHT JOIN result here. Doctrine cannot hydrate RIGHT JOIN Object-Graphs |
| 348 | 348 | if ( ! isset($nonemptyComponents[$parentAlias])) { |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | $reflFieldValue = $reflField->getValue($parentObject); |
| 383 | 383 | |
| 384 | 384 | if (isset($nonemptyComponents[$dqlAlias])) { |
| 385 | - $collKey = $oid . $relationField; |
|
| 385 | + $collKey = $oid.$relationField; |
|
| 386 | 386 | if (isset($this->initializedCollections[$collKey])) { |
| 387 | 387 | $reflFieldValue = $this->initializedCollections[$collKey]; |
| 388 | 388 | } else if ( ! isset($this->existingCollections[$collKey])) { |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | // PATH B: Single-valued association |
| 431 | 431 | $reflFieldValue = $reflField->getValue($parentObject); |
| 432 | 432 | |
| 433 | - if ( ! $reflFieldValue || isset($this->_hints[Query::HINT_REFRESH]) || ($reflFieldValue instanceof Proxy && !$reflFieldValue->__isInitialized__)) { |
|
| 433 | + if ( ! $reflFieldValue || isset($this->_hints[Query::HINT_REFRESH]) || ($reflFieldValue instanceof Proxy && ! $reflFieldValue->__isInitialized__)) { |
|
| 434 | 434 | // we only need to take action if this value is null, |
| 435 | 435 | // we refresh the entity or its an unitialized proxy. |
| 436 | 436 | if (isset($nonemptyComponents[$dqlAlias])) { |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | $entityKey = $this->_rsm->entityMappings[$dqlAlias] ?: 0; |
| 476 | 476 | |
| 477 | 477 | // if this row has a NULL value for the root result id then make it a null result. |
| 478 | - if ( ! isset($nonemptyComponents[$dqlAlias]) ) { |
|
| 478 | + if ( ! isset($nonemptyComponents[$dqlAlias])) { |
|
| 479 | 479 | if ($this->_rsm->isMixed) { |
| 480 | 480 | $result[] = array($entityKey => null); |
| 481 | 481 | } else { |
@@ -531,13 +531,13 @@ discard block |
||
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - if ( ! isset($resultKey) ) { |
|
| 534 | + if ( ! isset($resultKey)) { |
|
| 535 | 535 | $this->resultCounter++; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | // Append scalar values to mixed result sets |
| 539 | 539 | if (isset($rowData['scalars'])) { |
| 540 | - if ( ! isset($resultKey) ) { |
|
| 540 | + if ( ! isset($resultKey)) { |
|
| 541 | 541 | $resultKey = (isset($this->_rsm->indexByMap['scalars'])) |
| 542 | 542 | ? $row[$this->_rsm->indexByMap['scalars']] |
| 543 | 543 | : $this->resultCounter - 1; |
@@ -550,19 +550,19 @@ discard block |
||
| 550 | 550 | |
| 551 | 551 | // Append new object to mixed result sets |
| 552 | 552 | if (isset($rowData['newObjects'])) { |
| 553 | - if ( ! isset($resultKey) ) { |
|
| 553 | + if ( ! isset($resultKey)) { |
|
| 554 | 554 | $resultKey = $this->resultCounter - 1; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | |
| 558 | - $scalarCount = (isset($rowData['scalars'])? count($rowData['scalars']): 0); |
|
| 558 | + $scalarCount = (isset($rowData['scalars']) ? count($rowData['scalars']) : 0); |
|
| 559 | 559 | |
| 560 | 560 | foreach ($rowData['newObjects'] as $objIndex => $newObject) { |
| 561 | 561 | $class = $newObject['class']; |
| 562 | 562 | $args = $newObject['args']; |
| 563 | 563 | $obj = $class->newInstanceArgs($args); |
| 564 | 564 | |
| 565 | - if ($scalarCount == 0 && count($rowData['newObjects']) == 1 ) { |
|
| 565 | + if ($scalarCount == 0 && count($rowData['newObjects']) == 1) { |
|
| 566 | 566 | $result[$resultKey] = $obj; |
| 567 | 567 | |
| 568 | 568 | continue; |
@@ -20,7 +20,6 @@ |
||
| 20 | 20 | namespace Shitty\ORM\Internal\Hydration; |
| 21 | 21 | |
| 22 | 22 | use PDO; |
| 23 | -use Shitty\DBAL\Types\Type; |
|
| 24 | 23 | use Shitty\ORM\Mapping\ClassMetadata; |
| 25 | 24 | use Shitty\ORM\Query; |
| 26 | 25 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | /** |
| 144 | 144 | * Adds Index. |
| 145 | 145 | * |
| 146 | - * @param array $columns |
|
| 146 | + * @param string[] $columns |
|
| 147 | 147 | * @param string $name |
| 148 | 148 | * |
| 149 | 149 | * @return ClassMetadataBuilder |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | /** |
| 163 | 163 | * Adds Unique Constraint. |
| 164 | 164 | * |
| 165 | - * @param array $columns |
|
| 165 | + * @param string[] $columns |
|
| 166 | 166 | * @param string $name |
| 167 | 167 | * |
| 168 | 168 | * @return ClassMetadataBuilder |
@@ -150,7 +150,7 @@ |
||
| 150 | 150 | */ |
| 151 | 151 | public function addIndex(array $columns, $name) |
| 152 | 152 | { |
| 153 | - if (!isset($this->cm->table['indexes'])) { |
|
| 153 | + if ( ! isset($this->cm->table['indexes'])) { |
|
| 154 | 154 | $this->cm->table['indexes'] = array(); |
| 155 | 155 | } |
| 156 | 156 | |