Skip to content

Commit

Permalink
PHPCS first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Apr 12, 2018
1 parent afd933d commit 7920b08
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 120 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"php": ">=7.1",
"zendframework/zend-servicemanager": "^3.3",
"zendframework/zend-authentication": "^2.5.3",
"zendframework/zend-code": "3.2.0",
"doctrine/doctrine-orm-module": "^1.1.5 || ^2.1",
"api-skeletons/zf-doctrine-data-fixture": "^5.0.7",
"api-skeletons/zf-doctrine-repository": "^1.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^2",
"zendframework/zend-code": "3.2.0",
"api-skeletons/coding-standard": "^1.0",
"phpunit/phpunit": "^4.0"
},
"autoload": {
Expand Down
27 changes: 27 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<ruleset name="API Skeletons" namespace="API-Skeletons\CS\Standard">
<description>v1.0 Coding Standard for API Skeletons</description>
<file>src</file>
<file>test</file>
<exclude-pattern type="relative">Bootstrap.php</exclude-pattern>
<exclude-pattern type="relative">*/data/*</exclude-pattern>
<arg name="colors"/>
<rule ref="PSR1"/>
<rule ref="PSR2"/>
<rule ref="Generic.Arrays.ArrayIndent"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Commenting.Fixme"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Formatting.SpaceAfterNot"/>
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="./vendor/api-skeletons/coding-standard/phpcs/Sniffs/Strings/ConcatenationSpacingSniff.php"/>
</ruleset>
1 change: 0 additions & 1 deletion src/Entity/AuditEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,3 @@ public function getTargetEntity()
return $this->targetEntity;
}
}

1 change: 0 additions & 1 deletion src/Entity/Revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,3 @@ public function getRevisionEntity()
return $this->revisionEntity;
}
}

1 change: 0 additions & 1 deletion src/Entity/RevisionEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,3 @@ public function getRevisionType()
return $this->revisionType;
}
}

1 change: 0 additions & 1 deletion src/Entity/RevisionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ public function getRevisionEntity()
return $this->revisionEntity;
}
}

1 change: 0 additions & 1 deletion src/Entity/TargetEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,3 @@ public function getParent()
return $this->parent;
}
}

4 changes: 2 additions & 2 deletions src/Fixture/RevisionTypeFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class RevisionTypeFixture implements
public function load(ObjectManager $auditObjectManager)
{
// Add RevisionType
foreach (array('insert', 'update', 'delete', 'epoch') as $name) {
foreach (['insert', 'update', 'delete', 'epoch'] as $name) {
$revisionType = $auditObjectManager
->getRepository('ZF\Doctrine\Audit\Entity\RevisionType')
->findOneBy(
[
'name' => $name,
'name' => $name,
]
);

Expand Down
16 changes: 8 additions & 8 deletions src/Loader/EntityAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public function loadClass($auditClassName, $type)
$auditClass->addProperty('revisionEntity', null, PropertyGenerator::FLAG_PROTECTED);
$auditClass->addMethod(
'getRevisionEntity',
array(),
[],
MethodGenerator::FLAG_PUBLIC,
" return \$this->revisionEntity;"
);

$auditClass->addMethod(
'setRevisionEntity',
array('value'),
['value'],
MethodGenerator::FLAG_PUBLIC,
" \$this->revisionEntity = \$value;\n\nreturn \$this;
"
Expand All @@ -80,13 +80,13 @@ public function loadClass($auditClassName, $type)

$auditClass->addMethod(
'getAssociationMappings',
array(),
[],
MethodGenerator::FLAG_PUBLIC,
"return unserialize('" . serialize($auditedClassMetadata->getAssociationMappings()) . "');"
);

// Add exchange array method
$setters = array();
$setters = [];
foreach ($fields as $fieldName) {
$setters[] = '$this->' . $fieldName
. ' = (isset($data["' . $fieldName . '"])) ? $data["' . $fieldName . '"]: null;';
Expand All @@ -95,24 +95,24 @@ public function loadClass($auditClassName, $type)

$auditClass->addMethod(
'getArrayCopy',
array(),
[],
MethodGenerator::FLAG_PUBLIC,
"return array(\n" . implode(",\n", $arrayCopy) . "\n);"
);

$auditClass->addMethod(
'exchangeArray',
array('data'),
['data'],
MethodGenerator::FLAG_PUBLIC,
implode("\n", $setters)
);

// Add function to return the entity class this entity audits
$auditClass->addMethod(
'getAuditedEntityClass',
array(),
[],
MethodGenerator::FLAG_PUBLIC,
" return '" . addslashes($className) . "';"
" return '" . addslashes($className) . "';"
);

eval($auditClass->generate());
Expand Down
16 changes: 8 additions & 8 deletions src/Loader/JoinEntityAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ public function loadClass($auditClassName, $type)
$auditClass->addProperty('revisionEntity', null, PropertyGenerator::FLAG_PROTECTED);
$auditClass->addMethod(
'getRevisionEntity',
array(),
[],
MethodGenerator::FLAG_PUBLIC,
" return \$this->revisionEntity;"
);

$auditClass->addMethod(
'setRevisionEntity',
array('value'),
['value'],
MethodGenerator::FLAG_PUBLIC,
" \$this->revisionEntity = \$value;\n\nreturn \$this;
"
Expand All @@ -98,13 +98,13 @@ public function loadClass($auditClassName, $type)

$auditClass->addMethod(
'getAssociationMappings',
array(),
[],
MethodGenerator::FLAG_PUBLIC,
"return unserialize('" . serialize($mapping) . "');"
);

// Add exchange array method
$setters = array();
$setters = [];
foreach ($fields as $field) {
$setters[] = '$this->' . $field['name']
. ' = (isset($data["' . $field['name'] . '"])) ? $data["' . $field['name'] . '"]: null;';
Expand All @@ -113,24 +113,24 @@ public function loadClass($auditClassName, $type)

$auditClass->addMethod(
'getArrayCopy',
array(),
[],
MethodGenerator::FLAG_PUBLIC,
"return array(\n" . implode(",\n", $arrayCopy) . "\n);"
);

$auditClass->addMethod(
'exchangeArray',
array('data'),
['data'],
MethodGenerator::FLAG_PUBLIC,
implode("\n", $setters)
);

// Add function to return the entity class this entity audits
$auditClass->addMethod(
'getAuditedEntityClass',
array(),
[],
MethodGenerator::FLAG_PUBLIC,
" return '" . addslashes($auditClassName) . "';"
" return '" . addslashes($auditClassName) . "';"
);

// echo "Created " . $auditClass->getName() . "\n" . $auditClass->getNamespaceName() . "\n";
Expand Down
10 changes: 5 additions & 5 deletions src/Mapping/Driver/EntityDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
$metadataFactory = $this->getObjectManager()->getMetadataFactory();
$builder = new ClassMetadataBuilder($metadata);

$identifiers = array();
$identifiers = [];

// Get the entity this entity audits
$metadataClassName = $metadata->getName();
Expand All @@ -57,11 +57,11 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
$builder->addField(
$fieldName,
$auditedClassMetadata->getTypeOfField($fieldName),
array(
[
'columnName' => $auditedClassMetadata->getColumnName($fieldName),
'nullable' => true,
'quoted' => true
)
]
);

if ($auditedClassMetadata->isIdentifier($fieldName)) {
Expand All @@ -80,7 +80,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
$builder->addField(
$mapping['fieldName'],
'bigint',
array('nullable' => true, 'columnName' => $field)
['nullable' => true, 'columnName' => $field]
);
}
} elseif (isset($mapping['joinColumnFieldNames'])) {
Expand All @@ -89,7 +89,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
$builder->addField(
$mapping['fieldName'],
'bigint',
array('nullable' => true, 'columnName' => $field)
['nullable' => true, 'columnName' => $field]
);
}
} else {
Expand Down
20 changes: 10 additions & 10 deletions test/TestConfig.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php
return array(
'modules' => array(
return [
'modules' => [
'Zend\Router',
'ZF\Doctrine\Audit',
'ZFTest\Doctrine\Audit',
'DoctrineModule',
'DoctrineORMModule',
'ZF\Doctrine\DataFixture',
'ZF\Doctrine\Repository',
),
'module_listener_options' => array(
'config_glob_paths' => array(
],
'module_listener_options' => [
'config_glob_paths' => [
'../../../config/autoload/{,*.}{global,local}.php',
'autoload/{,*.}{global,local}.php',
),
'module_paths' => array(
],
'module_paths' => [
'module',
'vendor',
),
),
);
],
],
];
28 changes: 14 additions & 14 deletions test/ZFTest/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class Module implements
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
return [
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__,
),
),
);
],
],
];
}

public function getConfig()
Expand All @@ -31,17 +31,17 @@ public function getConfig()

public function getServiceConfig()
{
return array(
'factories' => array(
'doctrine.entitymanager.orm_zf_doctrine_audit'
return [
'factories' => [
'doctrine.entitymanager.orm_zf_doctrine_audit'
=> new EntityManagerFactory('orm_zf_doctrine_audit'),
'doctrine.connection.orm_zf_doctrine_audit'
'doctrine.connection.orm_zf_doctrine_audit'
=> new DBALConnectionFactory('orm_zf_doctrine_audit'),
'doctrine.configuration.orm_zf_doctrine_audit'
'doctrine.configuration.orm_zf_doctrine_audit'
=> new ConfigurationFactory('orm_zf_doctrine_audit'),
'doctrine.eventmanager.orm_zf_doctrine_audit'
'doctrine.eventmanager.orm_zf_doctrine_audit'
=> new EventManagerFactory('orm_zf_doctrine_audit'),
),
);
],
];
}
}
Loading

0 comments on commit 7920b08

Please sign in to comment.