Skip to content

Commit

Permalink
Add v7 with drop support for PHP < 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrimaud committed Dec 31, 2023
1 parent aa9f13c commit 4076393
Show file tree
Hide file tree
Showing 33 changed files with 424 additions and 410 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
php: [ '7.2', '7.3', '7.4', '8', '8.1', '8.2', '8.3']
php: ['8.2', '8.3']

steps:
- name: "Init repository"
Expand All @@ -26,9 +26,10 @@ jobs:
run: composer install

- name: "Tests"
run: php vendor/bin/phpunit tests --whitelist src --coverage-clover ./build/logs/clover.xml
run: composer tests

- name: "Coveralls"
run: php vendor/bin/php-coveralls -v
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "CS Fix"
run: composer cs-fix

- name: "Phpstan"
run: composer phpstan
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ cache/
.phpunit.result.cache

!assets/.gitkeep
assets/
assets/

.php-cs-fixer.cache
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
[![All Contributors](https://img.shields.io/badge/all_contributors-30-orange.svg)](#contributors)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

> **Warning**
> 2023-12-31 - Version 7.0.0 will drop support for PHP < 8.2
> **Warning**
> 2022-11-09 - Instagram changed his DOM AGAIN... Please update to this version 6.16.4
Expand Down Expand Up @@ -62,6 +65,10 @@ composer require pgrimaud/instagram-user-feed

# Changelog

**v7.0.0** - 2023-12-31:

- Drop support for PHP < 8.2

**v6.16.6** - 2023-12-31:

- Add support for Symfony 7
Expand Down
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,21 @@
}
},
"require": {
"php": ">=7.2.5",
"php": ">=8.2",
"ext-curl": "*",
"ext-json": "*",
"symfony/cache": "^3.4|^4.3|^5.0|^6.0|^7.0",
"guzzlehttp/guzzle": "^6.0|^7.0"
"symfony/cache": "^6.0|^7.0",
"guzzlehttp/guzzle": "^7.0"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^8.5|^9.5",
"symfony/var-dumper": "^5.0|^6.0|^7.0"
"phpunit/phpunit": "^9.5",
"symfony/var-dumper": "^6.0|^7.0",
"phpstan/phpstan": "^1.10",
"friendsofphp/php-cs-fixer": "^3.45"
},
"scripts": {
"test": "phpunit tests --whitelist src"
"tests": "vendor/bin/phpunit tests --whitelist src --coverage-clover ./build/logs/clover.xml",
"phpstan": "vendor/bin/phpstan analyze src examples tests --level max",
"cs-fix": "vendor/bin/php-cs-fixer fix src --rules=@PSR12"
}
}
4 changes: 2 additions & 2 deletions src/Instagram/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function login(string $username, string $password, ?ImapClient $imapClien
{
$login = new Login($this->client, $username, $password, $imapClient, $this->challengeDelay);

if ( !($this->cachePool instanceof CacheItemPoolInterface) ) {
if (!($this->cachePool instanceof CacheItemPoolInterface)) {
throw new InstagramAuthException('You must set cachePool / login with cookies, example: \n$cachePool = new \Symfony\Component\Cache\Adapter\FilesystemAdapter("Instagram", 0, __DIR__ . "/../cache"); \n$api = new \Instagram\Api($cachePool);');
}

Expand Down Expand Up @@ -775,7 +775,7 @@ public function getTimeline(string $maxId = null): TimelineFeed

return $hydrator->getTimelineFeed();
}

/**
* @param string $user
*
Expand Down
2 changes: 1 addition & 1 deletion src/Instagram/Auth/Checkpoint/ImapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function getLastInstagramEmailContent(int $try = 1): string
$resource = @imap_open('{' . $this->getServer() . '/' . $this->getConnectionType() . '/ssl}INBOX', $this->getLogin(), $this->getPassword());

if (!$resource) {
throw new InstagramAuthException('Unable to open IMAP stream.');
throw new InstagramAuthException('Unable to open IMAP stream.');
}

$numberMax = imap_num_msg($resource);
Expand Down
2 changes: 1 addition & 1 deletion src/Instagram/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function process(): CookieJar

if (property_exists($response, 'authenticated') && $response->authenticated == true) {
return $cookieJar;
} else if (property_exists($response, 'error_type') && $response->error_type === 'generic_request_error') {
} elseif (property_exists($response, 'error_type') && $response->error_type === 'generic_request_error') {
throw new InstagramAuthException('Generic error / Your IP may be block from Instagram. You should consider using a proxy.');
} else {
throw new InstagramAuthException('Wrong login / password');
Expand Down
2 changes: 1 addition & 1 deletion src/Instagram/Auth/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Session
{
const SESSION_KEY = 'instagram.session';
public const SESSION_KEY = 'instagram.session';

/**
* @var CookieJar
Expand Down
8 changes: 4 additions & 4 deletions src/Instagram/Hydrator/CarouselHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function carouselMediaHydrator(array $carouselItems): array
'width' => $carouselItem->original_width,
'height' => $carouselItem->original_height,
];

if (property_exists($carouselItem, 'image_versions2')) {
$carouselMedia['image'] = $carouselItem->image_versions2->candidates;
}
Expand All @@ -97,11 +97,11 @@ public function carouselMediaHydrator(array $carouselItems): array
if (property_exists($carouselItem, 'video_duration')) {
$carouselMedia['duration'] = $carouselItem->video_duration;
}

if (property_exists($carouselItem, 'accessibility_caption')) {
$carouselMedia['accessibilityCaption'] = $carouselItem->accessibility_caption;
}

if (property_exists($carouselItem, 'number_of_qualities')) {
$carouselMedia['quality'] = $carouselItem->number_of_qualities;
}
Expand All @@ -114,7 +114,7 @@ public function carouselMediaHydrator(array $carouselItems): array

/**
* @param int $media_type
*
*
* @return string
* @throws InstagramFetchException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Instagram/Hydrator/ImageHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function imageBaseHydrator(\StdClass $node): Image
$image->setDate(\DateTime::createFromFormat('U', (string) $node->taken_at));
$image->setLikes($node->like_count);
$image->setIsLiked($node->has_liked);

$image->setHeight($node->original_height);
$image->setWidth($node->original_width);

Expand Down

0 comments on commit 4076393

Please sign in to comment.