Skip to content

Commit

Permalink
NEW: PHP 8 upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfendeksilverstripe committed Jun 23, 2022
1 parent ef24800 commit 2bae9f6
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 209 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
ci:
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

19 changes: 13 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
"issues": "http://github.com/ichaber/silverstripe-swiftype/issues"
},
"require": {
"php": "^7.1",
"silverstripe/vendor-plugin": "^1",
"php": "^7.4 || ^8.0",
"silverstripe/vendor-plugin": "^1.6",
"silverstripe/framework": "^4",
"silverstripe/cms": "^4",
"guzzlehttp/guzzle": "^6.3.0",
"guzzlehttp/psr7": "^1.4.2"
"guzzlehttp/guzzle": "^7",
"guzzlehttp/psr7": "^2"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
"silverstripe/recipe-testing": "^2"
},
"autoload": {
"psr-4": {
Expand All @@ -43,5 +43,12 @@
"installer-name": "silverstripe-swiftype"
},
"prefer-stable": true,
"minimum-stability": "dev"
"minimum-stability": "dev",
"config": {
"allow-plugins": {
"composer/installers": true,
"silverstripe/recipe-plugin": true,
"silverstripe/vendor-plugin": true
}
}
}
26 changes: 26 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>

<file>src</file>
<file>tests</file>

<rule ref="Generic.Arrays.DisallowLongArraySyntax" />

<!-- base rules are PSR-2 -->
<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
<exclude name="PSR2.Classes.PropertyDeclaration" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration" /> <!-- causes php notice while linting -->
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenerdefault" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment" />
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
<exclude name="Squiz.Scope.MethodScope" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="PEAR.Functions.ValidDefaultValue.NotAtEnd" />
</rule>
</ruleset>
26 changes: 15 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
<testsuite name="Default">
<directory>tests/php/</directory>
</testsuite>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/silverstripe/cms/tests/bootstrap.php"
colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
<exclude>
<directory suffix=".php">tests/</directory>
</exclude>
</whitelist>
</filter>
</include>
<exclude>
<directory suffix=".php">tests/</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Default">
<directory>tests/</directory>
</testsuite>
</testsuites>
</phpunit>
3 changes: 0 additions & 3 deletions src/Extensions/SwiftypeMetaTagContentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
use SilverStripe\ORM\FieldType\DBField;

