Skip to content

Commit

Permalink
Merge pull request #596 from mikysan/fix-static-env-property
Browse files Browse the repository at this point in the history
Fix access to static $env property  form 'self::$env' to 'static::$env'
  • Loading branch information
alexislefebvre authored Jan 21, 2022
2 parents 46c7666 + d97e51e commit 50f1ada
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions src/Test/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function runCommand(string $name, array $params = [], bool $reuseKerne
static::ensureKernelShutdown();
}

$kernel = static::bootKernel(['environment' => self::$env]);
$kernel = static::bootKernel(['environment' => static::$env]);
$kernel->boot();
} else {
$kernel = $this->getContainer()->get('kernel');
Expand Down Expand Up @@ -208,10 +208,10 @@ public function isDecorated(bool $decorated): void
*/
private function getDependencyInjectionContainer(): ContainerInterface
{
$cacheKey = self::$env;
$cacheKey = static::$env;
if (empty($this->containers[$cacheKey])) {
$kernel = static::createKernel([
'environment' => self::$env,
'environment' => static::$env,
]);
$kernel->boot();

Expand All @@ -229,7 +229,7 @@ private function getDependencyInjectionContainer(): ContainerInterface
protected static function createKernel(array $options = []): KernelInterface
{
if (!isset($options['environment'])) {
$options['environment'] = self::$env;
$options['environment'] = static::$env;
}

return parent::createKernel($options);
Expand All @@ -253,9 +253,9 @@ public function __set($name, $value)
throw new \Exception(sprintf('There is no property with name "%s"', $name));
}

@trigger_error('Setting "environment" property is deprecated, please use self::$env.', \E_USER_DEPRECATED);
@trigger_error('Setting "environment" property is deprecated, please use static::$env.', \E_USER_DEPRECATED);

self::$env = $value;
static::$env = $value;
}

public function __isset($name)
Expand All @@ -264,7 +264,7 @@ public function __isset($name)
throw new \Exception(sprintf('There is no property with name "%s"', $name));
}

@trigger_error('Checking "environment" property is deprecated, please use self::$env.', \E_USER_DEPRECATED);
@trigger_error('Checking "environment" property is deprecated, please use static::$env.', \E_USER_DEPRECATED);

return true;
}
Expand All @@ -275,9 +275,9 @@ public function __get($name)
throw new \Exception(sprintf('There is no property with name "%s"', $name));
}

@trigger_error('Getting "environment" property is deprecated, please use self::$env.', \E_USER_DEPRECATED);
@trigger_error('Getting "environment" property is deprecated, please use static::$env.', \E_USER_DEPRECATED);

return self::$env;
return static::$env;
}

/**
Expand Down Expand Up @@ -496,7 +496,7 @@ protected function createClientWithParams(array $params, ?string $username = nul
static::ensureKernelShutdown();
}

$client = static::createClient(['environment' => self::$env], $params);
$client = static::createClient(['environment' => static::$env], $params);

if ($this->firewallLogins) {
// has to be set otherwise "hasPreviousSession" in Request returns false.
Expand Down
4 changes: 2 additions & 2 deletions tests/Command/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testRunCommandWithInputs(): void
public function testRunCommandWithoutOptionsAndNotReuseKernel(bool $useEnv): void
{
if ($useEnv) {
self::$env = 'test';
static::$env = 'test';
} else {
$this->environment = 'test';
}
Expand All @@ -96,7 +96,7 @@ public function testRunCommandWithoutOptionsAndNotReuseKernel(bool $useEnv): voi

// Run command and reuse kernel
if ($useEnv) {
self::$env = 'prod';
static::$env = 'prod';
} else {
$this->environment = 'prod';
}
Expand Down

0 comments on commit 50f1ada

Please sign in to comment.