diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 61b0c9f6..051ef9ad 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,9 +1,15 @@ inherit: true +build: + nodes: + analysis: + tests: + override: [php-scrutinizer-run] + checks: php: code_rating: true duplication: true filter: - paths: [code/*, tests/*] + paths: [src/*, tests/*] diff --git a/.travis.yml b/.travis.yml index 1ac2b9a3..1f43b596 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,6 @@ before_script: - if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:3.x-dev --no-update; fi - if [[ $DB == SQLITE ]]; then composer require silverstripe/sqlite3:3.x-dev --no-update; fi - composer require silverstripe/recipe-core:5.x-dev silverstripe/admin:2.x-dev silverstripe/versioned:2.x-dev --no-update - - if [[ $PHPCS_TEST ]]; then composer global require squizlabs/php_codesniffer:^3 --prefer-dist --no-interaction --no-progress --no-suggest -o; fi - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile script: diff --git a/composer.json b/composer.json index b6a2bbb4..c7b8bc81 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "silverstripe/vendor-plugin": "^1" }, "require-dev": { - "phpunit/phpunit": "^7" + "phpunit/phpunit": "^7", + "squizlabs/php_codesniffer": "^3" }, "extra": { "branch-alias": { @@ -38,13 +39,13 @@ }, "autoload": { "psr-4": { - "SilverStripe\\Reports\\": "code/", + "SilverStripe\\Reports\\": "src/", "SilverStripe\\Reports\\Tests\\": "tests/" } }, "scripts": { - "lint": "phpcs code/ tests/", - "lint-clean": "phpcbf code/ tests/" + "lint": "vendor/bin/phpcs src/ tests/", + "lint-clean": "vendor/bin/phpcbf src/ tests/" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 9276cd5a..50768205 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -2,21 +2,10 @@ CodeSniffer ruleset for SilverStripe coding conventions. - - + + - - - - - - - - - - - - + diff --git a/code/Report.php b/src/Report.php similarity index 97% rename from code/Report.php rename to src/Report.php index dad52df2..53e5b3f0 100644 --- a/code/Report.php +++ b/src/Report.php @@ -59,7 +59,8 @@ use SilverStripe\View\ViewableData; * Right now, all subclasses of SS_Report will be shown in the ReportAdmin. In SS3 there is only * one place where reports can go, so this class is greatly simplifed from its version in SS2. * - * @method SS_List|DataList sourceRecords($params = [], $sort = null, $limit = null) List of records to show for this report + * @method SS_List|DataList sourceRecords($params = [], $sort = null, $limit = null) + * List of records to show for this report */ class Report extends ViewableData { @@ -149,7 +150,11 @@ class Report extends ViewableData if ($this->hasMethod('sourceRecords')) { return $this->sourceRecords($params, null, null)->dataQuery(); } else { - user_error("Please override sourceQuery()/sourceRecords() and columns() or, if necessary, override getReportField()", E_USER_ERROR); + user_error( + "Please override sourceQuery()/sourceRecords() and columns() or, if necessary, " + . "override getReportField()", + E_USER_ERROR + ); } } @@ -313,7 +318,10 @@ class Report extends ViewableData } // Add a search button - $formAction = FormAction::create('updatereport', _t('SilverStripe\\Forms\\GridField\\GridField.Filter', 'Filter')); + $formAction = FormAction::create( + 'updatereport', + _t('SilverStripe\\Forms\\GridField\\GridField.Filter', 'Filter') + ); $formAction->addExtraClass('btn-primary mb-4'); $fields->push($formAction); diff --git a/code/ReportAdmin.php b/src/ReportAdmin.php similarity index 93% rename from code/ReportAdmin.php rename to src/ReportAdmin.php index 8173681e..09149537 100644 --- a/code/ReportAdmin.php +++ b/src/ReportAdmin.php @@ -174,10 +174,13 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider if ($this->reportObject) { //build breadcrumb trail to the current report - $items->push(new ArrayData(array( + $items->push(ArrayData::create([ 'Title' => $this->reportObject->title(), - 'Link' => Controller::join_links($this->Link(), '?' . http_build_query(array('q' => $this->request->requestVar('q')))) - ))); + 'Link' => Controller::join_links( + $this->Link(), + '?' . http_build_query(['q' => $this->request->requestVar('q')]) + ) + ])); } return $items; @@ -226,7 +229,8 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider ); $gridField = new GridField('Reports', false, $this->Reports(), $gridFieldConfig); /** @var GridFieldDataColumns $columns */ - $columns = $gridField->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns'); + $columns = $gridField->getConfig() + ->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns'); $columns->setDisplayFields(array( 'title' => _t('SilverStripe\\Reports\\ReportAdmin.ReportTitle', 'Title'), )); @@ -240,7 +244,9 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider $actions = new FieldList(); $form = new Form($this, "EditForm", $fields, $actions); - $form->addExtraClass('panel panel--padded panel--scrollable cms-edit-form cms-panel-padded' . $this->BaseCSSClasses()); + $form->addExtraClass( + 'panel panel--padded panel--scrollable cms-edit-form cms-panel-padded' . $this->BaseCSSClasses() + ); $form->loadDataFrom($this->request->getVars()); $this->extend('updateEditForm', $form); diff --git a/code/ReportWrapper.php b/src/ReportWrapper.php similarity index 95% rename from code/ReportWrapper.php rename to src/ReportWrapper.php index 7ba44e76..3a1fe76c 100644 --- a/code/ReportWrapper.php +++ b/src/ReportWrapper.php @@ -2,6 +2,8 @@ namespace SilverStripe\Reports; +use SilverStripe\Core\Injector\Injector; + /** * SS_ReportWrapper is a base class for creating report wappers. * @@ -21,7 +23,7 @@ abstract class ReportWrapper extends Report public function __construct($baseReport) { - $this->baseReport = is_string($baseReport) ? new $baseReport : $baseReport; + $this->baseReport = is_string($baseReport) ? Injector::inst()->create($baseReport) : $baseReport; $this->dataClass = $this->baseReport->dataClass(); parent::__construct(); } diff --git a/code/SideReportView.php b/src/SideReportView.php similarity index 98% rename from code/SideReportView.php rename to src/SideReportView.php index 171ef960..4e15fb55 100644 --- a/code/SideReportView.php +++ b/src/SideReportView.php @@ -11,8 +11,8 @@ use SilverStripe\View\ViewableData; */ class SideReportView extends ViewableData { - - protected $controller, $report; + protected $controller; + protected $report; protected $parameters; public function __construct($controller, $report) diff --git a/code/SideReportWrapper.php b/src/SideReportWrapper.php similarity index 100% rename from code/SideReportWrapper.php rename to src/SideReportWrapper.php