Skip to content

Commit

Permalink
Revert "Merge branch '5.0.0' into master"
Browse files Browse the repository at this point in the history
This reverts commit a09684b, reversing
changes made to 6853fac.
  • Loading branch information
irfan-dahir committed May 29, 2024
1 parent a09684b commit 81ce30c
Show file tree
Hide file tree
Showing 202 changed files with 533 additions and 558 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/archive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
archive:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v5.0.0
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code-quality-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
codeQuality:
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
name: PHP
steps:
- name: Checkout changes
Expand All @@ -15,7 +15,7 @@ jobs:
- name: Setup PHP and linter
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.0'
tools: parallel-lint, phpunit, php-cs-fixer
- name: Run code quality checks
run: ./.github/workflows/utilities/lint-pr ${{ github.base_ref }}
4 changes: 2 additions & 2 deletions .github/workflows/code-quality-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
codeQuality:
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
name: PHP
steps:
- name: Checkout changes
Expand All @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP and linter
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.0'
tools: parallel-lint, phpunit, php-cs-fixer
- name: Run code quality checks
run: ./.github/workflows/utilities/lint-push
2 changes: 1 addition & 1 deletion .github/workflows/comment-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
comment-run:
runs-on: ubuntu-22.04
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
strategy:
max-parallel: 4
matrix:
operatingSystem: [ubuntu-22.04, windows-latest]
phpVersion: ['8.2']
operatingSystem: [ubuntu-20.04, windows-latest]
phpVersion: ['8.0', '8.1']
fail-fast: false
runs-on: ${{ matrix.operatingSystem }}
name: ${{ matrix.operatingSystem }} / PHP ${{ matrix.phpVersion }}
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
/.php-cs-fixer.cache
composer.phar
.phpunit.result.cache
.phpdoc
.phive
/.phpdoc
4 changes: 1 addition & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'@PER-CS' => true,
'@PHP82Migration' => true,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($finder)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2024 Jikan API
Copyright (c) 2018 Jikan API

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
25 changes: 10 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"minimum-stability": "stable",
"authors": [
{
"name": "Nekomata",
"name": "Irfan",
"email": "neko@jikan.moe"
}
],
Expand All @@ -19,25 +19,24 @@
},
"autoload-dev": {
"psr-4": {
"JikanTest\\": [
"test/unit"
]
"JikanTest\\": [
"test/JikanTest"
]
}
},
"require": {
"php": "^8.2",
"php": "^8.0",
"ext-json": "*",
"symfony/browser-kit": "^6.4|^7.0",
"symfony/css-selector": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0"
"fabpot/goutte": "^4.0"
},
"require-dev": {
"brianium/paratest": "^7.3",
"brianium/paratest": "^6.4.1",
"doctrine/collections": "^1.5",
"friendsofphp/php-cs-fixer": "^3.8",
"jikan-me/jikan-fixtures": "dev-master",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpro/grumphp": "^2.4",
"jikan-me/jikan-fixtures": "dev-master",
"phpro/grumphp": "^1.7.0",
"phpunit/phpunit": "~9.0",
"squizlabs/php_codesniffer": "^3.3"
},
"scripts": {
Expand All @@ -47,10 +46,6 @@
"composer config repositories.fixtures path ../jikan-fixtures",
"composer update jikan-me/jikan-fixtures",
"composer config repositories.fixtures --unset"
],
"generate-docs": [
"git clone https://github.com/jikan-me/jikan-docs.git ../jikan-docs || git -C ../jikan-docs reset --hard origin/master",
"phpDocumentor run -d src -t ../jikan-docs/docs"
]
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ grumphp:
- 'die'
paratest:
always_execute: true
phplint: ~
phplint: ~
27 changes: 9 additions & 18 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
cacheDirectory=".phpunit.cache"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
colors="true"
failOnEmptyTestSuite="true"
>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="unit">
<directory phpVersion="8.2" phpVersionOperator=">=">test/unit</directory>
<testsuite name="Unit">
<directory>./test/JikanTest</directory>
</testsuite>
</testsuites>

<php>
<ini name="precision" value="14"/>
<ini name="serialize_precision" value="14"/>

<const name="PHPUNIT_TESTSUITE" value="true"/>
</php>
</phpunit>
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<phpunit colors="true">
<testsuites>
<testsuite name="Unit">
<directory>./test/unit</directory>
<directory>./test/JikanTest</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
</phpunit>
4 changes: 3 additions & 1 deletion src/Exception/BadResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
*
* @package Jikan\Exception
*/
class BadResponseException extends \Exception {}
class BadResponseException extends \Exception
{
}
14 changes: 7 additions & 7 deletions src/Http/HttpClientWrapper.php → src/Goutte/GoutteWrapper.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php

namespace Jikan\Http;
namespace Jikan\Goutte;

use Goutte\Client;
use Jikan\Exception\BadResponseException;
use Symfony\Component\BrowserKit\HttpBrowser;
use Symfony\Component\DomCrawler\Crawler;

/**
* Class HttpClientWrapper
* Class GoutteWrapper
*
* @package Jikan\Http
* @package Jikan\Goutte
*/
class HttpClientWrapper extends HttpBrowser
class GoutteWrapper extends Client
{
/**
* @inheritdoc
Expand All @@ -33,7 +33,7 @@ public function request(
array $server = [],
string $content = null,
bool $changeHistory = true
): Crawler {
) : Crawler {
$response = parent::request(
$method,
$uri,
Expand All @@ -47,7 +47,7 @@ public function request(
$internalResponse = $this->getInternalResponse();
if ($internalResponse->getStatusCode() >= 400) {
throw new BadResponseException(
$internalResponse->getStatusCode() . ' on ' . $response->getUri(),
$internalResponse->getStatusCode().' on '.$response->getUri(),
$internalResponse->getStatusCode()
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Helper/JString.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public static function cleanse(string $string): string
$string = preg_replace('~[[:cntrl:]]~', "", $string);

// strip any leftover tags
// $string = htmlspecialchars_decode(strip_tags($string));
// $string = htmlspecialchars_decode(strip_tags($string));
$string = strip_tags($string);

// trim Nbsp // causing serializer issues
// $string = self::UTF8NbspTrim($string);
// $string = self::UTF8NbspTrim($string);

// remove any newlines at the end
$string = str_replace('\\n', "\n", $string);
// $string = preg_replace('~([\n]+)~', '', $string);
// $string = preg_replace('~([\n]+)~', '', $string);

// trim
$string = trim($string);
Expand All @@ -52,14 +52,14 @@ public static function cleanse(string $string): string
*/
public static function UTF8NbspTrim(string $string): string
{
return trim($string, \chr(0xC2) . \chr(0xA0));
return trim($string, \chr(0xC2).\chr(0xA0));
}

/**
* @param string $string
* @return string
*/
public static function strToCanonical(string $string): string
public static function strToCanonical(string $string) : string
{
return str_replace(
[' ', '/'],
Expand Down
6 changes: 3 additions & 3 deletions src/Helper/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Media
* @param string|null $url
* @return string
*/
public static function youtubeIdFromUrl(?string $url): ?string
public static function youtubeIdFromUrl(?string $url) : ?string
{
/**
* https://stackoverflow.com/a/17030234
Expand All @@ -38,7 +38,7 @@ public static function youtubeIdFromUrl(?string $url): ?string
* @param string $id
* @return string
*/
public static function generateYoutubeUrlFromId(?string $id): ?string
public static function generateYoutubeUrlFromId(?string $id) : ?string
{
if ($id === null) {
return null;
Expand All @@ -51,7 +51,7 @@ public static function generateYoutubeUrlFromId(?string $id): ?string
* @param string $id
* @return YoutubeImageResource
*/
public static function generateYoutubeImageResource(?string $id): YoutubeImageResource
public static function generateYoutubeImageResource(?string $id) : YoutubeImageResource
{
return YoutubeImageResource::factory($id);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Helper/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function (Crawler $crawler) {
*/
public static function idFromUrl(string $url): int
{
return (int) preg_replace('#https://myanimelist.net(/\w+/)(\d+).*#', '$2', $url);
return (int)preg_replace('#https://myanimelist.net(/\w+/)(\d+).*#', '$2', $url);
}

/**
Expand All @@ -57,7 +57,7 @@ public static function idFromUrl(string $url): int
* @param string $url
* @return int
*/
public static function clubIdFromUrl(string $url): int
public static function clubIdFromUrl(string $url) : int
{
return (int) preg_replace('~.*\.php\?cid=([\d]+)$~', '$1', $url);
}
Expand All @@ -82,7 +82,7 @@ public static function suffixIdFromUrl(string $url): int
public static function parseForumDate(string $date): ?\DateTimeImmutable
{
if (!preg_match('/\d{4}/', $date)) {
$date .= ', ' . date('Y');
$date .= ', '.date('Y');
}

return self::parseDate($date);
Expand All @@ -96,7 +96,7 @@ public static function parseForumDate(string $date): ?\DateTimeImmutable
public static function parseDate(string $date): ?\DateTimeImmutable
{
if (preg_match('/^\d{4}$/', $date)) {
return \DateTimeImmutable::createFromFormat('!Y-m-d', $date . '-01-01', new \DateTimeZone('UTC'));
return \DateTimeImmutable::createFromFormat('!Y-m-d', $date.'-01-01', new \DateTimeZone('UTC'));
}

if (preg_match('/(\w{3}), (\d{4})/', $date, $matches)) {
Expand Down Expand Up @@ -185,7 +185,7 @@ public static function parseDateMDYReadable(string $date): ?\DateTimeImmutable
* @param string $dateTime
* @return \DateTimeImmutable|null
*/
public static function parseDateTimePST(string $dateTime): ?\DateTimeImmutable
public static function parseDateTimePST(string $dateTime) : ?\DateTimeImmutable
{
try {
$malTimeZone = new \DateTimeZone('America/Los_Angeles'); //
Expand Down Expand Up @@ -217,7 +217,7 @@ public static function textOrNull(Crawler $crawler): ?string
* @return string
* @throws \InvalidArgumentException
*/
public static function parseImageQuality(string $imageUrl): string
public static function parseImageQuality(string $imageUrl) : string
{
// adding `v` prefix returns a very small thumbnail, as opposed to adding `l`
$imageUrl = str_replace(['v.jpg', 't.jpg', 'l.jpg'], '.jpg', $imageUrl);
Expand All @@ -230,7 +230,7 @@ public static function parseImageQuality(string $imageUrl): string
* @return string
* @throws \InvalidArgumentException
*/
public static function parseImageThumbToHQ(string $imageUrl): string
public static function parseImageThumbToHQ(string $imageUrl) : string
{
return str_replace(['thumbs/', '_thumb'], '', $imageUrl);
}
Expand All @@ -250,6 +250,6 @@ public static function parseDurationToSeconds(string $duration): ?int
$minutes = $match[2] ?? 0;
$seconds = $match[3] ?? 0;

return ($hours * 60 * 60) + ($minutes * 60) + $seconds;
return ($hours*60*60) + ($minutes*60) + $seconds;
}
}
2 changes: 1 addition & 1 deletion src/Model/Anime/AnimeReviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function fromParser(Parser\Anime\AnimeReviewsParser $parser): self
/**
* @return static
*/
public static function mock(): self
public static function mock() : self
{
return new self();
}
Expand Down
Loading

0 comments on commit 81ce30c

Please sign in to comment.