Coding standards

This commit is contained in:
Romain Neutron
2012-01-26 17:45:02 +01:00
parent 91dd71cb19
commit b7805dda58
10 changed files with 170 additions and 152 deletions

View File

@@ -27,6 +27,7 @@ $finder
->files()
->name('*.md')
->name('*.php')
->name('*.inc')
->name('*.php.dist')
->name('*.twig')
->name('*.xml')

View File

@@ -21,7 +21,7 @@ require_once __DIR__ . "/../../vendor/Phlickr/Api.php";
*/
/**
*
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
@@ -34,17 +34,17 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface
public function __construct()
{
}
public function get_created_on()
{
}
public function get_description()
{
}
public function get_id()
@@ -54,12 +54,12 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface
public function get_thumbnail($width = 120, $height = 90)
{
}
public function get_title()
{
}
public function get_type()
@@ -69,27 +69,27 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface
public function get_updated_on()
{
}
public function get_url()
{
}
public function get_category()
{
}
public function is_private()
{
}
public function get_rating()
{
}
}
@@ -102,27 +102,27 @@ class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface
public function __construct()
{
}
public function get_category()
{
}
public function get_created_on()
{
}
public function get_description()
{
}
public function get_duration()
{
}
public function get_id()
@@ -132,17 +132,17 @@ class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface
public function get_rating()
{
}
public function get_thumbnail()
{
}
public function get_title()
{
}
public function get_type()
@@ -152,22 +152,22 @@ class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface
public function get_updated_on()
{
}
public function get_url()
{
}
public function get_view_count()
{
}
public function is_private()
{
}
}
@@ -187,17 +187,17 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
protected function initialize_transport()
{
}
protected function set_auth_params()
{
}
protected function set_transport_authentication_params()
{
}
public function get_terms_url()
@@ -206,7 +206,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
}
/**
*
*
* @return Array
*/
public function connect()
@@ -216,7 +216,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
/**
*
* @return Bridge_Api_Interface
* @return Bridge_Api_Interface
*/
public function reconnect()
{
@@ -225,7 +225,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
/**
*
* @return Bridge_Api_Interface
* @return Bridge_Api_Interface
*/
public function disconnect()
{
@@ -234,7 +234,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
/**
*
* @return boolean
* @return boolean
*/
public function is_connected()
{
@@ -242,16 +242,16 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
}
/**
*
* @return Bridge_Api_Interface
*
* @return Bridge_Api_Interface
*/
public function set_locale($locale)
{
}
/**
*
*
* @return string
*/
public function get_name()
@@ -260,39 +260,39 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
}
/**
*
*
* @return string
*/
public function get_icon_url()
{
}
/**
*
*
* @return string
*/
public function get_image_url()
{
}
/**
*
*
* @return string
*/
public function get_url()
{
}
/**
*
*
* @return string
*/
public function get_infos()
{
}
public function get_object_class_from_type($type)
@@ -320,12 +320,12 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
public function get_element_types()
{
}
public function get_container_types()
{
}
public function get_element_from_id($element_id, $object)
@@ -333,6 +333,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$element = new Bridge_Api_Apitest_Element();
$element->id = $element_id;
$element->type = $object;
return $element;
}
@@ -341,12 +342,13 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$container = new Bridge_Api_Apitest_Containers();
$container->id = $element_id;
$container->type = $object;
return $container;
}
public function get_category_list()
{
}
public function get_user_name()
@@ -368,6 +370,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$element_collection->add_element(new Bridge_Api_Apitest_Element());
$i++;
}
return $element_collection;
}
@@ -380,12 +383,13 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$container_collection->add_element(new Bridge_Api_Apitest_Containers());
$i++;
}
return $container_collection;
}
public function update_element($object, $object_id, Array $datas)
{
}
public function create_container($container_type, \Symfony\Component\HttpFoundation\Request $request)
@@ -416,7 +420,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
}
/**
*
*
* @return Closure
*/
public function acceptable_records()
@@ -425,32 +429,33 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
{
return true;
};
return $func;
}
public function get_element_status(Bridge_Element $element)
{
}
public function map_connector_to_element_status($status)
{
}
public function get_error_message_from_status($connector_status)
{
}
public function upload(record_adapter &$record, array $options = array())
{
}
public function is_valid_object_id($object_id)
{
}
public function is_configured()
@@ -463,8 +468,10 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
if (self::$hasError)
{
self::$hasError = false;
return array('title' => 'too long');
}
return array();
}
@@ -475,7 +482,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
public function is_multiple_upload()
{
}
public function check_update_constraints(Array $datas)
@@ -493,6 +500,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
elseif (self::$hasError)
{
self::$hasError = false;
return array('title' => 'too long');
}
}
@@ -509,12 +517,12 @@ class Bridge_Api_Auth_None extends Bridge_Api_Auth_Abstract implements Bridge_Ap
public function connect($param)
{
}
public function parse_request_token()
{
}
public function reconnect()
@@ -539,12 +547,12 @@ class Bridge_Api_Auth_None extends Bridge_Api_Auth_Abstract implements Bridge_Ap
public function get_auth_signatures()
{
}
public function set_parameters(Array $parameters)
{
}
}
}

