Skip to content

Commit

Permalink
requires at least PHP 8.1, CakePHP 5.0 and PHPUnit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
mirko-pagliai committed Jan 6, 2024
1 parent 835bf05 commit 46f86c1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 1.x branch
## 1.2 branch
### 1.2.0
* requires at least PHP 8.1;
* requires at least PHP 8.1, CakePHP 5.0 and PHPUnit 10;
* provides its own `phpUri` library;
* added tests for PHP 8.3.

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
],
"require": {
"php": ">=8.1",
"cakephp/cakephp": "^4.3",
"mirko-pagliai/php-tools": "^1.8.2",
"cakephp/cakephp": "^5.0",
"mirko-pagliai/php-tools": "~1.9.2",
"symfony/dom-crawler": "^6.0|^7.0"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "^4.0",
"cakephp/cakephp-codesniffer": "^5.0",
"nikic/php-parser": "^v4.18.0",
"phpunit/phpunit": "^9.1|^9.5",
"phpunit/phpunit": "^10.1.0 <=10.5.3",
"phpstan/phpstan": "^1.10.38",
"vimeo/psalm": "^5.15.0"
},
Expand Down
1 change: 1 addition & 0 deletions src/Command/LinkScannerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use LinkScanner\Event\LinkScannerCommandEventListener;
use LinkScanner\Utility\LinkScanner;
use PHPUnit\Framework\Exception as PHPUnitException;
use function Cake\I18n\__d;

/**
* A link scanner command
Expand Down
1 change: 1 addition & 0 deletions src/Event/LinkScannerCommandEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Cake\Http\Client\Response;
use Cake\I18n\FrozenTime;
use LinkScanner\ResultScan;
use function Cake\I18n\__d;

/**
* Event listener for the `LinkScannerCommand` class.
Expand Down
12 changes: 8 additions & 4 deletions src/Utility/LinkScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
use Cake\Event\EventList;
use Cake\Http\Client;
use Cake\Http\Client\Response;
use Exception;
use Laminas\Diactoros\Stream;
use LinkScanner\ResultScan;
use LinkScanner\ScanEntity;
use LogicException;
use PHPUnit\Framework\Exception as PHPUnitException;
use Serializable;
use Throwable;
use Tools\Filesystem;
use function Cake\I18n\__d;

/**
* A link scanner
Expand Down Expand Up @@ -216,7 +217,7 @@ protected function _getResponse(string $url): Response
}
} catch (PHPUnitException $e) {
throw $e;
} catch (Exception $e) {
} catch (Throwable) {
$Response = (new Response())->withStatus(404);
}

Expand Down Expand Up @@ -394,8 +395,11 @@ public function import(string $filename)
$filename = $this->_getAbsolutePath($filename);

try {
$instance = unserialize(file_get_contents($filename) ?: '');
} catch (Exception $e) {
if (!is_readable($filename)) {
throw new LogicException(__d('link-scanner', 'File or directory `'. $filename . '` is not readable'));
}
$instance = unserialize(file_get_contents($filename));
} catch (Throwable $e) {
$message = preg_replace('/file_get_contents\([^)]+\):\s+/', '', $e->getMessage()) ?: '';
throw new LogicException(
__d('link-scanner', 'Failed to import results from file `{0}` with message `{1}`', $filename, lcfirst($message))
Expand Down
5 changes: 3 additions & 2 deletions tests/TestCase/Utility/LinkScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ public function testImport(): void
$this->assertEquals($expectedProperties, $resultProperties);

//With a no existing file
$this->expectExceptionMessage('Failed to import results from file `' . TMP . 'noExistingDir' . DS . 'result` with message `failed to open stream: No such file or directory`');
$this->LinkScanner->import(TMP . 'noExistingDir' . DS . 'result');
$filename = TMP . 'noExistingDir' . DS . 'result';
$this->expectExceptionMessage('Failed to import results from file `' . $filename . '` with message `file or directory `'. $filename . '` is not readable`');
$this->LinkScanner->import($filename);
}

/**
Expand Down
7 changes: 0 additions & 7 deletions tests/test_app/TestApp/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,4 @@

class AppController extends Controller
{
public function initialize(): void
{
parent::initialize();

$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
}
}

0 comments on commit 46f86c1

Please sign in to comment.