Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more strict phpstan rules #10

Merged
merged 5 commits into from Jul 31, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

[PATCH] Use more precise null and type checks

  • Loading branch information
core23 committed Jul 31, 2019
commit bdfdda258caf1e4bc6e6b8d959f91154c47cb6e7
@@ -61,7 +61,7 @@ public function getSetting(string $name, $default = null)
public function getTtl(): int
{
if (!$this->getSetting('use_cache', true)) {
if (true !== $this->getSetting('use_cache', true)) {
return 0;
}
@@ -52,14 +52,10 @@ public function toXML(): string
foreach ($this->defintionManager->getAll() as $sitemap) {
try {
$serviceXml = $this->fetch($sitemap);
$xml .= $this->fetch($sitemap);
} catch (InvalidArgumentException $exception) {
throw new RuntimeException('Error accessing cache', $exception->getCode(), $exception);
}
if ($serviceXml) {
$xml .= $serviceXml;
}
}
$xml .= '</urlset>';
@@ -76,13 +72,13 @@ private function fetch(SitemapDefinitionInterface $definition): string
{
$name = sprintf('Sitemap_%s', md5(serialize($definition)));
if ($this->cache && $this->cache->has($name)) {
if (null !== $this->cache && $this->cache->has($name)) {
return $this->cache->get($name);
}
$service = $this->sitemapServiceManager->get($definition);
if (!$service) {
if (null === $service) {
return '';
}
@@ -91,7 +87,7 @@ private function fetch(SitemapDefinitionInterface $definition): string
$xml .= $this->getLocEntry($entry);
}
if ($this->cache) {
if (null !== $this->cache) {
$this->cache->set($name, $xml, $definition->getTtl());
}
@@ -13,7 +13,6 @@
use Core23\SitemapBundle\Definition\SitemapDefinitionInterface;
use Core23\SitemapBundle\Exception\SitemapNotFoundException;
use InvalidArgumentException;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class SitemapServiceManager implements SitemapServiceManagerInterface
@@ -31,10 +30,6 @@ public function __construct(array $services = [])
$this->services = [];
foreach ($services as $id => $service) {
if (!$service instanceof SitemapServiceInterface) {
throw new InvalidArgumentException(sprintf('The "%s" service is not a valid SitemapServiceInterface', \get_class($service)));
}
$this->addSitemap($id, $service);
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.