Plugin Directory

Changeset 1908445


Ignore:
Timestamp:
07/12/2018 08:02:43 PM (8 years ago)
Author:
bdolor
Message:

updating mpdf to 7.1.1

Location:
pressbooks-mpdf/trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • pressbooks-mpdf/trunk/autoloader.php

    r1839558 r1908445  
    33 * PSR-4 compliant autoload.
    44 *
    5  * @modified from https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
     5 * @modified from
     6 *     https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
    67 *
    78 * @param string $class The fully-qualified class name.
     
    1213    function ( $class ) {
    1314
    14             // project-specific namespace prefix
    15             $prefix = 'BCcampus';
     15        // project-specific namespace prefix
     16        $prefix = 'BCcampus';
    1617
    17             // base directory for the namespace prefix
    18             $base_dir = __DIR__ . '/inc';
     18        // base directory for the namespace prefix
     19        $base_dir = __DIR__ . '/inc';
    1920
    20             // does the class use the namespace prefix?
    21             $len = \strlen( $prefix );
     21        // does the class use the namespace prefix?
     22        $len = \strlen( $prefix );
    2223
    2324        if ( \strncmp( $prefix, $class, $len ) !== 0 ) {
     
    2627        }
    2728
    28             // get the relative class name
    29             $relative_class = \substr( $class, $len );
     29        // get the relative class name
     30        $relative_class = \substr( $class, $len );
     31        $last_ns_pos    = strripos( $relative_class, '\\' );
    3032
    31         if ( false !== ( $last_ns_pos = strripos( $relative_class, '\\' ) ) ) {
     33        if ( false !== ( $last_ns_pos ) ) {
    3234            $namespace = substr( $relative_class, 0, $last_ns_pos );
    3335            $class     = substr( $relative_class, $last_ns_pos + 1 );
    3436            $file      = str_replace( '\\', DIRECTORY_SEPARATOR, $namespace ) . DIRECTORY_SEPARATOR;
    3537        }
    36             $file .= 'class-' . str_replace( '_', '-', $class ) . '.php';
     38        $file .= 'class-' . str_replace( '_', '-', $class ) . '.php';
    3739
    38             $path = $base_dir . strtolower( $file );
     40        $path = $base_dir . strtolower( $file );
    3941
    40             // if the file exists, require it
     42        // if the file exists, require it
    4143        if ( \file_exists( $path ) ) {
    4244            require $path;
  • pressbooks-mpdf/trunk/composer.json

    r1897333 r1908445  
    33  "description": "Open source PDF generation for Pressbooks via the mPDF library.",
    44  "type": "wordpress-plugin",
    5   "version": "3.1.3",
     5  "version": "3.2.0",
    66  "homepage": "https://github.com/bccampus/pressbooks-mpdf",
    77  "license": "GPL-2.0+",
  • pressbooks-mpdf/trunk/composer.lock

    r1897333 r1908445  
    55        "This file is @generated automatically"
    66    ],
    7     "content-hash": "dcfa5cf459a8119290b56a667cdd761b",
     7    "content-hash": "0a754beef6ea55d85e5f003924532d27",
    88    "packages": [
    99        {
    1010            "name": "mpdf/mpdf",
    11             "version": "v7.1.0",
     11            "version": "v7.1.1",
    1212            "source": {
    1313                "type": "git",
    1414                "url": "https://github.com/mpdf/mpdf.git",
    15                 "reference": "8e3d0d7bf74f71d04904215fb487d01e924c469a"
    16             },
    17             "dist": {
    18                 "type": "zip",
    19                 "url": "https://api.github.com/repos/mpdf/mpdf/zipball/8e3d0d7bf74f71d04904215fb487d01e924c469a",
    20                 "reference": "8e3d0d7bf74f71d04904215fb487d01e924c469a",
     15                "reference": "800a7f9d93474988cc2ffb8c155497ca5910fb09"
     16            },
     17            "dist": {
     18                "type": "zip",
     19                "url": "https://api.github.com/repos/mpdf/mpdf/zipball/800a7f9d93474988cc2ffb8c155497ca5910fb09",
     20                "reference": "800a7f9d93474988cc2ffb8c155497ca5910fb09",
    2121                "shasum": ""
    2222            },
     
    7373                "utf-8"
    7474            ],
    75             "time": "2018-05-18T05:41:37+00:00"
     75            "time": "2018-07-02T14:26:48+00:00"
    7676        },
    7777        {
     
    122122        {
    123123            "name": "paragonie/random_compat",
    124             "version": "v2.0.15",
     124            "version": "v2.0.17",
    125125            "source": {
    126126                "type": "git",
    127127                "url": "https://github.com/paragonie/random_compat.git",
    128                 "reference": "10bcb46e8f3d365170f6de9d05245aa066b81f09"
    129             },
    130             "dist": {
    131                 "type": "zip",
    132                 "url": "https://api.github.com/repos/paragonie/random_compat/zipball/10bcb46e8f3d365170f6de9d05245aa066b81f09",
    133                 "reference": "10bcb46e8f3d365170f6de9d05245aa066b81f09",
     128                "reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d"
     129            },
     130            "dist": {
     131                "type": "zip",
     132                "url": "https://api.github.com/repos/paragonie/random_compat/zipball/29af24f25bab834fcbb38ad2a69fa93b867e070d",
     133                "reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d",
    134134                "shasum": ""
    135135            },
     
    167167                "random"
    168168            ],
    169             "time": "2018-06-08T15:26:40+00:00"
     169            "time": "2018-07-04T16:31:37+00:00"
    170170        },
    171171        {
     
    16231623        {
    16241624            "name": "symfony/yaml",
    1625             "version": "v3.4.11",
     1625            "version": "v3.4.12",
    16261626            "source": {
    16271627                "type": "git",
  • pressbooks-mpdf/trunk/inc/modules/export/mpdf/class-pdf.php

    r1897333 r1908445  
    115115        // lives and dies with the instantiation of the object
    116116        if ( $memory_available < $this->memoryNeeded ) {
    117             ini_set( 'memory_limit', $this->memoryNeeded . 'M' );
     117            ini_set( 'memory_limit', $this->memoryNeeded . 'M' ); // @codingStandardsIgnoreLine
    118118        }
    119119
     
    131131        if ( ! empty( $_REQUEST['preview'] ) ) {
    132132            $this->url .= '&' . http_build_query(
    133                     [
    134                         'preview' => $_REQUEST['preview'],
    135                     ]
    136                 );
     133                [
     134                    'preview' => $_REQUEST['preview'],
     135                ]
     136            );
    137137        }
    138138    }
     
    149149        $args             = [];
    150150        if ( defined( 'WP_ENV' ) && WP_ENV === 'development' ) {
    151             $args['sslverify'] = FALSE;
     151            $args['sslverify'] = false;
    152152        }
    153153        $contents = wp_remote_get( $this->url, $args );
     
    157157            \error_log( 'BCcampus\Modules\Export\Mpdf\convert failed to get remote url' . $contents->get_error_message() );
    158158
    159             return FALSE;
     159            return false;
    160160        }
    161161        $doc                     = ( class_exists( HTML5::class ) ) ? new HTML5() : new \DOMDocument();
    162         $doc->preserveWhiteSpace = FALSE;
     162        $doc->preserveWhiteSpace = false;
    163163        $dom                     = $doc->loadHTML( $contents );
    164164
     
    171171            // @see https://mpdf.github.io/reference/mpdf-functions/overview.html
    172172            $this->mpdf->SetBasePath( home_url( '/' ) );
    173             $this->mpdf->SetCompression( TRUE );
     173            $this->mpdf->SetCompression( true );
    174174
    175175            // iterate over the xhtml domdocument
     
    186186             * works but mpdf headers and footer functionality is lost
    187187             *****************************************/
    188             //$this->mpdf->WriteHTML( $contents );
     188            //$this->mpdf->WriteHTML( $contents ); // @codingStandardsIgnoreLine
    189189
    190190            // make the thing
     
    195195        }
    196196
    197         return TRUE;
     197        return true;
    198198    }
    199199
     
    232232            'margin_footer'          => 9,
    233233            'orientation'            => 'P',
    234             'enableImports'          => FALSE,
     234            'enableImports'          => false,
    235235            'anchor2Bookmark'        => 1,
    236236            'mirrorMargins'          => 1,
    237237            'tempDir'                => _MPDF_TEMP_PATH,
    238238            'defaultCssFile'         => $css_file,
    239             'autoLangToFont'         => TRUE,
    240             'ignore_invalid_utf8'    => TRUE,
     239            'autoLangToFont'         => true,
     240            'ignore_invalid_utf8'    => true,
    241241            'defaultfooterline'      => 0,
    242242            'defaultheaderline'      => 0,
     
    244244            'defaultfooterfontstyle' => 'I',
    245245            'shrink_tables_to_fit'   => 1,
    246             'use_kwt'                => TRUE,
    247             //          'debug'                => true,
     246            'use_kwt'                => true,
     247            //'debug'                => true, // @codingStandardsIgnoreLine
    248248        ];
    249249
     
    285285
    286286        $options = [
    287             'paging'           => TRUE,
    288             'links'            => TRUE,
     287            'paging'           => true,
     288            'links'            => true,
    289289            'tocindent'        => 1,
    290290            'suppress'         => 'on',
     
    354354
    355355                    case 'fron':
    356                         $display_header = FALSE;
    357                         $display_footer = TRUE;
     356                        $display_header = false;
     357                        $display_footer = true;
    358358                        $page_options   = [
    359359                            'suppress'     => 'off',
     
    364364                        $class          = 'front-matter-title';
    365365                        $title          = $this->getNodeValue( $page, $element, $class );
    366                         $add_to_toc     = TRUE;
     366                        $add_to_toc     = true;
    367367                        break;
    368368
    369369                    case 'chap':
    370                         $display_header = TRUE;
    371                         $display_footer = TRUE;
     370                        $display_header = true;
     371                        $display_footer = true;
    372372                        $page_options   = [
    373373                            'suppress'     => 'off',
     
    378378                        $class          = 'chapter-title';
    379379                        $title          = $this->getNodeValue( $page, $element, $class );
    380                         $add_to_toc     = TRUE;
     380                        $add_to_toc     = true;
    381381                        break;
    382382
    383383                    case 'part':
    384                         $display_header = FALSE;
    385                         $display_footer = TRUE;
     384                        $display_header = false;
     385                        $display_footer = true;
    386386                        $page_options   = [
    387387                            'suppress'     => 'on',
     
    392392                        $class          = 'part-title';
    393393                        $title          = $this->getNodeValue( $page, $element, $class );
    394                         $add_to_toc     = TRUE;
     394                        $add_to_toc     = true;
    395395                        break;
    396396
    397397                    case 'back':
    398                         $display_header = FALSE;
    399                         $display_footer = TRUE;
     398                        $display_header = false;
     399                        $display_footer = true;
    400400                        $page_options   = [
    401401                            'suppress'     => 'off',
     
    406406                        $class          = 'back-matter-title';
    407407                        $title          = $this->getNodeValue( $page, $element, $class );
    408                         $add_to_toc     = TRUE;
     408                        $add_to_toc     = true;
    409409                        break;
    410410
    411411                    default:
    412                         $display_header = FALSE;
    413                         $display_footer = FALSE;
     412                        $display_header = false;
     413                        $display_footer = false;
    414414                        $page_options   = [
    415415                            'suppress'     => 'on',
     
    421421                        $class          = '';
    422422                        $title          = '';
    423                         $add_to_toc     = FALSE;
     423                        $add_to_toc     = false;
    424424
    425425                }
     
    489489        static $chap_id = 1;
    490490
    491         if ( 'part-title' == $class ) {
     491        if ( 'part-title' === $class ) {
    492492            $entry = $part_id . '. ' . $title;
    493493            $part_id ++;
    494         } elseif ( 'chapter-title' == $class ) {
     494        } elseif ( 'chapter-title' === $class ) {
    495495            $entry = $chap_id . '. ' . $title;
    496496            $chap_id ++;
     
    514514
    515515        // bail early
    516         if ( FALSE === $display ) {
     516        if ( false === $display ) {
    517517            return '';
    518518        }
     
    541541
    542542        // bail early
    543         if ( FALSE === $display ) {
     543        if ( false === $display ) {
    544544            return '';
    545545        }
     
    590590
    591591        if ( ! $this->isPdf( $this->outputPath ) ) {
    592             return FALSE;
    593         }
    594 
    595         return TRUE;
     592            return false;
     593        }
     594
     595        return true;
    596596    }
    597597
     
    607607        $mime = static::mimeType( $file );
    608608
    609         return ( strpos( $mime, 'application/pdf' ) !== FALSE );
     609        return ( strpos( $mime, 'application/pdf' ) !== false );
    610610    }
    611611
     
    622622            if ( is_array( $val ) ) {
    623623                if ( $this->atLeastOneExport( $val ) ) {
    624                     return TRUE;
     624                    return true;
    625625                }
    626626            } elseif ( 'export' === (string) $key && $val ) {
    627                 return TRUE;
     627                return true;
    628628            }
    629629        }
    630630
    631         return FALSE;
     631        return false;
    632632    }
    633633
  • pressbooks-mpdf/trunk/inc/modules/themeoptions/class-mpdfoptions.php

    r1881029 r1908445  
    5858     */
    5959    function init() {
    60         $_page    = $_option = 'pressbooks_theme_options_' . $this->getSlug();
     60        $_page    = 'pressbooks_theme_options_' . $this->getSlug();
     61        $_option  = 'pressbooks_theme_options_' . $this->getSlug();
    6162        $_section = $this->getSlug() . '_options_section';
    6263
     
    190191        );
    191192
    192         //      add_settings_field(
    193         //          'mpdf_indent_paragraphs',
    194         //          __( 'Indent paragraphs', 'pressbooks-mpdf' ),
    195         //          [ $this, 'renderIndentParagraphsField' ],
    196         //          $_page,
    197         //          $_section,
    198         //          [
    199         //               __( 'Indent paragraphs', 'pressbooks-mpdf' )
    200         //          ]
    201         //      );
    202         //
    203         //      add_settings_field(
    204         //          'mpdf_hyphens',
    205         //          __( 'Hyphens', 'pressbooks-mpdf' ),
    206         //          [ $this, 'renderHyphensField' ],
    207         //          $_page,
    208         //          $_section,
    209         //          [
    210         //               __( 'Enable hyphenation', 'pressbooks-mpdf' )
    211         //          ]
    212         //      );
    213         //
    214         //      add_settings_field(
    215         //          'mpdf_fontsize',
    216         //          __( 'Increase Font Size', 'pressbooks-mpdf' ),
    217         //          [ $this, 'renderFontSizeField' ],
    218         //          $_page,
    219         //          $_section,
    220         //          [
    221         //              __( 'Increases font size and line height for greater accessibility', 'pressbooks-mpdf' )
    222         //          ]
    223         //      );
    224 
    225193        /**
    226194         * Add custom settings fields.
  • pressbooks-mpdf/trunk/pressbooks-mpdf.php

    r1897333 r1908445  
    77 * Plugin Name: mPDF for Pressbooks
    88 * Description:  Open source PDF generation for Pressbooks via the mPDF library.
    9  * Version: 3.1.3
     9 * Version: 3.2.0
    1010 * Author: Brad Payne
    1111 * Author URI: https://github.com/bdolor
     
    1616 * Network: True
    1717 * Tags: pressbooks, OER, publishing, PDF, export
    18  * Pressbooks tested up to: 5.3.3
     18 * Pressbooks tested up to: 5.4.0
    1919 */
    2020/**
     
    7272
    7373        require_once __DIR__ . '/autoloader.php';
     74
    7475        // Load Composer Dependencies
    75         if ( file_exists( $composer = __DIR__ . '/vendor/autoload.php' ) ) {
     76        $composer = __DIR__ . '/vendor/autoload.php';
     77        if ( file_exists( $composer ) ) {
    7678            require_once( $composer );
    7779        }
  • pressbooks-mpdf/trunk/readme.txt

    r1897333 r1908445  
    33Donation link: https://github.com/BCcampus/pressbooks-mpdf
    44Tags: pressbooks, textbook, mPDF
    5 Requires at least: 4.9.5
    6 Tested up to: 4.9.6
    7 Stable tag: 3.1.3
     5Requires at least: 4.9.6
     6Tested up to: 4.9.7
     7Stable tag: 3.2.0
    88Requires PHP: 7.0
    99License: GPLv2
     
    6161
    6262See: https://github.com/BCcampus/pressbooks-mpdf/commits/master for more detail
     63
     64= 3.2.0 (2018/07/12) =
     65* update mPDF to v7.1.1
    6366
    6467= 3.1.3 (2018/06/18) =
  • pressbooks-mpdf/trunk/vendor/composer/installed.json

    r1897333 r1908445  
    22    {
    33        "name": "mpdf/mpdf",
    4         "version": "v7.1.0",
    5         "version_normalized": "7.1.0.0",
     4        "version": "v7.1.1",
     5        "version_normalized": "7.1.1.0",
    66        "source": {
    77            "type": "git",
    88            "url": "https://github.com/mpdf/mpdf.git",
    9             "reference": "8e3d0d7bf74f71d04904215fb487d01e924c469a"
    10         },
    11         "dist": {
    12             "type": "zip",
    13             "url": "https://api.github.com/repos/mpdf/mpdf/zipball/8e3d0d7bf74f71d04904215fb487d01e924c469a",
    14             "reference": "8e3d0d7bf74f71d04904215fb487d01e924c469a",
     9            "reference": "800a7f9d93474988cc2ffb8c155497ca5910fb09"
     10        },
     11        "dist": {
     12            "type": "zip",
     13            "url": "https://api.github.com/repos/mpdf/mpdf/zipball/800a7f9d93474988cc2ffb8c155497ca5910fb09",
     14            "reference": "800a7f9d93474988cc2ffb8c155497ca5910fb09",
    1515            "shasum": ""
    1616        },
     
    3535            "ext-zlib": "Needed for compression of embedded resources, such as fonts"
    3636        },
    37         "time": "2018-05-18T05:41:37+00:00",
     37        "time": "2018-07-02T14:26:48+00:00",
    3838        "type": "library",
    3939        "extra": {
     
    119119    {
    120120        "name": "paragonie/random_compat",
    121         "version": "v2.0.15",
    122         "version_normalized": "2.0.15.0",
     121        "version": "v2.0.17",
     122        "version_normalized": "2.0.17.0",
    123123        "source": {
    124124            "type": "git",
    125125            "url": "https://github.com/paragonie/random_compat.git",
    126             "reference": "10bcb46e8f3d365170f6de9d05245aa066b81f09"
    127         },
    128         "dist": {
    129             "type": "zip",
    130             "url": "https://api.github.com/repos/paragonie/random_compat/zipball/10bcb46e8f3d365170f6de9d05245aa066b81f09",
    131             "reference": "10bcb46e8f3d365170f6de9d05245aa066b81f09",
     126            "reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d"
     127        },
     128        "dist": {
     129            "type": "zip",
     130            "url": "https://api.github.com/repos/paragonie/random_compat/zipball/29af24f25bab834fcbb38ad2a69fa93b867e070d",
     131            "reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d",
    132132            "shasum": ""
    133133        },
     
    141141            "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
    142142        },
    143         "time": "2018-06-08T15:26:40+00:00",
     143        "time": "2018-07-04T16:31:37+00:00",
    144144        "type": "library",
    145145        "installation-source": "dist",
  • pressbooks-mpdf/trunk/vendor/mpdf/mpdf/src/Mpdf.php

    r1881029 r1908445  
    5656{
    5757
    58     const VERSION = '7.1.0';
     58    const VERSION = '7.1.1';
    5959
    6060    const SCALE = 72 / 25.4;
     
    2569125691        $toc_sheetsize = (isset($a['toc_sheetsize']) ? $a['toc_sheetsize'] : (isset($a['toc-sheet-size']) ? $a['toc-sheet-size'] : ''));
    2569225692
    25693         $this->TOCpagebreak($tocfont, $tocfontsize, $tocindent, $TOCusePaging, $TOCuseLinking, $toc_orientation, $toc_mgl, $toc_mgr, $toc_mgt, $toc_mgb, $toc_mgh, $toc_mgf, $toc_ohname, $toc_ehname, $toc_ofname, $toc_efname, $toc_ohvalue, $toc_ehvalue, $toc_ofvalue, $toc_efvalue, $toc_preHTML, $toc_postHTML, $toc_bookmarkText, $resetpagenum, $pagenumstyle, $suppress, $orientation, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $toc_id, $pagesel, $toc_pagesel, $sheetsize, $toc_sheetsize, $tocoutdent);
     25693        $this->TOCpagebreak('', '', '', $TOCusePaging, $TOCuseLinking, $toc_orientation, $toc_mgl, $toc_mgr, $toc_mgt, $toc_mgb, $toc_mgh, $toc_mgf, $toc_ohname, $toc_ehname, $toc_ofname, $toc_efname, $toc_ohvalue, $toc_ehvalue, $toc_ofvalue, $toc_efvalue, $toc_preHTML, $toc_postHTML, $toc_bookmarkText, $resetpagenum, $pagenumstyle, $suppress, $orientation, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $toc_id, $pagesel, $toc_pagesel, $sheetsize, $toc_sheetsize, $tocoutdent);
    2569425694    }
    2569525695
  • pressbooks-mpdf/trunk/vendor/mpdf/mpdf/src/TableOfContents.php

    r1881029 r1908445  
    316316            $tocClassClone->insertTOC();
    317317            $this->_toc = $tocClassClone->_toc;
    318             $this->mpdf->PageNumSubstitutions = $tocClassClone->mpdf->PageNumSubstitutions;
    319318        }
    320319
     
    440439            $this->mpdf->AddPage($toc_orientation, '', $tp_reset, $tp_pagenumstyle, $tp_suppress, $toc_mgl, $toc_mgr, $toc_mgt, $toc_mgb, $toc_mgh, $toc_mgf, $toc_ohname, $toc_ehname, $toc_ofname, $toc_efname, $toc_ohvalue, $toc_ehvalue, $toc_ofvalue, $toc_efvalue, $toc_page_selector, $toc_sheet_size); // mPDF 6
    441440
    442 
    443441            $this->mpdf->writingToC = true; // mPDF 5.6.38
     442
     443            /*
     444             * Ensure the TOC Page Number Style doesn't effect the TOC Numbering (added automatically in `AddPage()` above)
     445             * Ensure the page numbers show in the TOC when the 'suppress' setting is enabled
     446             * @see https://github.com/mpdf/mpdf/issues/792
     447             * @see https://github.com/mpdf/mpdf/issues/777
     448             */
     449            if (isset($tocClassClone)) {
     450                $this->mpdf->PageNumSubstitutions = array_map(function ($sub) {
     451                    $sub['suppress'] = '';
     452                    return $sub;
     453                }, $tocClassClone->mpdf->PageNumSubstitutions);
     454            }
     455
    444456            // mPDF 5.6.31
    445457            $tocstart = count($this->mpdf->pages);
     
    447459                $this->mpdf->WriteHTML($toc_preHTML);
    448460            }
    449 
    450461
    451462            // mPDF 5.6.19
  • pressbooks-mpdf/trunk/vendor/paragonie/random_compat/lib/byte_safe_strings.php

    r1897333 r1908445  
    2929if (!is_callable('RandomCompat_strlen')) {
    3030    if (
    31         defined('MB_OVERLOAD_STRING') &&
    32         ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
     31        defined('MB_OVERLOAD_STRING')
     32            &&
     33        ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING
    3334    ) {
    3435        /**
     
    8384    if (
    8485        defined('MB_OVERLOAD_STRING')
    85         &&
    86         ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
     86            &&
     87        ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING
    8788    ) {
    8889        /**
     
    9495         * @param string $binary_string
    9596         * @param int $start
    96          * @param int $length (optional)
     97         * @param int|null $length (optional)
    9798         *
    9899         * @throws TypeError
     
    119120                 * PHP 5.3, so we have to find the length ourselves.
    120121                 */
     122                /** @var int $length */
    121123                $length = RandomCompat_strlen($binary_string) - $start;
    122124            } elseif (!is_int($length)) {
     
    134136            }
    135137
    136             return (string) mb_substr($binary_string, $start, $length, '8bit');
     138            return (string) mb_substr(
     139                (string) $binary_string,
     140                (int) $start,
     141                (int) $length,
     142                '8bit'
     143            );
    137144        }
    138145
     
    146153         * @param string $binary_string
    147154         * @param int $start
    148          * @param int $length (optional)
     155         * @param int|null $length (optional)
    149156         *
    150157         * @throws TypeError
     
    173180                }
    174181
    175                 return (string) substr($binary_string, $start, $length);
     182                return (string) substr(
     183                    (string )$binary_string,
     184                    (int) $start,
     185                    (int) $length
     186                );
    176187            }
    177188
    178             return (string) substr($binary_string, $start);
     189            return (string) substr(
     190                (string) $binary_string,
     191                (int) $start
     192            );
    179193        }
    180194    }
  • pressbooks-mpdf/trunk/vendor/paragonie/random_compat/lib/cast_to_int.php

    r1897333 r1908445  
    5151            $number += 0;
    5252        } elseif (is_numeric($number)) {
     53            /** @psalm-suppress InvalidOperand */
    5354            $number += 0;
    5455        }
     56        /** @var int|float $number */
    5557
    5658        if (
    5759            is_float($number)
    58             &&
     60                &&
    5961            $number > ~PHP_INT_MAX
    60             &&
     62                &&
    6163            $number < PHP_INT_MAX
    6264        ) {
  • pressbooks-mpdf/trunk/vendor/paragonie/random_compat/lib/random.php

    r1897333 r1908445  
    44 * for using the new PHP 7 random_* API in PHP 5 projects
    55 *
    6  * @version 2.0.15
    7  * @released 2018-06-08
     6 * @version 2.0.17
     7 * @released 2018-07-04
    88 *
    99 * The MIT License (MIT)
     
    204204         *
    205205         * @param mixed $length
    206          * @psalm-suppress MissingReturnType
    207206         * @psalm-suppress InvalidReturnType
    208207         * @throws Exception
  • pressbooks-mpdf/trunk/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php

    r1897333 r1908445  
    4242    {
    4343        try {
     44            /** @var int $bytes */
    4445            $bytes = RandomCompat_intval($bytes);
    4546        } catch (TypeError $ex) {
     
    5556        }
    5657
     58        /** @var string $buf */
    5759        $buf = '';
    5860        if (!class_exists('COM')) {
     
    6163            );
    6264        }
     65        /** @var COM $util */
    6366        $util = new COM('CAPICOM.Utilities.1');
    6467        $execCount = 0;
     
    6972         */
    7073        do {
    71             $buf .= base64_decode($util->GetRandom($bytes, 0));
     74            $buf .= base64_decode((string) $util->GetRandom($bytes, 0));
    7275            if (RandomCompat_strlen($buf) >= $bytes) {
    7376                /**
    7477                 * Return our random entropy buffer here:
    7578                 */
    76                 return RandomCompat_substr($buf, 0, $bytes);
     79                return (string) RandomCompat_substr($buf, 0, $bytes);
    7780            }
    7881            ++$execCount;
  • pressbooks-mpdf/trunk/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php

    r1897333 r1908445  
    4747    function random_bytes($bytes)
    4848    {
     49        /** @var resource $fp */
    4950        static $fp = null;
     51
    5052        /**
    5153         * This block should only be run once
     
    5658             * We never fall back to /dev/random
    5759             */
     60            /** @var resource|bool $fp */
    5861            $fp = fopen('/dev/urandom', 'rb');
    59             if (!empty($fp)) {
     62            if (is_resource($fp)) {
     63                /** @var array<string, int> $st */
    6064                $st = fstat($fp);
    6165                if (($st['mode'] & 0170000) !== 020000) {
     
    6569            }
    6670
    67             if (!empty($fp)) {
     71            if (is_resource($fp)) {
    6872                /**
    6973                 * stream_set_read_buffer() does not exist in HHVM
     
    8488
    8589        try {
     90            /** @var int $bytes */
    8691            $bytes = RandomCompat_intval($bytes);
    8792        } catch (TypeError $ex) {
     
    104109         * page load.
    105110         */
    106         if (!empty($fp)) {
     111        if (is_resource($fp)) {
    107112            /**
    108113             * @var int
  • pressbooks-mpdf/trunk/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php

    r1897333 r1908445  
    4444    {
    4545        try {
     46            /** @var int $bytes */
    4647            $bytes = RandomCompat_intval($bytes);
    4748        } catch (TypeError $ex) {
     
    6162         * generated in one invocation.
    6263         */
     64        /** @var string|bool $buf */
    6365        if ($bytes > 2147483647) {
    6466            $buf = '';
     
    7072            }
    7173        } else {
     74            /** @var string|bool $buf */
    7275            $buf = \Sodium\randombytes_buf($bytes);
    7376        }
    7477
    75         if ($buf !== false) {
     78        if (is_string($buf)) {
    7679            if (RandomCompat_strlen($buf) === $bytes) {
    7780                return $buf;
  • pressbooks-mpdf/trunk/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php

    r1897333 r1908445  
    4444    {
    4545        try {
     46            /** @var int $bytes */
    4647            $bytes = RandomCompat_intval($bytes);
    4748        } catch (TypeError $ex) {
  • pressbooks-mpdf/trunk/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php

    r1897333 r1908445  
    4343    {
    4444        try {
     45            /** @var int $bytes */
    4546            $bytes = RandomCompat_intval($bytes);
    4647        } catch (TypeError $ex) {
     
    5657        }
    5758
    58         $buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
     59        /** @var string|bool $buf */
     60        $buf = @mcrypt_create_iv((int) $bytes, (int) MCRYPT_DEV_URANDOM);
    5961        if (
    60             $buf !== false
    61             &&
     62            is_string($buf)
     63                &&
    6264            RandomCompat_strlen($buf) === $bytes
    6365        ) {
  • pressbooks-mpdf/trunk/vendor/paragonie/random_compat/lib/random_int.php

    r1897333 r1908445  
    5252
    5353        try {
     54            /** @var int $min */
    5455            $min = RandomCompat_intval($min);
    5556        } catch (TypeError $ex) {
     
    6061
    6162        try {
     63            /** @var int $max */
    6264            $max = RandomCompat_intval($max);
    6365        } catch (TypeError $ex) {
     
    9193         */
    9294        $attempts = $bits = $bytes = $mask = $valueShift = 0;
     95        /** @var int $attempts */
     96        /** @var int $bits */
     97        /** @var int $bytes */
     98        /** @var int $mask */
     99        /** @var int $valueShift */
    93100
    94101        /**
     
    96103         * overflow, however, if $max - $min > PHP_INT_MAX. PHP will cast it to
    97104         * a float and we will lose some precision.
     105         *
     106         * @var int|float $range
    98107         */
    99108        $range = $max - $min;
     
    116125             */
    117126            $bytes = PHP_INT_SIZE;
     127            /** @var int $mask */
    118128            $mask = ~0;
    119129
     
    130140                ++$bits;
    131141                $range >>= 1;
     142                /** @var int $mask */
    132143                $mask = $mask << 1 | 1;
    133144            }
     
    135146        }
    136147
     148        /** @var int $val */
    137149        $val = 0;
    138150        /**
     
    140152         * random integers until one falls between $min and $max
    141153         */
     154        /** @psalm-suppress RedundantCondition */
    142155        do {
    143156            /**
     
    170183                $val |= ord($randomByteString[$i]) << ($i * 8);
    171184            }
     185            /** @var int $val */
    172186
    173187            /**
  • pressbooks-mpdf/trunk/vendor/paragonie/random_compat/psalm.xml

    r1897333 r1908445  
    22<psalm
    33    autoloader="psalm-autoload.php"
    4     stopOnFirstError="false"
    54    useDocblockTypes="true"
     5    totallyTyped="true"
    66>
    77    <projectFiles>
     
    1010    <issueHandlers>
    1111        <RedundantConditionGivenDocblockType errorLevel="info" />
     12            <!-- We have to be explicit because PHP 5 lacks scalar types -->
    1213        <UnresolvableInclude errorLevel="info" />
     14            <!-- Because we put the variants into their own subdirectory -->
    1315        <DuplicateClass errorLevel="info" />
    14         <InvalidOperand errorLevel="info" />
     16            <!-- Later versions of Psalm are only PHP 7 compatible, which
     17                 sees our redefinition of Error and TypeError as duplicate
     18                 class errors. -->
    1519        <UndefinedConstant errorLevel="info" />
     20            <!-- The Mcrypt constants aren't defined in PHP 7.2 -->
    1621        <MissingReturnType errorLevel="info" />
     22            <!-- False positive with some versions of (Psalm, PHP) -->
    1723        <InvalidReturnType errorLevel="info" />
     24            <!-- The "last resort" function in lib/random.php -->
     25        <MixedInferredReturnType errorLevel="suppress" />
     26            <!-- Only used in totallyTyped mode -->
    1827    </issueHandlers>
    1928</psalm>
Note: See TracChangeset for help on using the changeset viewer.