Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

?DateTime return type declaration in AccessTokenMetadata->getExpiresAt() method #3

Closed
frugan-dev opened this issue May 7, 2022 · 5 comments

Comments

@frugan-dev
Copy link

On some occasions expires_at = 0, and this causes an exception:

JanuSoftware\Facebook\Authentication\AccessTokenMetadata::getExpiresAt(): Return value must be of type ?Safe\DateTime, int returned

See here https://developers.facebook.com/community/threads/461192667975495/ .

@JulienRamel
Copy link

@frugan-it I faced the same issue and the fastest option I found was to create a patch to be applied by the Composer Patches module from Cameron Eagans: https://github.com/cweagans/composer-patches.

Here is the patch:

diff --git a/vendor/janu-software/facebook-php-sdk/src/Authentication/AccessTokenMetadata.php b/vendor/janu-software/facebook-php-sdk/src/Authentication/AccessTokenMetadata.php
index ab5ab57..ade3dae 100755
--- a/vendor/janu-software/facebook-php-sdk/src/Authentication/AccessTokenMetadata.php
+++ b/vendor/janu-software/facebook-php-sdk/src/Authentication/AccessTokenMetadata.php
@@ -182,7 +182,7 @@ class AccessTokenMetadata
 	/**
 	 * DateTime when this access token expires.
 	 */
-	public function getExpiresAt(): ?DateTime
+	public function getExpiresAt()
 	{
 		return $this->getField('expires_at');
 	}

@frugan-dev
Copy link
Author

Thy @JulienRamel, I had already applied the same patch (but using https://github.com/vaimo/composer-patches), but I still opened an issue hoping that the author will solve it as soon as possible..

@stanislav-janu
Copy link
Contributor

Hi, this patch is not strict. My workaround is zero cast as null, because null is non-expiring token like App Token and zero means same.

@stanislav-janu
Copy link
Contributor

Test please latest dev-master.

@frugan-dev
Copy link
Author

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants