GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( bd1580...0ea8fb )
by Florian
09:56
created
DependencyInjection/Compiler/FacetCompilerPass.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 	 * @param ContainerBuilder $container
17 17
 	 */
18 18
 	public function process(ContainerBuilder $container) {
19
-		if(!$container->hasAlias(SearchService::class)) {
19
+		if (!$container->hasAlias(SearchService::class)) {
20 20
 			return;
21 21
 		}
22 22
 
23 23
 		$serviceId = (string)$container->getAlias(SearchService::class);
24 24
 
25
-		if(!$container->hasDefinition($serviceId)) {
25
+		if (!$container->hasDefinition($serviceId)) {
26 26
 			return;
27 27
 		}
28 28
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 		$servicesMap = array();
32 32
 		// Builds an array with fully-qualified type class names as keys and service IDs as values
33
-		foreach($container->findTaggedServiceIds(FacetServiceInterface::TAG_NAME, true) as $serviceId => $tag) {
33
+		foreach ($container->findTaggedServiceIds(FacetServiceInterface::TAG_NAME, true) as $serviceId => $tag) {
34 34
 			// Add form type service to the service locator
35 35
 			$serviceDefinition = $container->getDefinition($serviceId);
36 36
 			$servicesMap[$serviceDefinition->getClass()] = new Reference($serviceId);
Please login to merge, or discard this patch.
DependencyInjection/Configuration.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 	 */
32 32
 	public function getConfigTreeBuilder() {
33 33
 		$treeBuilder = new TreeBuilder('stinger_soft_entity_search');
34
-		if(Kernel::VERSION_ID < 40200) {
34
+		if (Kernel::VERSION_ID < 40200) {
35 35
 			$root = $treeBuilder->root('stinger_soft_entity_search');
36 36
 		} else {
37 37
 			$root = $treeBuilder->getRootNode();
Please login to merge, or discard this patch.
Form/FacetChoiceLoader.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 	public function loadValuesForChoices(array $choices, $value = null): array {
42 42
 		// is called on form creat with $choices containing the preset of the bound entity
43 43
 		$values = array();
44
-		foreach($choices as $key => $choice) {
44
+		foreach ($choices as $key => $choice) {
45 45
 			// we use a DataTransformer, thus only plain values arrive as choices which can be used directly as value
46
-			if(is_callable($value)) {
46
+			if (is_callable($value)) {
47 47
 				$values[$key] = (string)call_user_func($value, $choice, $key);
48 48
 			} else {
49 49
 				$values[$key] = $choice;
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	public function loadChoicesForValues(array $values, $value = null): array {
88 88
 		// is called on form submit after loadValuesForChoices of form create and loadChoiceList of form view create
89 89
 		$choices = array();
90
-		foreach($values as $key => $val) {
90
+		foreach ($values as $key => $val) {
91 91
 			// we use a DataTransformer, thus only plain values arrive as choices which can be used directly as value
92
-			if(is_callable($value)) {
92
+			if (is_callable($value)) {
93 93
 				$choices[$key] = (string)call_user_func($value, $val, $key);
94 94
 			} else {
95 95
 				$choices[$key] = $val;
Please login to merge, or discard this patch.
Form/FacetType.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@
 block discarded – undo
32 32
 		$builder->resetModelTransformers();
33 33
 		$builder->resetViewTransformers();
34 34
 		
35
-		if($options['multiple']) {
36
-			$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
35
+		if ($options['multiple']) {
36
+			$builder->addEventListener(FormEvents::PRE_SUBMIT, function(FormEvent $event) {
37 37
 				$event->stopPropagation();
38 38
 			}, 1);
39 39
 		}
40
-		$builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
40
+		$builder->addEventListener(FormEvents::SUBMIT, function(FormEvent $event) {
41 41
 			$data = $event->getForm()->getExtraData();
42 42
 			//$event->setData(array_unique(array_merge($data, $event->getData())));
43 43
 			$event->setData($data);
Please login to merge, or discard this patch.
Form/QueryType.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -55,25 +55,25 @@  discard block
 block discarded – undo
55 55
 		$preferredFilterChoices = $options['preferred_filter_choices'];
56 56
 		$maxChoiceGroupCount = (int)$options['max_choice_group_count'];
57 57
 
58
-		if($usedFacets && !$result) {
58
+		if ($usedFacets && !$result) {
59 59
 			$data = [];
60
-			foreach($usedFacets as $facetType => $facetTypeOptions) {
60
+			foreach ($usedFacets as $facetType => $facetTypeOptions) {
61 61
 				$facetTypeOptions = is_array($facetTypeOptions) ? $facetTypeOptions : [];
62 62
 				$preferredChoices = $preferredFilterChoices[$facetType] ?? [];
63 63
 				$i = 0;
64
-				$builder->add('facet_' . $facetType, FacetType::class, array_merge(array(
65
-					'label'             => 'stinger_soft_entity_search.forms.query.' . $facetType . '.label',
64
+				$builder->add('facet_'.$facetType, FacetType::class, array_merge(array(
65
+					'label'             => 'stinger_soft_entity_search.forms.query.'.$facetType.'.label',
66 66
 					'multiple'          => true,
67 67
 					'expanded'          => true,
68 68
 					'preferred_choices' => function($val) use ($preferredChoices, $data, $facetType, $maxChoiceGroupCount, &$i) {
69
-						$facetKey = 'facet_' . $facetType;
69
+						$facetKey = 'facet_'.$facetType;
70 70
 						return $i++ < $maxChoiceGroupCount || $maxChoiceGroupCount === 0 || \in_array($val, $preferredChoices) || (isset($data[$facetKey]) && \in_array($val, $data[$facetKey]));
71 71
 					}
72 72
 				), $facetTypeOptions));
73 73
 				unset($i);
74 74
 			}
75 75
 		}
76
-		if($result) {
76
+		if ($result) {
77 77
 			$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($options, $result) {
78 78
 				$this->createFacets($event->getForm(), $result->getFacets(), $options, $event->getData());
79 79
 			});
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 		$selectedFacets = $data->getFacets();
138 138
 		$usedFacets = $options['used_facets'];
139 139
 
140
-		foreach($facets->getFacets() as $facetType => $facetValues) {
140
+		foreach ($facets->getFacets() as $facetType => $facetValues) {
141 141
 			$preferredChoices = $preferredFilterChoices[$facetType] ?? [];
142 142
 
143 143
 			$i = 0;
144 144
 			$facetTypeOptions = $usedFacets[$facetType] ?? [];
145 145
 			$formatter = $options['facet_formatter'][$facetType] ?? null;
146
-			$builder->add('facet_' . $facetType, FacetType::class, array_merge(array(
147
-				'label'             => 'stinger_soft_entity_search.forms.query.' . $facetType . '.label',
146
+			$builder->add('facet_'.$facetType, FacetType::class, array_merge(array(
147
+				'label'             => 'stinger_soft_entity_search.forms.query.'.$facetType.'.label',
148 148
 				'multiple'          => true,
149 149
 				'expanded'          => true,
150 150
 				'choices'           => $this->generateFacetChoices($facetType, $facetValues, $selectedFacets[$facetType] ?? [], $formatter),
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	protected function generateFacetChoices($facetType, array $facets, array $selectedFacets = [], callable $formatter = null): array {
168 168
 		$choices = [];
169
-		foreach($facets as $facet => $data) {
169
+		foreach ($facets as $facet => $data) {
170 170
 			$value = $data['value'];
171 171
 			$count = $data['count'];
172
-			if($count === 0 && !\in_array($facet, $selectedFacets)) {
172
+			if ($count === 0 && !\in_array($facet, $selectedFacets)) {
173 173
 				continue;
174 174
 			}
175 175
 			$choices[$this->formatFacet($formatter, $facetType, $facet, $value, $count)] = $facet;
176 176
 		}
177
-		foreach($selectedFacets as $facet) {
178
-			if(isset($facets[$facet])) {
177
+		foreach ($selectedFacets as $facet) {
178
+			if (isset($facets[$facet])) {
179 179
 				continue;
180 180
 			}
181 181
 			$value = $facets[$facet]['value'];
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 	 * @return string
195 195
 	 */
196 196
 	protected function formatFacet($formatter, $facetType, $facet, $value, $count):string {
197
-		$default = $facet . ' (' . $count . ')';
198
-		if(!$formatter) {
197
+		$default = $facet.' ('.$count.')';
198
+		if (!$formatter) {
199 199
 			return $default;
200 200
 		}
201 201
 		return $formatter($facetType, $value, $count, $default);
Please login to merge, or discard this patch.
Services/Mapping/DocumentToEntityMapper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,14 +35,14 @@
 block discarded – undo
35 35
 	public function getEntity(Document $document) : ?object {
36 36
 		$clazz = $document->getEntityClass();
37 37
 		
38
-		if($clazz === null) {
38
+		if ($clazz === null) {
39 39
 			return null;
40 40
 		}
41
-		if(!$document->getEntityId()) {
41
+		if (!$document->getEntityId()) {
42 42
 			return null;
43 43
 		}
44 44
 		$manager = $this->managerRegistry->getManagerForClass($clazz);
45
-		if($manager === null) {
45
+		if ($manager === null) {
46 46
 			return null;
47 47
 		}
48 48
 		return $manager->getRepository($clazz)->find($document->getEntityId());
Please login to merge, or discard this patch.
Services/Mapping/EntityToDocumentMapper.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -48,18 +48,18 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	public function __construct(SearchService $searchService, array $mapping = array()) {
50 50
 		$this->searchService = $searchService;
51
-		foreach($mapping as $key => $config) {
52
-			if(!isset($config['mappings'])) {
53
-				throw new \InvalidArgumentException($key . ' has no mapping defined!');
51
+		foreach ($mapping as $key => $config) {
52
+			if (!isset($config['mappings'])) {
53
+				throw new \InvalidArgumentException($key.' has no mapping defined!');
54 54
 			}
55
-			if(!isset($config['persistence'])) {
56
-				throw new \InvalidArgumentException($key . ' has no persistence defined!');
55
+			if (!isset($config['persistence'])) {
56
+				throw new \InvalidArgumentException($key.' has no persistence defined!');
57 57
 			}
58
-			if(!isset($config['persistence']['model'])) {
59
-				throw new \InvalidArgumentException($key . ' has no model defined!');
58
+			if (!isset($config['persistence']['model'])) {
59
+				throw new \InvalidArgumentException($key.' has no model defined!');
60 60
 			}
61 61
 			$map = array();
62
-			foreach($config['mappings'] as $fieldKey => $fieldConfig) {
62
+			foreach ($config['mappings'] as $fieldKey => $fieldConfig) {
63 63
 				$map[$fieldKey] = isset($fieldConfig['propertyPath']) && $fieldConfig['propertyPath'] ? $fieldConfig['propertyPath'] : $fieldKey;
64 64
 			}
65 65
 			
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 	 * @see \StingerSoft\EntitySearchBundle\Services\Mapping\EntityToDocumentMapperInterface::isIndexable()
75 75
 	 */
76 76
 	public function isIndexable(object $object) : bool {
77
-		if($object instanceof SearchableEntity) {
77
+		if ($object instanceof SearchableEntity) {
78 78
 			return true;
79 79
 		}
80
-		if(count($this->getMapping(get_class($object))) > 0) {
80
+		if (count($this->getMapping(get_class($object))) > 0) {
81 81
 			return true;
82 82
 		}
83 83
 		return false;
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function isClassIndexable(string $clazz) : bool {
94 94
 		$reflectionClass = new \ReflectionClass($clazz);
95
-		if(array_key_exists(SearchableEntity::class, $reflectionClass->getInterfaces())) {
95
+		if (array_key_exists(SearchableEntity::class, $reflectionClass->getInterfaces())) {
96 96
 			return true;
97 97
 		}
98
-		if(count($this->getMapping($clazz)) > 0) {
98
+		if (count($this->getMapping($clazz)) > 0) {
99 99
 			return true;
100 100
 		}
101 101
 		return false;
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	 * @see \StingerSoft\EntitySearchBundle\Services\Mapping\EntityToDocumentMapperInterface::createDocument()
108 108
 	 */
109 109
 	public function createDocument(ObjectManager $manager, object $object) : ?Document {
110
-		if(!$this->isIndexable($object))
110
+		if (!$this->isIndexable($object))
111 111
 			return null;
112 112
 		$document = $this->searchService->createEmptyDocumentFromEntity($object);
113 113
 		$index = $this->fillDocument($document, $object);
114
-		if($index === false)
114
+		if ($index === false)
115 115
 			return null;
116 116
 		
117 117
 		return $document;
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 	 * @return boolean
126 126
 	 */
127 127
 	protected function fillDocument(Document $document, object $object) : bool {
128
-		if($object instanceof SearchableEntity) {
128
+		if ($object instanceof SearchableEntity) {
129 129
 			return $object->indexEntity($document);
130 130
 		}
131 131
 		$mapping = $this->getMapping(\get_class($object));
132 132
 		$accessor = PropertyAccess::createPropertyAccessor();
133
-		foreach($mapping as $fieldName => $propertyPath) {
133
+		foreach ($mapping as $fieldName => $propertyPath) {
134 134
 			$document->addField($fieldName, $accessor->getValue($object, $propertyPath));
135 135
 		}
136 136
 		return true;
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
 	 * @throws \ReflectionException
144 144
 	 */
145 145
 	protected function getMapping(string $clazz) : array {
146
-		if(isset($this->cachedMapping[$clazz])) {
146
+		if (isset($this->cachedMapping[$clazz])) {
147 147
 			return $this->cachedMapping[$clazz];
148 148
 		}
149 149
 		$ref = new \ReflectionClass($clazz);
150 150
 		
151 151
 		$mapping = array();
152 152
 		
153
-		foreach($this->mapping as $className => $config) {
154
-			if($clazz === $className || $ref->isSubclassOf($className)) {
153
+		foreach ($this->mapping as $className => $config) {
154
+			if ($clazz === $className || $ref->isSubclassOf($className)) {
155 155
 				$mapping = \array_merge($mapping, $config);
156 156
 			}
157 157
 		}
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -107,12 +107,14 @@
 block discarded – undo
107 107
 	 * @see \StingerSoft\EntitySearchBundle\Services\Mapping\EntityToDocumentMapperInterface::createDocument()
108 108
 	 */
109 109
 	public function createDocument(ObjectManager $manager, object $object) : ?Document {
110
-		if(!$this->isIndexable($object))
111
-			return null;
110
+		if(!$this->isIndexable($object)) {
111
+					return null;
112
+		}
112 113
 		$document = $this->searchService->createEmptyDocumentFromEntity($object);
113 114
 		$index = $this->fillDocument($document, $object);
114
-		if($index === false)
115
-			return null;
115
+		if($index === false) {
116
+					return null;
117
+		}
116 118
 		
117 119
 		return $document;
118 120
 	}
Please login to merge, or discard this patch.
Services/DoctrineListener.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @param LifecycleEventArgs $args
96 96
 	 */
97 97
 	public function postPersist(LifecycleEventArgs $args): void {
98
-		if(!$this->enableIndexing) {
98
+		if (!$this->enableIndexing) {
99 99
 			return;
100 100
 		}
101 101
 		$this->updateEntity($args->getObject(), $args->getObjectManager());
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @throws \Doctrine\ORM\OptimisticLockException
108 108
 	 */
109 109
 	public function postFlush(PostFlushEventArgs $eventArgs): void {
110
-		if($this->needsFlush) {
110
+		if ($this->needsFlush) {
111 111
 			$this->needsFlush = false;
112 112
 			$eventArgs->getEntityManager()->flush();
113 113
 		}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @param LifecycleEventArgs $args
120 120
 	 */
121 121
 	public function preRemove(LifecycleEventArgs $args): void {
122
-		if(!$this->enableIndexing) {
122
+		if (!$this->enableIndexing) {
123 123
 			return;
124 124
 		}
125 125
 		$this->removeEntity($args->getObject(), $args->getObjectManager());
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @param LifecycleEventArgs $args
132 132
 	 */
133 133
 	public function postUpdate(LifecycleEventArgs $args): void {
134
-		if(!$this->enableIndexing) return;
134
+		if (!$this->enableIndexing) return;
135 135
 		$this->updateEntity($args->getObject(), $args->getObjectManager());
136 136
 	}
137 137
 
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 	 * @param object $entity
157 157
 	 */
158 158
 	protected function updateEntity(object $entity, ObjectManager $manager): void {
159
-		if($entity instanceof SearchableAlias) {
159
+		if ($entity instanceof SearchableAlias) {
160 160
 			$entity = $entity->getEntityToIndex();
161 161
 		}
162 162
 		$document = $this->getEntityToDocumentMapper()->createDocument($manager, $entity);
163
-		if($document !== null) {
163
+		if ($document !== null) {
164 164
 			$this->getSearchService()->saveDocument($document);
165 165
 			$this->needsFlush = true;
166 166
 		}
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 	 * @param object $entity
172 172
 	 */
173 173
 	protected function removeEntity(object $entity, ObjectManager $manager): void {
174
-		if($entity instanceof SearchableAlias) {
174
+		if ($entity instanceof SearchableAlias) {
175 175
 			$entity = $entity->getEntityToIndex();
176 176
 		}
177 177
 		$document = $this->getEntityToDocumentMapper()->createDocument($manager, $entity);
178
-		if($document !== null) {
178
+		if ($document !== null) {
179 179
 			$this->getSearchService()->removeDocument($document);
180 180
 			$this->needsFlush = true;
181 181
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,9 @@
 block discarded – undo
131 131
 	 * @param LifecycleEventArgs $args
132 132
 	 */
133 133
 	public function postUpdate(LifecycleEventArgs $args): void {
134
-		if(!$this->enableIndexing) return;
134
+		if(!$this->enableIndexing) {
135
+			return;
136
+		}
135 137
 		$this->updateEntity($args->getObject(), $args->getObjectManager());
136 138
 	}
137 139
 
Please login to merge, or discard this patch.
Services/DummySearchService.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function autocomplete(string $search, int $maxResults = 10): array {
68 68
 		$words = array();
69
-		foreach($this->index as $doc) {
70
-			foreach($doc->getFields() as $content) {
71
-				if(is_string($content)) {
69
+		foreach ($this->index as $doc) {
70
+			foreach ($doc->getFields() as $content) {
71
+				if (is_string($content)) {
72 72
 					$words = array_merge($words, explode(' ', $content));
73 73
 				}
74 74
 			}
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 		$facets = new FacetSetAdapter();
93 93
 
94 94
 		$hits = array();
95
-		foreach($this->index as $key => $doc) {
96
-			foreach($doc->getFields() as $content) {
97
-				if(is_string($content) && stripos($content, $term) !== false) {
98
-					if(!isset($hits[$key])) {
95
+		foreach ($this->index as $key => $doc) {
96
+			foreach ($doc->getFields() as $content) {
97
+				if (is_string($content) && stripos($content, $term) !== false) {
98
+					if (!isset($hits[$key])) {
99 99
 						$hits[$key] = 0;
100 100
 					}
101 101
 					$hits[$key] = $hits[$key] + 1;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		}
105 105
 		arsort($hits);
106 106
 		$results = array();
107
-		foreach(array_keys($hits) as $docId) {
107
+		foreach (array_keys($hits) as $docId) {
108 108
 			$doc = $this->index[$docId];
109 109
 			$facets->addFacetValue(FacetSet::FACET_ENTITY_TYPE, $doc->getEntityClass());
110 110
 			$facets->addFacetValue(FacetSet::FACET_AUTHOR, (string)$doc->getFieldValue(Document::FIELD_AUTHOR));
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		$id = $document->getEntityClass();
132 132
 		$id .= '#';
133 133
 		$entityId = $document->getEntityId();
134
-		if(is_scalar($entityId)) {
134
+		if (is_scalar($entityId)) {
135 135
 			$id .= $entityId;
136 136
 		} else {
137 137
 			$id .= md5(serialize($entityId));
Please login to merge, or discard this patch.