This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function status() { | |
kextstat | grep org.virtualbox.kext > /dev/null 2>&1 ; | |
vbox=$((1-$?)) | |
kextstat | grep com.github.osxfuse > /dev/null 2>&1 ; | |
fuse=$((1-$?)) | |
} | |
status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<rule name="ErrorControlOperator" | |
message="Remove error control operator '@' on line {0}." | |
class="PHPMD\Rule\CleanCode\ErrorControlOperator" | |
externalInfoUrl="http://phpmd.org/rules/cleancode.html#errorcontroloperator"> | |
<description> | |
<![CDATA[ | |
Error suppression should be avoided if possible as it doesn't just suppress the error, that you | |
are trying to stop, but will also suppress errors that you didn't predict would ever occur. | |
Moreover it slows down execution of your code by average of 1.75x. Consider changing | |
error_reporting() level and/or setting up your own error handler. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... | |
class ErrorControlOperator extends AbstractRule implements MethodAware, FunctionAware | |
{ | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class testAppliedToClassesAndMethods | |
{ | |
private $baz = 'baz'; | |
public function testAppliedToClassesAndMethods() | |
{ | |
$foo = @$this->fooBar(); | |
++$foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function apply(AbstractNode $node) | |
{ | |
foreach ($node->findChildrenOfType('UnaryExpression') as $unaryExpression) { | |
if ($unaryExpression->getImage() === '@') { | |
$this->addViolation($node, array($unaryExpression->getBeginLine())); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PHPMD\Rule\CleanCode; | |
use PHPMD\AbstractTest; | |
class ErrorControlOperatorTest extends AbstractTest | |
{ | |
public function testDoesNotApplyToOtherUnaryOperatorsInFunction() | |
{ | |
$rule = new ErrorControlOperator(); | |
$rule->setReport($this->getReportMock(1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function testDoesNotApplyToOtherUnaryOperatorsInFunction() | |
{ | |
@$foo = is_dir(__DIR__); | |
$bar = !$foo; | |
++$bar; | |
$baz = ++$bar; | |
return !--$baz; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function apply(AbstractNode $node) | |
{ | |
foreach ($node->findChildrenOfType('UnaryExpression') as $unaryExpression) { | |
$this->addViolation($node, array($unaryExpression->getBeginLine())); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PHPMD\Rule\CleanCode; | |
use PHPMD\AbstractTest; | |
class ErrorControlOperatorTest extends AbstractTest | |
{ | |
// ... | |
public function testAppliesToErrorControlOperatorInFunction() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function testAppliesToErrorControlOperatorInFunction() | |
{ | |
$foo = @debug_backtrace(); | |
$bar = @is_dir(__FILE__); | |
@$average = 3 / 0; | |
return [$foo, $bar, $average]; | |
} |
NewerOlder