Skip to content

Commit

Permalink
Enable inferPrivatePropertyTypeFromConstructor on PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
j0k3r committed Jul 8, 2019
1 parent da49da0 commit e3ab396
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ parameters:
-
message: '#between false and DOMNodeList will always evaluate to false#'
path: %currentWorkingDirectory%/src/Extractor/ContentExtractor.php

inferPrivatePropertyTypeFromConstructor: true
15 changes: 5 additions & 10 deletions src/Extractor/ContentExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ class ContentExtractor
private $date = null;
private $success = false;
private $nextPageUrl;
/** @var LoggerInterface */
private $logger;
/** @var ConfigBuilder */
private $configBuilder;

/**
* @param array $config
* @param LoggerInterface|null $logger
* @param ConfigBuilder $configBuilder
* @param ConfigBuilder|null $configBuilder
*/
public function __construct($config = [], LoggerInterface $logger = null, ConfigBuilder $configBuilder = null)
{
Expand Down Expand Up @@ -69,15 +71,8 @@ public function __construct($config = [], LoggerInterface $logger = null, Config

$this->config = $resolver->resolve($config);

$this->logger = $logger;
if (null === $logger) {
$this->logger = new NullLogger();
}

$this->configBuilder = $configBuilder;
if (null === $this->configBuilder) {
$this->configBuilder = new ConfigBuilder($this->config['config_builder'], $this->logger);
}
$this->logger = null === $logger ? new NullLogger() : $logger;
$this->configBuilder = null === $configBuilder ? new ConfigBuilder($this->config['config_builder'], $this->logger) : $configBuilder;
}

public function setLogger(LoggerInterface $logger)
Expand Down
7 changes: 4 additions & 3 deletions src/Graby.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
class Graby
{
private $debug = false;
/** @var LoggerInterface */
private $logger;
private $logLevel = 'info';

Expand All @@ -43,9 +44,9 @@ class Graby
private $imgNoReferrer = false;

/**
* @param array $config
* @param Client|null $client Http client
* @param ConfigBuilder $configBuilder
* @param array $config
* @param Client|null $client Http client
* @param ConfigBuilder|null $configBuilder
*/
public function __construct($config = [], Client $client = null, ConfigBuilder $configBuilder = null)
{
Expand Down
6 changes: 2 additions & 4 deletions src/SiteConfig/ConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class ConfigBuilder
{
/** @var LoggerInterface */
private $logger;
private $config = [];
private $configFiles = [];
Expand All @@ -32,10 +33,7 @@ public function __construct($config = [], LoggerInterface $logger = null)

$this->config = $resolver->resolve($config);

$this->logger = $logger;
if (null === $logger) {
$this->logger = new NullLogger();
}
$this->logger = null === $logger ? new NullLogger() : $logger;

$this->loadConfigFiles();
}
Expand Down

0 comments on commit e3ab396

Please sign in to comment.