Skip to content

Commit 26789c5

Browse files
committed
Styling fixups
1 parent 4913590 commit 26789c5

File tree

7 files changed

+32
-13
lines changed

7 files changed

+32
-13
lines changed

src/DependencyInjection/DrupalExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class: Drupal\jsonapi\Routing\JsonApiParamEnhancer
161161
}
162162
}
163163

164-
protected function camelize($id)
164+
protected function camelize(string $id): string
165165
{
166166
return strtr(ucwords(strtr($id, ['_' => ' ', '.' => '_ ', '\\' => '_ '])), [' ' => '']);
167167
}

src/Drupal/Bootstrap.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ protected function addCoreNamespaces(): void
164164
// Add core test namespaces.
165165
$core_tests_dir = $this->drupalRoot . '/core/tests';
166166
$this->autoloader->add('Drupal\\Tests', $core_tests_dir);
167-
$this->autoloader->add('Drupal\\TestSite', $core_tests_dir);
168-
$this->autoloader->add('Drupal\\KernelTests', $core_tests_dir);
169-
$this->autoloader->add('Drupal\\FunctionalTests', $core_tests_dir);
170-
$this->autoloader->add('Drupal\\FunctionalJavascriptTests', $core_tests_dir);
167+
$this->autoloader->add('Drupal\\TestSite', $core_tests_dir);
168+
$this->autoloader->add('Drupal\\KernelTests', $core_tests_dir);
169+
$this->autoloader->add('Drupal\\FunctionalTests', $core_tests_dir);
170+
$this->autoloader->add('Drupal\\FunctionalJavascriptTests', $core_tests_dir);
171171
}
172172
protected function addModuleNamespaces(): void
173173
{

src/Drupal/DrupalServiceDefinition.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,25 @@
44

55
class DrupalServiceDefinition
66
{
7+
8+
/**
9+
* @var string
10+
*/
711
private $id;
12+
13+
/**
14+
* @var string|null
15+
*/
816
private $class;
17+
18+
/**
19+
* @var bool
20+
*/
921
private $public;
22+
23+
/**
24+
* @var string|null
25+
*/
1026
private $alias;
1127

1228
public function __construct(string $id, ?string $class, bool $public = true, ?string $alias = null)
@@ -48,6 +64,4 @@ public function getAlias(): ?string
4864
{
4965
return $this->alias;
5066
}
51-
5267
}
53-

src/Drupal/ServiceMap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,4 @@ public function getService(string $id): ?DrupalServiceDefinition
3939
{
4040
return $this->services[$id] ?? null;
4141
}
42-
4342
}

src/Drupal/ServiceMapFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
class ServiceMapFactory implements ServiceMapFactoryInterface
66
{
7+
/**
8+
* @var array
9+
*/
710
private $drupalServices;
811

912
public function __construct(array $drupalServiceMap = [])
@@ -15,5 +18,4 @@ public function create(): ServiceMap
1518
{
1619
return new ServiceMap($this->drupalServices);
1720
}
18-
1921
}

src/Drupal/ServiceMapFactoryInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44

55
interface ServiceMapFactoryInterface
66
{
7-
87
public function create(): ServiceMap;
9-
108
}

src/Type/ServiceDynamicReturnTypeExtension.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Type;
44

55
use PhpParser\Node\Expr\MethodCall;
6+
use PhpParser\Node\Scalar\String_;
67
use PHPStan\Analyser\Scope;
78
use PHPStan\Drupal\DrupalServiceDefinition;
89
use PHPStan\Drupal\ServiceMap;
@@ -43,7 +44,13 @@ public function getTypeFromMethodCall(
4344
return $returnType;
4445
}
4546

46-
$serviceId = (string)$methodCall->args[0]->value->value;
47+
$arg1 = $methodCall->args[0]->value;
48+
if (!$arg1 instanceof String_) {
49+
// @todo determine what these types are.
50+
return $returnType;
51+
}
52+
53+
$serviceId = $arg1->value;
4754

4855
if ($methodReflection->getName() === 'get') {
4956
$service = $this->serviceMap->getService($serviceId);
@@ -59,5 +66,4 @@ public function getTypeFromMethodCall(
5966

6067
throw new ShouldNotHappenException();
6168
}
62-
6369
}

0 commit comments

Comments
 (0)