Plugin Directory

Changeset 2579590


Ignore:
Timestamp:
08/07/2021 02:35:29 AM (5 years ago)
Author:
wellflat
Message:

required php7.4 or later, added typed properties

Location:
wp-github-card/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • wp-github-card/trunk/readme.txt

    r2327975 r2579590  
    44Tags: github, shortcode
    55Requires at least: 4.9.6
    6 Tested up to: 5.4.2
    7 Requires PHP: 7.3+
    8 Stable tag: 2.0.0
     6Tested up to: 5.8
     7Requires PHP: 7.4+
     8Stable tag: 2.1.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3737== Changelog ==
    3838
     39= 2.1.0 =
     40* required php7.4 or later, added typed properties
    3941= 2.0.0 =
    4042* required php7.3 or later, end of support php5
  • wp-github-card/trunk/src/Renderer.php

    r1889368 r2579590  
    66 * Class WP\GitHub\Renderer
    77 * html renderer
    8  * @package WP_GitHub_Card 
     8 * @package WP_GitHub_Card
    99 * @since 1.0.0
    1010 * @link https://twig.symfony.com/
     
    1313
    1414    /** @var \Twig_Environment */
    15     private $twig;
     15    private \Twig_Environment $twig;
    1616    /** @var string */
    17     private $base_dir;
     17    private string $base_dir;
    1818
    1919    public function __construct() {
     
    3232     * @param string $template_file
    3333     * @param array $params
     34     * @return string
    3435     */
    35     public function render( $template_file, array $params ) {
     36    public function render( string $template_file, array $params ): string {
    3637        $template = $this->twig->loadTemplate( $template_file );
    3738        return $template->render( $params );
     
    4142     * creates template cache directory
    4243     */
    43     public function prepare_template_cache() {
    44         $cache_dir = $this->base_dir . '/cache';
     44    public function prepare_template_cache(): void {
     45        $cache_dir = $this->base_dir . '/cache';
    4546        $this->twig->setCache( $cache_dir );
    4647    }
     
    5051     * @global object $wp_filesystem
    5152     */
    52     public function delete_template_cache() {
     53    public function delete_template_cache(): void {
    5354        $this->twig->setCache( false );
    5455        if( WP_Filesystem() ) {
  • wp-github-card/trunk/src/Repos.php

    r1889368 r2579590  
    1111final class Repos {
    1212    /** @var array */
    13     private $repos = [];
     13    private array $repos = [];
    1414    /** @var array */
    15     public $languages = [];
     15    public array $languages = [];
    1616    /** @var int */
    17     public $stargazers = 0;
     17    public int $stargazers = 0;
    1818    /** @var string */
    19     public $recently_active_repo = '';
     19    public string $recently_active_repo = '';
    2020
    2121    public function __construct( array $data = null ) {
     
    4545     * @return int
    4646     */
    47     private function count_stargazers() {
     47    private function count_stargazers(): int {
    4848        return array_reduce( $this->repos, function($c, $i) {
    4949            return $c + $i['stargazers'];
  • wp-github-card/trunk/src/Service.php

    r1889368 r2579590  
    1010 */
    1111final class Service {
    12     const API_BASE_PATH = 'https://api.github.com';
    13     const CACHE_PREFIX = 'wp-github-card-';
    14     const CACHE_EXPIRED = 4*HOUR_IN_SECONDS;
     12    private const API_BASE_PATH = 'https://api.github.com';
     13    private const CACHE_PREFIX = 'wp-github-card-';
     14    private const CACHE_EXPIRED = 4*HOUR_IN_SECONDS;
    1515
    1616    /** @var string */
    17     private $user = null;
     17    private ?string $user = null;
    1818    /** @var string */
    19     private $token = null;
     19    private ?string $token = null;
    2020
    21     public function __construct( $user = null, $token = null ) {
     21    public function __construct( ?string $user = null, ?string $token = null ) {
    2222        $this->user = $user;
    2323        $this->token = $token;
     
    3737     * @link https://developer.github.com/v3/users/#get-a-single-user
    3838     */
    39     public function get_user() {
     39    public function get_user(): User {
    4040        $url = self::API_BASE_PATH . '/users/' . $this->user;
    4141        $cache_key = self::CACHE_PREFIX . 'user-' . $this->user;
     
    5757     * @link https://developer.github.com/v3/repos/#list-user-repositories
    5858     */
    59     public function get_repos() {
     59    public function get_repos(): Repos {
    6060        $url = self::API_BASE_PATH . '/users/' . $this->user . '/repos?sort=pushed';
    6161        $cache_key = self::CACHE_PREFIX . 'repos-' . $this->user;
     
    7676     * @global object $wpdb
    7777     */
    78     public function delete_transients() {
     78    public function delete_transients(): void {
    7979        global $wpdb;
    8080        $sql = "DELETE FROM `{$wpdb->prefix}options` WHERE `option_name` LIKE '_transient_wp-github-card-%'";
     
    8989     * @link https://developer.github.com/v3/
    9090     */
    91     private function request( $url ) {
     91    private function request( string $url ) {
    9292        $headers = [ 'Accept' => 'application/vnd.github.v3+json' ];
    9393        if ( ! is_null( $this->token ) ) {
  • wp-github-card/trunk/src/Shortcode.php

    r1889368 r2579590  
    1212
    1313    /** @var WP\GitHub\Renderer */
    14     private $renderer;
     14    private Renderer $renderer;
    1515    /** @var WP\GitHub\Service */
    16     private $service;
     16    private Service $service;
    1717
    1818    public function __construct() {
     
    2828     * @return string
    2929     */
    30     public function handler( array $atts ) {
     30    public function handler( array $atts ): string {
    3131        $defaults = [
    3232            'user' => null,
     
    4646     * enqueues style sheet
    4747     */
    48     public function add_style() {
     48    public function add_style(): void {
    4949        wp_register_style(
    5050            'github-card-style',
     
    5757     * prepares template cache
    5858     */
    59     public function prepare_cache() {
     59    public function prepare_cache(): void {
    6060        $this->renderer->prepare_template_cache();
    6161    }
     
    6464     * deletes transients and template cache
    6565     */
    66     public function delete_cache() {
     66    public function delete_cache(): void {
    6767        $this->service->delete_transients();
    6868        $this->renderer->delete_template_cache();
  • wp-github-card/trunk/src/User.php

    r1889368 r2579590  
    1111final class User {
    1212    /** @var string */
    13     public $login = '';
     13    public string $login = '';
    1414    /** @var string */
    15     public $avatar = '';
     15    public string $avatar = '';
    1616    /** @var string */
    17     public $name = '';
     17    public string $name = '';
    1818    /** @var int */
    19     public $public_repos = 0;
     19    public int $public_repos = 0;
    2020    /** @var int */
    21     public $public_gists = 0;
     21    public int $public_gists = 0;
    2222    /** @var int */
    23     public $followers = 0;
     23    public int $followers = 0;
    2424
    2525    public function __construct( \stdClass $data = null ) {
     
    4343     * @return bool
    4444     */
    45     private function check_properties( \stdClass $data ) {
     45    private function check_properties( \stdClass $data ): bool {
    4646        $properties = [
    4747            'login', 'avatar_url', 'name', 'public_repos', 'public_gists', 'followers'
Note: See TracChangeset for help on using the changeset viewer.