/**
* Class SwiftypeMetaTagContentExtension
*
* @package Ichaber\SSSwiftype\Extensions
* @property DataObject|$this $owner
*/
class SwiftypeMetaTagContentExtension extends DataExtension
Expand Down
5 changes: 0 additions & 5 deletions src/Extensions/SwiftypeSiteConfigFieldsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
/**
* Some default things to set up
*
* Class SwiftypeSiteConfigFieldsExtension
*
* @package Ichaber\SSSwiftype\Extensions
* @property bool $SwiftypeEnabled
* @property string $SwiftypeAccessKey
* @property string $SwiftypeAPIKey
Expand All @@ -39,8 +36,6 @@ class SwiftypeSiteConfigFieldsExtension extends DataExtension
* Settings and CMS form fields for CMS the admin/settings area
*
* @codeCoverageIgnore
* @param FieldList $fields
* @return void
*/
public function updateCMSFields(FieldList $fields): void
{
Expand Down
28 changes: 5 additions & 23 deletions src/Extensions/SwiftypeSiteTreeCrawlerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
use SilverStripe\Versioned\Versioned;

/**
* Class SwiftypeSiteTreeCrawlerExtension
*
* @package Ichaber\SSSwiftype\Extensions
* @property SiteTree|$this $owner
*/
class SwiftypeSiteTreeCrawlerExtension extends SiteTreeExtension
Expand All @@ -26,16 +23,11 @@ class SwiftypeSiteTreeCrawlerExtension extends SiteTreeExtension
*/
private $urlsToCrawl = [];

/**
* @param array $urls
*/
public function setUrlsToCrawl(array $urls) {
public function setUrlsToCrawl(array $urls)
{
$this->urlsToCrawl = $urls;
}

/**
* @return array
*/
public function getUrlsToCrawl(): array
{
return $this->urlsToCrawl;
Expand All @@ -56,7 +48,6 @@ public function onBeforeWrite(): void
* an unpublish)
*
* @param SiteTree|mixed $original
* @return void
*/
public function onAfterPublish(&$original): void
{
Expand Down Expand Up @@ -162,7 +153,7 @@ public function collateUrls(): void
$urls = $this->getUrlsToCrawl();

// Set us to a LIVE stage/reading_mode
$this->withVersionContext(function() use (&$urls) {
$this->withVersionContext(function () use (&$urls) {
/** @var SiteTree $owner */
$owner = $this->getOwner();
$key = $this->getOwnerKey();
Expand Down Expand Up @@ -225,15 +216,11 @@ protected function processCollatedUrls(): void
}

// Force the reindexing of each URL we collated
foreach ($urls[$key] as $url) {
foreach ($urls[$key] as $url) {
$this->forceSwiftypeIndex($url);
}
}

/**
* @param string $updateUrl
* @return bool
*/
protected function forceSwiftypeIndex(string $updateUrl): bool
{
// We don't reindex dev environments
Expand All @@ -246,9 +233,6 @@ protected function forceSwiftypeIndex(string $updateUrl): bool
return $crawler->send($updateUrl);
}

/**
* @return string
*/
protected function getOwnerKey(): ?string
{
$owner = $this->owner;
Expand All @@ -269,12 +253,10 @@ protected function getOwnerKey(): ?string
* The main function is to suppress the ?stage=Live querystring. LeftAndMain will set the default
* reading mode to 'DRAFT' when initialising so to counter this we need to re-set the default
* reading mode back to LIVE
*
* @param callable $callback
*/
private function withVersionContext(callable $callback): void
{
Versioned::withVersionedMode(static function() use ($callback) {
Versioned::withVersionedMode(static function () use ($callback) {
// Grab our current stage and reading mode
$originalDefaultReadingMode = Versioned::get_default_reading_mode();
$originalReadingMode = Versioned::get_reading_mode();
Expand Down
14 changes: 0 additions & 14 deletions src/MetaTags/SwiftypeMetaTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
use SilverStripe\ORM\FieldType\DBDatetime;

/**
* Class SwiftypeMetaTag
*
* @package Ichaber\SSSwiftype\MetaTags
* @see _config/model.yml for DateFormat definition
* @see _config/model.yml for field_name override example
*/
Expand All @@ -33,10 +30,6 @@ abstract class SwiftypeMetaTag implements SwiftypeMetaTagInterface
*/
protected $fieldType;

/**
* @param DataObject $dataObject
* @return null|string
*/
public function getMetaTagString(DataObject $dataObject): ?string
{
// Can't do anything if no tag name was specified
Expand All @@ -61,7 +54,6 @@ public function getMetaTagString(DataObject $dataObject): ?string
}

/**
* @param DataObject $dataObject
* @return string|int|null
*/
protected function getFieldValue(DataObject $dataObject)
Expand Down Expand Up @@ -111,12 +103,6 @@ protected function getFieldValue(DataObject $dataObject)
return null;
}

/**
* @param string $name
* @param string $fieldType
* @param string $value
* @return string
*/
protected function generateMetaTagsString(string $name, string $fieldType, string $value): string
{
return sprintf(
Expand Down
5 changes: 0 additions & 5 deletions src/MetaTags/SwiftypeMetaTagDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

namespace Ichaber\SSSwiftype\MetaTags;

/**
* Class SwiftypeMetaTagDescription
*
* @package Ichaber\SSSwiftype\MetaTags
*/
class SwiftypeMetaTagDescription extends SwiftypeMetaTag
{
/**
Expand Down
8 changes: 0 additions & 8 deletions src/MetaTags/SwiftypeMetaTagInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@
* and I would just get php errors any time I tried to instantiate a MetaTag class.
*
* Moving them into the same namespace was the only way I was able to move forward without going down a rabbit hole.
*
* Interface SwiftypeMetaTagInterface
*
* @package Ichaber\SSSwiftype\Interfaces
*/
interface SwiftypeMetaTagInterface
{
/**
* @param DataObject $dataObject
* @return string|null
*/
public function getMetaTagString(DataObject $dataObject): ?string;
}
5 changes: 0 additions & 5 deletions src/MetaTags/SwiftypeMetaTagPublishedAt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

namespace Ichaber\SSSwiftype\MetaTags;

/**
* Class SwiftypeMetaTagPublishedAt
*
* @package Ichaber\SSSwiftype\MetaTags
*/
class SwiftypeMetaTagPublishedAt extends SwiftypeMetaTag
{
/**
Expand Down
10 changes: 0 additions & 10 deletions src/MetaTags/SwiftypeMetaTagRobots.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,8 @@
use SilverStripe\Core\Config\Config;
use SilverStripe\ORM\DataObject;

/**
* Class SwiftypeMetaTagRobots
*
* @package Ichaber\SSSwiftype\MetaTags
*/
class SwiftypeMetaTagRobots extends SwiftypeMetaTag
{
/**
* @param DataObject $dataObject
* @return string|null
*/
public function getMetaTagString(DataObject $dataObject): ?string
{
$value = $this->getFieldValue($dataObject);
Expand All @@ -29,7 +20,6 @@ public function getMetaTagString(DataObject $dataObject): ?string
}

/**
* @param DataObject $dataObject
* @return int|string|null
*/
protected function getFieldValue(DataObject $dataObject)
Expand Down
5 changes: 0 additions & 5 deletions src/MetaTags/SwiftypeMetaTagTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

namespace Ichaber\SSSwiftype\MetaTags;

/**
* Class SwiftypeMetaTagTitle
*
* @package Ichaber\SSSwiftype\MetaTags
*/
class SwiftypeMetaTagTitle extends SwiftypeMetaTag
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/MetaTags/SwiftypeMetaTagURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

namespace Ichaber\SSSwiftype\MetaTags;

/**
* Class SwiftypeMetaTagURL
*
* @package Ichaber\SSSwiftype\MetaTags
*/
class SwiftypeMetaTagURL extends SwiftypeMetaTag
{
/**
Expand Down
Loading

0 comments on commit 2bae9f6

Please sign in to comment.