Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dd01465
(CS) Change indentation from 4 to 2.
donquixote Jan 11, 2020
497d05d
(CS) Function/method curly bracket on same line.
donquixote Jan 11, 2020
6288df3
(CS) Class/interface curly bracket on same line.
donquixote Jan 11, 2020
5187c40
(CS) Put else/elseif on new line.
donquixote Jan 11, 2020
5dbf01e
(CS) Add blank line after last method in class.
donquixote Jan 11, 2020
0162911
(CS) Add blank lines around function.
donquixote Jan 11, 2020
bc07e6d
(CS) Constants TRUE, FALSE, NULL in uppercase.
donquixote Jan 11, 2020
1a7712f
(CS) Use FQCN in phpdoc.
donquixote Jan 11, 2020
b5ea94c
(CS) (doc) Standardize param description in docs.
donquixote Jan 11, 2020
6633372
(CS) Add inline spaces.
donquixote Jan 11, 2020
b25dc03
(CS) Use short array syntax.
donquixote Jan 11, 2020
d0ec311
(CS) Fix line breaks in condition.
donquixote Jan 11, 2020
ee4c144
(CS) (doc) Add blank lines within docs.
donquixote Jan 11, 2020
47d1df5
(CS) Semicolon on same line.
donquixote Jan 11, 2020
628aad8
(CS) Comma after last array element.
donquixote Jan 11, 2020
a2facbc
(CS) Fix indentation.
donquixote Jan 11, 2020
847c055
(CS) Parentheses after constructor call.
donquixote Jan 11, 2020
f4a49cc
(CS) Remove unused imports.
donquixote Jan 11, 2020
9bd4525
(CS) Normalize imports order.
donquixote Jan 11, 2020
18c4add
(CS) (doc) throws tag on new line.
donquixote Jan 11, 2020
47bbb14
(CS) Remove commented-out leftover code.
donquixote Jan 11, 2020
72469a3
(CS) Explicit return NULL.
donquixote Jan 11, 2020
07fb7a5
Add phpcs.xml to suppress remaining inspections.
donquixote Jan 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0"?>
<!--
See http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php
See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset
-->
<ruleset name="DrupalFeatures">
<description>Drupal coding standard, relaxed for Features module</description>

<!-- Inherit everything from "Drupal" coding standard. -->
<rule ref="Drupal">

<!-- Ignore violations that we don't intend to fix any time soon. -->
<!-- Let's not touch .txt files for now. -->
<exclude name="Drupal.Files.TxtFileLineLength.TooLong"/>
<!-- Let's not add native 'array' type hints for now. -->
<exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/>
<exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/>
<exclude name="Drupal.Commenting.DocComment.MissingShort"/>
<exclude name="Drupal.Commenting.InlineComment.NotCapital"/>
<exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="Drupal.Commenting.ClassComment.Missing"/>
<exclude name="Drupal.Commenting.InlineComment.InvalidEndChar"/>
<exclude name="Drupal.Commenting.DocComment.ShortFullStop"/>
<exclude name="Drupal.Commenting.DocComment.ShortNotCapital"/>
<exclude name="Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps"/>
<exclude name="Drupal.Commenting.DocComment.ShortSingleLine"/>
<exclude name="Drupal.Files.LineLength.TooLong"/>
<exclude name="Drupal.Arrays.Array.LongLineDeclaration"/>
<exclude name="Drupal.Commenting.VariableComment.Missing"/>
<exclude name="Drupal.Commenting.FileComment.Missing"/>
<!-- This would require a named alias, which we better avoid. -->
<exclude name="Drupal.Classes.FullyQualifiedNamespace.UseStatementMissing"/>
<!-- False positives for annotation classes. -->
<exclude name="Drupal.Classes.UnusedUseStatement.UnusedUse"/>
<!--
<exclude name=""/>
<exclude name=""/>
<exclude name=""/>
-->

