for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
*
* @author romain[at]sunnysideup.co.nz
* @description: adds functions to the shopping cart
**/
class WishListMemberDecorator extends DataObjectDecorator
You can fix this by adding a namespace to your class:
namespace YourVendor; class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
{
* Define extra database fields for member object.
* @return array
*/
public function extraStatics()
return array(
'db' => array(
//Wish list will be stored as a serialised array.
'WishList' => 'Text'
)
);
}
* standard SS function - we dont need to show the Wish List field in the CMS.
public function updateCMSFields(&$fields)
$fields->removeByName("WishList");
$member = Member::currentUser();
if ($member && $member->IsAdmin()) {
$html = "";
$html
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
$array = unserialize($this->owner->WishList);
$links = array();
if (is_array($array) && count($array)) {
foreach ($array as $item) {
$object = DataObject::get_by_id($item[0], $item[1]);
if ($object) {
$links[] = "<a href=\"".$object->Link()."\">".$object->Title."</a>";
} else {
$links[] = "error in retrieving object ".implode(", ", $item);
$links[] = "no items on wishlist";
$html = "<ul><li>".implode("</li><li>", $links)."</li></ul>";
$field = new LiteralField(
"WishListOverview",
$fields->addFieldToTab("Root.WishList", $field);
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.