Avoid unused parameters such as '$crawlVariations'. Open
public function crawlArticle(string $responseBody, bool $crawlVariations): Article
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractDescription(DomCrawler $articleCrawler): string
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$descriptionHtml = $articleCrawler->filter('#j-product-description');
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractPrice(DomCrawler $articleCrawler): float
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractPriceDiscount(DomCrawler $articleCrawler): float
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$nameHtml = $articleCrawler->filter('h1.product-name');
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$sellerHtml = $articleCrawler->filter('#j-store-info-wrap .store-lnk');
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$priceCurrencyHtml = $articleCrawler->filter('.p-price-content .p-symbol');
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractRatingAmount(DomCrawler $articleCrawler): int
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractSeller(DomCrawler $articleCrawler): string
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$priceHtml = $articleCrawler->filter('#j-sku-price');
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractSellerSince(DomCrawler $articleCrawler): int
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractStock(DomCrawler $articleCrawler): int
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$propertyElements = $articleCrawler->filter('.product-property-list .property-item');
- Exclude checks
Argument 1 (rating)
is float
but \Sesame\Model\Article::setRating()
takes int
defined at /code/src/Sesame/Model/Article.php:231
Open
$article->setRating($this->extractRating($articleCrawler));
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractRating(DomCrawler $articleCrawler): float
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$priceDiscountHtml = $articleCrawler->filter('#j-sku-discount-price');
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$sellerSinceHtml = $articleCrawler->filter('.store-open-time span');
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$propertyTitle = substr($propertyCrawler->filter('.propery-title')->text(), 0, -1);
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractOrders(DomCrawler $articleCrawler): int
- Exclude checks
Call to method __construct
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$articleCrawler = new DomCrawler($responseBody);
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$sellerFeedbackHtml = $articleCrawler->filter('.seller-score-feedback span a');
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$ratingHtml = $articleCrawler->filter('#j-customer-reviews-trigger .percent-num');
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractSellerFeedback(DomCrawler $articleCrawler): float
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$sellerLocationHtml = $articleCrawler->filter('#j-store-info-wrap .store-address');
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractPriceCurrency(DomCrawler $articleCrawler): string
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$stockAmountHtml = $articleCrawler->filter('#j-sell-stock-num');
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractProperties(DomCrawler $articleCrawler): array
- Exclude checks
Parameter $articleCrawler
has undeclared type \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
protected function extractSellerLocation(DomCrawler $articleCrawler): string
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$ordersHtml = $articleCrawler->filter('#j-order-num');
- Exclude checks
Call to method __construct
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$propertyCrawler = new DomCrawler($propertyElement);
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$propertyValue = $propertyCrawler->filter('.propery-des')->text();
- Exclude checks
Call to method filter
from undeclared class \Symfony\Component\DomCrawler\Crawler
(Did you mean class \Sesame\Crawler\Crawler) Open
$ratingAmountHtml = $articleCrawler->filter('#j-customer-reviews-trigger .rantings-num');
- Exclude checks
The method extractProperties uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$properties[$propertyTitle] = $propertyValue;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Remove this commented out code. Open
//$article->setSellerFeedback($this->extractSellerFeedback($articleCrawler));
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Avoid excessively long variable names like $ratingAmountStringParts. Keep variable name length under 20. Open
$ratingAmountStringParts = explode(' ', $ratingAmountString);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $stockAmountStringParts. Keep variable name length under 20. Open
$stockAmountStringParts = explode(' ', $stockAmountString);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $sellerSinceStringParts. Keep variable name length under 20. Open
$sellerSinceStringParts = explode(' ', $sellerSinceString);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}