<!-- add later! -->
<exclude name="Drupal.Commenting.FunctionComment.Missing"/>
<exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/>
<exclude name="Drupal.Commenting.FunctionComment.MissingParamType"/>
<exclude name="Drupal.Commenting.DocComment.Empty"/>
<exclude name="Drupal.Commenting.FunctionComment.ParamMissingDefinition"/>
<!--
<exclude name=""/>
<exclude name=""/>
<exclude name=""/>
<exclude name=""/>
<exclude name=""/>
<exclude name=""/>
<exclude name=""/>
-->

<!-- Ignore some rules that produce false positives. -->
<!-- This rule expects the wrong indentation for multiline expressions as
array values. -->
<exclude name="Drupal.Arrays.Array.ArrayIndentation"/>
<!-- Some strings for l() should not be translated. -->
<exclude name="Drupal.Semantics.LStringTranslatable.LArg"/>

<!-- More customizations for features. -->

<!-- Ignore some rules by choice. -->
<!-- Inline @var docs for local variables are very useful. -->
<exclude name="Drupal.Commenting.InlineComment.DocBlock"/>
<!-- Class names like "What_How" are preferable to "HowWhat". -->
<exclude name="Drupal.NamingConventions.ValidClassName.NoUnderscores"/>
<!-- Param and return docs on hooks may be redundant, but they are empowering
for the IDE. -->
<exclude name="Drupal.Commenting.HookComment.HookParamDoc"/>
<exclude name="Drupal.Commenting.HookComment.HookReturnDoc"/>
</rule>

<rule ref="Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps">
<exclude-pattern>tests/features.test</exclude-pattern>
</rule>

<rule ref="Drupal.Files.LineLength.TooLong">
<!-- Two function docs have too long lines that cannot be shortened. -->
<exclude-pattern>includes/features.ctools.inc</exclude-pattern>
</rule>

</ruleset>
125 changes: 60 additions & 65 deletions src/Cache/DrupalCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,75 @@
use Doctrine\Common\Cache\CacheProvider;
use Drupal\Core\Cache\CacheBackendInterface;

class DrupalCache extends CacheProvider
{
/**
* @var CacheBackendInterface
*/
private $cache;

/**
* @param CacheBackendInterface $cache
*/
public function __construct(CacheBackendInterface $cache)
{
$this->cache = $cache;
}
class DrupalCache extends CacheProvider {

/**
* @inheritdoc
*/
protected function doFetch($id)
{
if ($cache = $this->cache->get($id)) {
return $cache->data;
}
/**
* @var \Drupal\Core\Cache\CacheBackendInterface
*/
private $cache;

return false;
}
/**
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
*/
public function __construct(CacheBackendInterface $cache) {
$this->cache = $cache;
}

/**
* @inheritdoc
*/
protected function doContains($id)
{
return $this->doFetch($id) !== false;
/**
* @inheritdoc
*/
protected function doFetch($id) {
if ($cache = $this->cache->get($id)) {
return $cache->data;
}

/**
* @inheritdoc
*/
protected function doSave($id, $data, $lifeTime = 0)
{
if ($lifeTime === 0) {
$this->cache->set($id, $data);
} else {
$this->cache->set($id, $data, time() + $lifeTime);
}

return true;
}
return FALSE;
}

/**
* @inheritdoc
*/
protected function doDelete($id)
{
$this->cache->delete($id);
/**
* @inheritdoc
*/
protected function doContains($id) {
return $this->doFetch($id) !== FALSE;
}

return true;
/**
* @inheritdoc
*/
protected function doSave($id, $data, $lifeTime = 0) {
if ($lifeTime === 0) {
$this->cache->set($id, $data);
}
else {
$this->cache->set($id, $data, time() + $lifeTime);
}

/**
* @inheritdoc
*/
protected function doFlush()
{
$this->cache->deleteAll();
return TRUE;
}

return true;
}
/**
* @inheritdoc
*/
protected function doDelete($id) {
$this->cache->delete($id);

return TRUE;
}

/**
* @inheritdoc
*/
protected function doFlush() {
$this->cache->deleteAll();

return TRUE;
}

/**
* @inheritdoc
*/
protected function doGetStats() {
return NULL;
}

/**
* @inheritdoc
*/
protected function doGetStats()
{
return;
}
}
Loading