View File

@@ -1,8 +1,8 @@
<?php
/**
* @example
*
* @example
*
try
{
$validator = new W3CFeedRawValidator($xml);
@@ -22,7 +22,7 @@
{
print "\n" . $e->getMessage();
}
*
*
*/
/**
@@ -30,7 +30,7 @@
*/
class W3CFeedValidatorException extends Exception
{
}
/**
@@ -55,7 +55,7 @@ class W3CFeedUrlValidator extends W3CFeedValidator
/**
* The URL of the document to validate
* @var string
* @var string
*/
private $url;
@@ -88,12 +88,13 @@ class W3CFeedUrlValidator extends W3CFeedValidator
{
throw new W3CFeedValidatorException("Unable to request W3C API");
}
return new W3CFeedValidatorResponse($response);
}
/**
* Check if an url is valid
* @param string $url
* @param string $url
* @return boolean
*/
private function isValidUrl($url)
@@ -112,14 +113,14 @@ class W3CFeedRawValidator extends W3CFeedValidator
/**
* The source of the document to validate
* @var string
* @var string
*/
private $rawData;
/**
* Constructor
* Init instance which the specified data to validate
* @param string $rawData
* @param string $rawData
*/
public function __construct($rawData)
{
@@ -151,6 +152,7 @@ class W3CFeedRawValidator extends W3CFeedValidator
{
throw new W3CFeedValidatorException("Unable to request W3C API");
}
return new W3CFeedValidatorResponse($response);
}
@@ -209,36 +211,40 @@ class W3CFeedValidatorResponse
$string .= $name . "=>" . $detail . "\n";
}
}
return $string;
}
/**
* Check if the XML is valid
* @return boolean
* Check if the XML is valid
* @return boolean
*/
public function isValid()
{
$xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:validity";
return $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== "false";
}
/**
* Check for errors
* @return boolean
* @return boolean
*/
public function hasError()
{
$xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:errors/m:errorcount";
return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0;
}
/**
* check fro warnings
* @return boolean
* @return boolean
*/
public function hasWarning()
{
$xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:warnings/m:warningcount";
return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0;
}
@@ -271,8 +277,8 @@ class W3CFeedValidatorResponse
* 1 => etc ..
* }
* }
*
* @return array
*
* @return array
*/
public function getWarnings()
{
@@ -286,12 +292,13 @@ class W3CFeedValidatorResponse
$warnings[] = $this->domNodeToArray($warning);
}
}
return $warnings;
}
/**
* Get an array with all errors as follow
* @return array
* @return array
*/
public function getErrors()
{
@@ -305,14 +312,15 @@ class W3CFeedValidatorResponse
$errors[] = $this->domNodeToArray($error);
}
}
return $errors;
}
/**
* @source http://www.ermshaus.org/2010/12/php-transform-domnode-to-array
*
*
* Transforms the contents of a DOMNode to an associative array
*
*
* XML node names become array keys, attributes will be discarded. If $node
* doesn't contain child nodes, a string will be returned.
*

View File

@@ -43,4 +43,4 @@ class SimpleTestListener implements PHPUnit_Framework_TestListener
return;
}
}
}

View File

@@ -17,7 +17,7 @@ use Symfony\Component\HttpFoundation\Response;
use Doctrine\Common\DataFixtures\Loader;
/**
*
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
@@ -36,7 +36,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
const USER_AGENT_IPHONE = 'Mozilla/5.0 (iPod; U; CPU iPhone OS 2_1 like Mac OS X; fr-fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F137 Safari/525.20';
/**
*
* @var Symfony\Component\HttpKernel\Client
* @var Symfony\Component\HttpKernel\Client
*/
protected $client;
@@ -353,14 +353,14 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Tell if tables were updated with new schemas
* @var boolean
* @var boolean
*/
protected static $updated;
/**
* if yo need record for your test
* just tell how many
* example = $need_records = 2
* just tell how many
* example = $need_records = 2
* will create 2 records self::$record_1 & self::$record_2
* You can use the same mechanism for subdef and stories
* @var mixed int|boolean
@@ -371,13 +371,13 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
*
* @var collection
* @var collection
*/
protected static $collection;
/**
*
* @var collection
* @var collection
*/
protected static $collection_no_access;
@@ -395,7 +395,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
*
* @var \Alchemy\Phrasea\Core
* @var \Alchemy\Phrasea\Core
*/
protected static $core;
@@ -439,8 +439,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* Delete temporay sqlite database
* Create schema using $this->classesMetatdas
* Load DoctrineTestServices
*
* @return
*
* @return
*/
public function __construct()
{
@@ -487,9 +487,9 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
//set Mozilla user agent as default
$browser = Browser::getInstance();
$browser->setUserAgent(self::USER_AGENT_FIREFOX8MAC);
$this->purgeDatabase();
self::$user->ACL()->revoke_access_from_bases(array(self::$collection_no_access->get_base_id()));
}
@@ -503,8 +503,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Insert fixture contained in the specified fixtureLoader
* into sqlLite test temporary database
*
* @param Doctrine\Common\DataFixtures\Loader $fixtureLoader
*
* @param Doctrine\Common\DataFixtures\Loader $fixtureLoader
*/
public function insertFixtureInDatabase(Doctrine\Common\DataFixtures\Loader $fixtureLoader, $append = true)
{
@@ -538,7 +538,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Insert one basket entry ans set current authenticated user as owner
*
*
* @return \Entities\Basket
*/
protected function insertOneBasket()
@@ -561,23 +561,23 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$this->fail('Fail load one Basket : ' . $e->getMessage());
}
}
protected function insertOneUsrList(\User_Adapter $user)
{
try
{
$loader = new Loader();
$UsrOwner = new PhraseaFixture\UsrLists\UsrListOwner();
$UsrOwner->setUser($user);
$loader->addFixture($UsrOwner);
$UsrList = new PhraseaFixture\UsrLists\UsrList();
$loader->addFixture($UsrList);
$this->insertFixtureInDatabase($loader);
@@ -588,33 +588,33 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$this->fail('Fail load one UsrList : ' . $e->getMessage());
}
}
/**
*
* @param \Entities\UsrList $UsrList
* @return \Entities\UsrListEntry
* @return \Entities\UsrListEntry
*/
protected function insertOneUsrListEntry(\User_adapter $owner, \User_adapter $user)
{
try
{
$loader = new Loader();
$UsrOwner = new PhraseaFixture\UsrLists\UsrListOwner();
$UsrOwner->setUser($owner);
$loader->addFixture($UsrOwner);
$UsrList = new PhraseaFixture\UsrLists\UsrList();
$loader->addFixture($UsrList);
$UsrEntry = new PhraseaFixture\UsrLists\UsrListEntry();
// $UsrEntry->setList($UsrList);
$UsrEntry->setUser($user);
$loader->addFixture($UsrEntry);
$this->insertFixtureInDatabase($loader);
@@ -628,7 +628,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Insert five baskets and set current authenticated user as owner
*
*
* @return \Entities\Basket
*/
protected function insertFiveBasket()
@@ -724,10 +724,10 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Create a new basket with current auhtenticated user as owner
* Create a new sessionValidation with the newly created basket
* Set current authenticated user as sessionValidation initiator
* Set current authenticated user as sessionValidation initiator
* Add 2 records as elments of the newly created basket
* Add 2 participants to the newly created sessionValidation
*
*
* @return \Entities\Basket
*/
protected function insertOneBasketEnv()
@@ -765,7 +765,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* One basket
* One story
* One ValidationSession & one participant
* @return
* @return
*/
protected function insertOneWZ()
{
@@ -827,7 +827,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$serviceName
, $confService
);
$this->app['Core']["Twig"] = $templateServiceBuilder->buildService()->getService();
}
@@ -870,7 +870,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$upgrader = new Setup_Upgrade($appbox);
$appbox->forceUpgrade($upgrader);
unset($upgrader);
self::$updated = true;
}
@@ -884,7 +884,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* self::$user
* self::$user_alt1
* self::$user_alt2
*
*
* @return void;
*/
private static function createSetOfUserTests()
@@ -920,8 +920,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Give Bases Rights to User
*
* @param \User_AAdapter $user
*
* @param \User_AAdapter $user
*/
private static function giveRightsToUser(\User_Adapter $user)
{
@@ -975,7 +975,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Set self::$collection
* @return void
* @return void
*/
private static function setCollection()
{
@@ -1011,15 +1011,15 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
self::$collection = $coll;
self::$collection_no_access = $collection_no_acces;
return;
}
/**
* Generate a set of stories for the current test suites
*
*
* @return void
*/
private static function generateStories()
@@ -1033,7 +1033,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
, true
);
}
if (static::$need_story && !self::$story_2 instanceof record_adapter)
{
self::$story_2 = \record_adapter::create(
@@ -1048,9 +1048,9 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
/**
* Generate a set subdef according to the records previously created
*
* @return void
* Generate a set subdef according to the records previously created
*
* @return void
*/
private static function generateSubdefs()
{
@@ -1172,6 +1172,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
self::$generated_subdefs['a23'] = true;
}
}
return;
}
@@ -1310,8 +1311,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Delete previously created Ressources
*
* @return void
*
* @return void
*/
private static function deleteRessources()
{

View File

@@ -10,7 +10,7 @@
*/
/**
*
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
@@ -41,4 +41,4 @@ abstract class PhraseanetPHPUnitAuthenticatedAbstract extends PhraseanetPHPUnitA
parent::tearDown();
}
}
}

View File

@@ -10,7 +10,7 @@
*/
/**
*
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
@@ -24,4 +24,4 @@ use Symfony\Component\HttpFoundation\Response;
abstract class PhraseanetWebTestCaseAbstract extends \PhraseanetPHPUnitAbstract
{
}
}

View File

@@ -10,7 +10,7 @@
*/
/**
*
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
@@ -41,4 +41,4 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU
$session->logout();
}
}
}

View File

@@ -1,16 +1,16 @@
<?php
function getRawEditorData($paramName) {
if ($paramName) {
if (isset($_POST[$paramName])) {
return $_POST[$paramName];
} else if (isset($_GET[$paramName])) {
return $_GET[$paramName];
} else {
return null;
}
} else {
return null;
}
if ($paramName) {
if (isset($_POST[$paramName])) {
return $_POST[$paramName];
} else if (isset($_GET[$paramName])) {
return $_GET[$paramName];
} else {
return null;
}
} else {
return null;
}
}
?>

View File

@@ -1,16 +1,16 @@
<?php
function getRawData($paramName) {
if ($paramName) {
if (isset($_POST[$paramName])) {
return $_POST[$paramName];
} else if (isset($_GET[$paramName])) {
return $_GET[$paramName];
} else {
return null;
}
} else {
return null;
}
if ($paramName) {
if (isset($_POST[$paramName])) {
return $_POST[$paramName];
} else if (isset($_GET[$paramName])) {
return $_GET[$paramName];
} else {
return null;
}
} else {
return null;
}
}
?>