jhonatanTeixeira /
restfull-client-orm
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Vox\Webservice; |
||
| 4 | |||
| 5 | use Metadata\MetadataFactoryInterface; |
||
| 6 | use Vox\Webservice\Event\DispatchEventTrait; |
||
| 7 | use Vox\Webservice\Event\LifecycleEvent; |
||
| 8 | use Vox\Webservice\Event\ManagerEvent; |
||
| 9 | use Vox\Webservice\Event\PersistenceEvents; |
||
| 10 | use Vox\Webservice\Metadata\TransferMetadata; |
||
| 11 | use Vox\Webservice\Proxy\ProxyFactory; |
||
| 12 | use Vox\Webservice\Proxy\ProxyFactoryInterface; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * This is the transfer manager, it is the best way for you to control the state of your transfers. |
||
| 16 | * this class is a facade to simplify the use of the unity of work and the repository pattern contained |
||
| 17 | * on this project |
||
| 18 | * |
||
| 19 | * @author Jhonatan Teixeira <[email protected]> |
||
| 20 | */ |
||
| 21 | class TransferManager implements TransferManagerInterface |
||
| 22 | { |
||
| 23 | use DispatchEventTrait; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var UnityOfWorkInterface |
||
|
0 ignored issues
–
show
|
|||
| 27 | */ |
||
| 28 | private $unitOfWork; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var MetadataFactoryInterface |
||
| 32 | */ |
||
| 33 | private $metadataFactory; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @var WebserviceClientInterface |
||
| 37 | */ |
||
| 38 | private $webserviceClient; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @var TransferPersisterInterface |
||
| 42 | */ |
||
| 43 | private $transferPersister; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @var ProxyFactoryInterface |
||
| 47 | */ |
||
| 48 | private $proxyFactory; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @var EventDispatcherInterface |
||
| 52 | */ |
||
| 53 | private $eventDispatcher; |
||
| 54 | |||
| 55 | 40 | public function __construct( |
|
| 56 | MetadataFactoryInterface $metadataFactory, |
||
| 57 | WebserviceClientInterface $webserviceClient, |
||
| 58 | ProxyFactoryInterface $proxyFactory = null, |
||
| 59 | EventDispatcherInterface $eventDispatcher = null |
||
| 60 | ) { |
||
| 61 | 40 | $this->metadataFactory = $metadataFactory; |
|
| 62 | 40 | $this->webserviceClient = $webserviceClient; |
|
| 63 | 40 | $this->proxyFactory = $proxyFactory ?? new ProxyFactory(); |
|
| 64 | 40 | $this->eventDispatcher = $eventDispatcher; |
|
| 65 | |||
| 66 | 40 | $this->clear(); |
|
| 67 | 40 | } |
|
| 68 | |||
| 69 | /** |
||
| 70 | * @todo injection of these objects |
||
| 71 | * |
||
| 72 | * @param type $objectName |
||
|
0 ignored issues
–
show
The type
Vox\Webservice\type was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 73 | */ |
||
| 74 | 40 | public function clear($objectName = null) |
|
| 75 | { |
||
| 76 | 40 | $this->unitOfWork = new UnitOfWork($this->metadataFactory); |
|
|
0 ignored issues
–
show
It seems like
new Vox\Webservice\UnitO...$this->metadataFactory) of type Vox\Webservice\UnitOfWork is incompatible with the declared type Vox\Webservice\UnityOfWorkInterface of property $unitOfWork.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 77 | 40 | $this->transferPersister = new TransferPersister( |
|
| 78 | 40 | $this->metadataFactory, |
|
| 79 | 40 | $this->unitOfWork, |
|
| 80 | 40 | $this->webserviceClient, |
|
| 81 | 40 | $this, |
|
| 82 | 40 | $this->eventDispatcher |
|
| 83 | ); |
||
| 84 | 40 | } |
|
| 85 | |||
| 86 | public function contains($object): bool |
||
| 87 | { |
||
| 88 | return $this->unitOfWork->contains($object); |
||
| 89 | } |
||
| 90 | |||
| 91 | public function detach($object) |
||
| 92 | { |
||
| 93 | $this->unitOfWork->detach($object); |
||
| 94 | } |
||
| 95 | |||
| 96 | 14 | public function find($className, $id) |
|
| 97 | { |
||
| 98 | 14 | return $this->getRepository($className)->find($id); |
|
| 99 | } |
||
| 100 | |||
| 101 | 17 | public function flush() |
|
| 102 | { |
||
| 103 | 17 | $event = new ManagerEvent($this); |
|
| 104 | |||
| 105 | 17 | $this->dispatchEvent(PersistenceEvents::PRE_FLUSH, $event); |
|
| 106 | |||
| 107 | 17 | foreach ($this->unitOfWork as $transfer) { |
|
| 108 | 17 | $this->transferPersister->save($transfer); |
|
| 109 | } |
||
| 110 | |||
| 111 | 16 | $this->dispatchEvent(PersistenceEvents::POST_FLUSH, $event); |
|
| 112 | 16 | } |
|
| 113 | |||
| 114 | 32 | public function getClassMetadata($className): TransferMetadata |
|
| 115 | { |
||
| 116 | 32 | if(is_object($className)) { |
|
| 117 | $className = get_class($className); |
||
| 118 | } |
||
| 119 | |||
| 120 | 32 | return $this->metadataFactory->getMetadataForClass($className); |
|
|
0 ignored issues
–
show
|
|||
| 121 | } |
||
| 122 | |||
| 123 | public function getMetadataFactory(): MetadataFactoryInterface |
||
| 124 | { |
||
| 125 | return $this->metadataFactory; |
||
|
0 ignored issues
–
show
The expression
return $this->metadataFactory returns the type Metadata\MetadataFactoryInterface which is incompatible with the return type mandated by Doctrine\Common\Persiste...r::getMetadataFactory() of Doctrine\Common\Persiste...ng\ClassMetadataFactory.
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
Loading history...
|
|||
| 126 | } |
||
| 127 | |||
| 128 | 25 | public function getRepository($className): TransferRepositoryInterface |
|
| 129 | { |
||
| 130 | 25 | return new TransferRepository( |
|
| 131 | 25 | $className, |
|
| 132 | 25 | $this->webserviceClient, |
|
| 133 | 25 | $this->unitOfWork, |
|
| 134 | 25 | $this, |
|
| 135 | 25 | $this->proxyFactory |
|
| 136 | ); |
||
| 137 | } |
||
| 138 | |||
| 139 | public function initializeObject($obj) |
||
| 140 | { |
||
| 141 | |||
| 142 | } |
||
| 143 | |||
| 144 | public function merge($object) |
||
| 145 | { |
||
| 146 | |||
| 147 | } |
||
| 148 | |||
| 149 | 8 | public function persist($object) |
|
| 150 | { |
||
| 151 | 8 | $this->dispatchEvent(PersistenceEvents::PRE_PERSIST, new LifecycleEvent($object, $this)); |
|
| 152 | 8 | $this->unitOfWork->attach($object); |
|
| 153 | 8 | } |
|
| 154 | |||
| 155 | public function refresh($object) |
||
| 156 | { |
||
| 157 | |||
| 158 | } |
||
| 159 | |||
| 160 | 5 | public function remove($object) |
|
| 161 | { |
||
| 162 | 5 | $this->unitOfWork->remove($object); |
|
| 163 | 5 | } |
|
| 164 | |||
| 165 | 1 | public function getUnitOfWork(): UnitOfWorkInterface |
|
| 166 | { |
||
| 167 | 1 | return $this->unitOfWork; |
|
| 168 | } |
||
| 169 | } |
||
| 170 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths