Plugin Directory

Changeset 2894437


Ignore:
Timestamp:
04/05/2023 02:10:30 PM (3 years ago)
Author:
simongomes02
Message:

release: version 1.1.1

Location:
ship-to-ecourier
Files:
112 added
18 edited

Legend:

Unmodified
Added
Removed
  • ship-to-ecourier/trunk/assets/js/admin.js

    r2528332 r2894437  
    1414    let bookingForm = $( '#ste-booking-metabox-form' );
    1515    let bookingMetaBoxMessage = $( '#ste-booking-metabox-message' );
     16    let recipientCity = $( '#recipient_city' );
     17    let recipientArea = $( '#recipient_area' );
     18    let recipientThana = $( '#recipient_thana' );
     19    let recipientZip = $( '#recipient_zip' );
     20
     21    /**
     22     * Setting area on change of city/district.
     23     */
     24    recipientCity.on( 'change', function ( event ) {
     25        let data = {
     26            action: 'ste_get_area_by_district',
     27            district: this.value,
     28            _nonce: STE_ADMIN.nonce,
     29        };
     30
     31        recipientArea.prop( 'disabled', true );
     32
     33        $.post( STE_ADMIN.ajaxurl, data, function ( response ) {
     34            recipientArea.empty();
     35            recipientThana.val( '' );
     36            recipientZip.val( '' );
     37
     38            if ( ! response.success ) {
     39                errorMessage.text( response.data );
     40                parcelSubmitButton.prop( 'disabled', true );
     41                return;
     42            }
     43
     44            errorMessage.text( '' );
     45
     46            recipientArea.prop( 'disabled', false );
     47
     48            let areas = response.data;
     49
     50            areas.map( function ( area, index ) {
     51                recipientArea.append( `<option data-thana="${area.thana}" data-post_code="${area.post_code}" value="${area.name.toLowerCase()}">${area.name}</option>` );
     52
     53                if ( index === 0 ) {
     54                    recipientThana.val( area.thana );
     55                    recipientZip.val( area.post_code );
     56                }
     57            } );
     58        } );
     59    } );
     60
     61    /**
     62     * Setting thana and post code on change of area.
     63     */
     64    recipientArea.on( 'change', function ( event ) {
     65        let optionSelected = $( 'option:selected', this );
     66
     67        recipientThana.val( optionSelected.data( 'thana' ) );
     68        recipientZip.val( optionSelected.data( 'post_code' ) );
     69    } );
    1670
    1771    parcelSubmitButton.on("click", function (e) {
     
    3488            comments: $( "#comments", bookingFormWrap ).val(),
    3589            submit_ste_ecourier_parcel: $( "#submit_ste_ecourier_parcel", bookingFormWrap ).val(),
     90            original_order_number: $( "#original_order_number", bookingFormWrap ).val(),
    3691            action: 'ste_booking_metabox_form',
    3792            _nonce: STE_ADMIN.nonce,
     
    113168            let orderData = {
    114169                tracking: cancleOrderButton.val(),
     170                original_order_number: $( '#original_order_number' ).val(),
    115171                action: 'ste_cancel_parcel_request',
    116172                _nonce: STE_ADMIN.nonce,
     
    118174
    119175            $.post(STE_ADMIN.ajaxurl, orderData, function (response) {
    120                 console.log( response );
    121176                if (!response.success) {
    122177                    errorMessage.text(response.data.message);
  • ship-to-ecourier/trunk/includes/Admin/STE_Metabox.php

    r2525816 r2894437  
    6464                // Set all necessary Shipping Information.
    6565                $this->set_shipping_info( $theorder );
     66
     67                $cities = ship_to_ecourier()->ecourier->get_city_list();
     68
     69                if ( is_wp_error( $cities ) ) {
     70                    $cities = [];
     71                }
     72
     73                $areas = ship_to_ecourier()->ecourier->get_area_by_district( $this->shipping_info['recipient_city'] );
     74
     75                if ( is_wp_error( $cities ) ) {
     76                    $areas = [];
     77                }
     78
    6679            } else {
    6780                $order_shipped->user = get_user_by( 'ID', $order_shipped->created_by )->display_name;
     
    8598            $this->shipping_info['recipient_name']    = '' !== trim( $order->get_formatted_shipping_full_name() ) ? $order->get_formatted_shipping_full_name() : $order->get_formatted_billing_full_name();
    8699            $this->shipping_info['recipient_mobile']  = $order->get_billing_phone();
    87             $this->shipping_info['recipient_city']    = '' !== trim( $order->get_shipping_city() ) ? $order->get_shipping_city() : $order->get_billing_city();
    88             $this->shipping_info['recipient_area']    = '';
     100            $this->shipping_info['recipient_city']    = '' !== trim( $order->get_shipping_state() ) ? strtolower( $order->get_shipping_state() ) : strtolower( $order->get_billing_state() );
     101            $this->shipping_info['recipient_area']    = '' !== trim( $order->get_shipping_city() ) ? strtolower( $order->get_shipping_city() ) : strtolower( $order->get_billing_city() );
    89102            $this->shipping_info['recipient_thana']   = '';
    90103            $this->shipping_info['recipient_zip']     = '' !== trim( $order->get_shipping_postcode() ) ? $order->get_shipping_postcode() : $order->get_billing_postcode();
     
    100113                $this->shipping_info['comments'] .= $item->get_name() . ' x' . $item->get_quantity() . PHP_EOL;
    101114            }
     115
     116            $this->shipping_info = apply_filters( 'ste_set_shipping_info', $this->shipping_info, $order );
    102117        }
    103118
  • ship-to-ecourier/trunk/includes/Admin/views/ste-booking-metabox-view.php

    r2528332 r2894437  
    55 * @package SendToEcourier\Admin
    66 */
     7
     8$recipient_thana     = '';
     9$recipient_post_code = '';
    710
    811?>
     
    2124            </li>
    2225            <li class="wide">
    23                 <label for="recipient_city"><?php esc_attr_e( 'Recipient City', 'ship-to-ecourier' ); ?></label>
    24                 <input class="input-text" type="text" name="recipient_city" id="recipient_city" placeholder="<?php esc_attr__( 'Recipient City', 'ship-to-ecourier' ); ?>"  value="<?php echo esc_attr( $this->shipping_info['recipient_city'] ); ?>">
     26                <label for="recipient_city"><?php esc_attr_e( 'Recipient District', 'ship-to-ecourier' ); ?></label>
     27                <select name="recipient_city" id="recipient_city" class="wc-enhanced-select">
     28                    <?php
     29                    foreach ( $cities as $city ) :
     30                        $city_val = strtolower( $city['value'] );
     31                        ?>
     32                    <option value="<?php echo $city_val; ?>" <?php echo $city_val === $this->shipping_info['recipient_city'] ? 'selected' : false; ?> ><?php echo $city['name']; ?></option>
     33                    <?php endforeach; ?>
     34                </select>
    2535            </li>
    2636            <li class="wide">
    2737                <label for="recipient_area"><?php esc_attr_e( 'Recipient Area', 'ship-to-ecourier' ); ?></label>
    28                 <input class="input-text" type="text" name="recipient_area" id="recipient_area" placeholder="<?php esc_attr__( 'Recipient Area', 'ship-to-ecourier' ); ?>"  value="<?php echo esc_attr( $this->shipping_info['recipient_area'] ); ?>">
     38
     39                <select name="recipient_area" id="recipient_area" class="wc-enhanced-select">
     40                    <?php
     41                    foreach ( $areas as $area ) :
     42                        $area_val = strtolower( $area['name'] );
     43
     44                        if ( $area_val === $this->shipping_info['recipient_area'] ) {
     45                            $recipient_thana     = strtolower( $area['thana'] );
     46                            $recipient_post_code = $area['post_code'];
     47                        }
     48                        ?>
     49                        <option
     50                            data-thana="<?php echo $area['thana']; ?>"
     51                            data-post_code="<?php echo $area['post_code']; ?>"
     52                            value="<?php echo $area_val; ?>" <?php echo $area_val === $this->shipping_info['recipient_area'] ? 'selected' : false; ?> >
     53                            <?php echo $area['name']; ?>
     54                        </option>
     55                    <?php endforeach; ?>
     56                </select>
    2957            </li>
    3058            <li class="wide">
    3159                <label for="recipient_thana"><?php esc_attr_e( 'Recipient Thana', 'ship-to-ecourier' ); ?></label>
    32                 <input class="input-text" type="text" name="recipient_thana" id="recipient_thana" placeholder="<?php esc_attr__( 'Recipient Thana', 'ship-to-ecourier' ); ?>"  value="<?php echo esc_attr( $this->shipping_info['recipient_thana'] ); ?>">
     60                <input class="input-text" type="text" name="recipient_thana" id="recipient_thana" placeholder="<?php esc_attr__( 'Recipient Thana', 'ship-to-ecourier' ); ?>"  value="<?php echo esc_attr( $recipient_thana ); ?>" readonly>
    3361            </li>
    3462            <li class="wide">
    3563                <label for="recipient_zip"><?php esc_attr_e( 'Recipient Zip', 'ship-to-ecourier' ); ?></label>
    36                 <input class="input-text" type="text" name="recipient_zip" id="recipient_zip" placeholder="<?php esc_attr__( 'Recipient Zip', 'ship-to-ecourier' ); ?>"  value="<?php echo esc_attr( $this->shipping_info['recipient_zip'] ); ?>">
     64                <input class="input-text" type="text" name="recipient_zip" id="recipient_zip" placeholder="<?php esc_attr__( 'Recipient Zip', 'ship-to-ecourier' ); ?>"  value="<?php echo esc_attr( $recipient_post_code ); ?>" readonly>
    3765            </li>
    3866            <li class="wide">
     
    4270            <li class="wide">
    4371                <label for="payment_method"><?php esc_attr_e( 'Payment Method', 'ship-to-ecourier' ); ?></label>
    44                 <select name="payment_method" id="payment_method">
    45                     <option value="CCRD"><?php esc_html_e( 'Card Payment', 'ship-to-ecourier' ); ?></option>
     72                <select name="payment_method" id="payment_method" class="wc-enhanced-select">
     73                    <option value="CCRD" <?php echo 'ccrd' === $this->shipping_info['payment_method'] ? 'selected' : false; ?>><?php esc_html_e( 'Card Payment', 'ship-to-ecourier' ); ?></option>
    4674                    <option value="COD" <?php echo 'cod' === $this->shipping_info['payment_method'] ? 'selected' : false; ?>><?php esc_html_e( 'Cash On Delivery', 'ship-to-ecourier' ); ?></option>
    47                     <option value="MPAY"><?php esc_html_e( 'Mobile Payment', 'ship-to-ecourier' ); ?></option>
    48                     <option value="POS"><?php esc_html_e( 'POS', 'ship-to-ecourier' ); ?></option>
     75                    <option value="MPAY" <?php echo 'mpay' === $this->shipping_info['payment_method'] ? 'selected' : false; ?>><?php esc_html_e( 'Mobile Payment', 'ship-to-ecourier' ); ?></option>
     76                    <option value="POS" <?php echo 'pos' === $this->shipping_info['payment_method'] ? 'selected' : false; ?>><?php esc_html_e( 'POS', 'ship-to-ecourier' ); ?></option>
    4977                </select>
    5078            </li>
    5179            <li class="wide">
    5280                <label for="package_code"><?php esc_attr_e( 'Package', 'ship-to-ecourier' ); ?></label>
    53                 <select name="package_code" id="package_code">
     81                <select name="package_code" id="package_code" class="wc-enhanced-select">
    5482                    <?php
    5583                    foreach ( $this->shipping_info['package_code'] as $package ) {
     
    107135        </div>
    108136    <?php } ?>
     137
     138    <input type="hidden" name="original_order_number" id="original_order_number" value="<?php echo esc_attr( $post->ID ); ?>">
    109139</div>
  • ship-to-ecourier/trunk/includes/Ajax.php

    r2528332 r2894437  
    4444            $this->ecourier_base_url = 'live' === $this->settings['api_environment'] ? STE_API_BASE_URL_LIVE : STE_API_BASE_URL_STAGING;
    4545
     46            add_action( 'wp_ajax_ste_get_area_by_district', array( $this, 'handle_ste_get_area_by_district' ) );
    4647            add_action( 'wp_ajax_ste_parcel_tracking_form', array( $this, 'handle_parcel_tracker_form_submission' ) );
    4748            add_action( 'wp_ajax_nopriv_ste_parcel_tracking_form', array( $this, 'handle_parcel_tracker_form_submission' ) );
     
    5253        }
    5354
     55        public function handle_ste_get_area_by_district() {
     56            if ( ! isset( $_POST['_nonce'] ) || empty( $_POST['district'] ) ) {
     57                wp_send_json_error( __( 'Something went wrong here!', 'ship-to-ecourier' ) );
     58                wp_die();
     59            }
     60
     61            // Block if _nonce field is not available and valid.
     62            check_ajax_referer( 'ste-admin-nonce', '_nonce' );
     63
     64            $areas = ship_to_ecourier()->ecourier->get_area_by_district( sanitize_text_field( $_POST['district'] ) );
     65
     66            if ( is_wp_error( $areas ) ) {
     67                wp_send_json_error( $areas->get_error_message() );
     68                wp_die();
     69            }
     70
     71            wp_send_json_success( $areas );
     72        }
     73
    5474        /**
    5575         * Handle the tracking form submission. Get parcel status from eCourier and return back to front end.
     
    7090                // Make request to eCourier API.
    7191                $response = $this->make_request( $ecourier_api_url, array( 'ecr' => $tracking_code ) );
     92
     93                if ( is_wp_error( $response ) ) {
     94                    wp_send_json_error(
     95                        array(
     96                            'message' => $response->get_error_data(),
     97                        )
     98                    );
     99                }
    72100
    73101                // Send response to front-end.
     
    123151                    )
    124152                );
     153                return;
    125154            }
    126155
     
    129158                'recipient_name'    => sanitize_text_field( wp_unslash( $_POST['recipient_name'] ) ),
    130159                'recipient_mobile'  => sanitize_text_field( wp_unslash( $_POST['recipient_mobile'] ) ),
    131                 'recipient_city'    => sanitize_text_field( wp_unslash( $_POST['recipient_city'] ) ),
    132                 'recipient_area'    => sanitize_text_field( wp_unslash( $_POST['recipient_area'] ) ),
    133                 'recipient_thana'   => sanitize_text_field( wp_unslash( $_POST['recipient_thana'] ) ),
     160                'recipient_city'    => ucwords( sanitize_text_field( wp_unslash( $_POST['recipient_city'] ) ) ),
     161                'recipient_area'    => ucwords( sanitize_text_field( wp_unslash( $_POST['recipient_area'] ) ) ),
     162                'recipient_thana'   => ucwords( sanitize_text_field( wp_unslash( $_POST['recipient_thana'] ) ) ),
    134163                'recipient_zip'     => sanitize_text_field( wp_unslash( $_POST['recipient_zip'] ) ),
    135164                'recipient_address' => sanitize_text_field( wp_unslash( $_POST['recipient_address'] ) ),
     
    147176            $response = $this->make_request( $ecourier_api_url, $parcel_data );
    148177
     178            if ( is_wp_error( $response ) ) {
     179                wp_send_json_error(
     180                    array(
     181                        'message' => $response->get_error_data(),
     182                    )
     183                );
     184                return;
     185            }
     186
    149187            $result = json_decode( $response['body'], true );
    150188
     
    165203                        )
    166204                    );
     205                    return;
    167206                }
    168207
    169                 // Get the order to update the order status.
    170                 $order = new \WC_Order( $parcel_data['product_id'] );
     208                $user = get_user_by( 'id', get_current_user_id() );
     209
     210                $order_shipped_note = '';
     211
     212                if ( $user ) {
     213                    $order_shipped_note = sprintf(
     214                        __( 'Order shipped to Ecourier by %s', 'ship-to-ecourier' ),
     215                        $user->display_name
     216                    );
     217                }
     218
     219                /**
     220                 * Get the order to update the order status.
     221                 *
     222                 * using original order number here because sometimes the order
     223                 * number might be modified through `woocommerce_order_number` filter
     224                 * by third party plugin.
     225                 */
     226                $order = new \WC_Order( sanitize_text_field( wp_unslash( $_POST['original_order_number'] ) ) );
     227                ! empty( $order_shipped_note ) ? $order->add_order_note( $order_shipped_note ) : null;
    171228                $order->update_status( 'shipped' );
    172229            }
     
    209266            $response = $this->make_request( $ecourier_api_url, $label_data );
    210267
     268            if ( is_wp_error( $response ) ) {
     269                wp_send_json_error(
     270                    array(
     271                        'message' => $response->get_error_data(),
     272                    )
     273                );
     274            }
     275
    211276            $result = json_decode( $response['body'], true );
    212277
     
    244309            check_ajax_referer( 'ste-admin-nonce', '_nonce' );
    245310
     311            $user = get_user_by( 'id', get_current_user_id() );
     312
    246313            // Generate label print data to send to eCourier.
    247314            $label_data = array(
    248315                'tracking' => sanitize_text_field( wp_unslash( $_POST['tracking'] ) ),
    249                 'comment'  => __( 'Please cancle the parcel.', 'ship-to-ecourier' ),
     316                'comment'  => __( 'Please cancel the parcel. Requested by ' . $user->display_name , 'ship-to-ecourier' ),
    250317            );
    251318
     
    254321            // Send parcel cancel request to eCourier.
    255322            $response = $this->make_request( $ecourier_api_url, $label_data );
     323
     324            if ( is_wp_error( $response ) ) {
     325                wp_send_json_error(
     326                    array(
     327                        'message' => $response->get_error_data(),
     328                    )
     329                );
     330            }
    256331
    257332            $result = json_decode( $response['body'], true );
     
    274349                    );
    275350                }
     351            }
     352
     353            $order = wc_get_order( wp_unslash( $_POST['original_order_number'] ) );
     354
     355            if ( $order instanceof \WC_Order) {
     356                $order_cancel_note = '';
     357
     358                if ( $user ) {
     359                    $order_cancel_note = sprintf(
     360                        __( 'Shipping cancelled at Ecourier by %s', 'ship-to-ecourier' ),
     361                        $user->display_name
     362                    );
     363                }
     364
     365                ! empty( $order_cancel_note ) ? $order->add_order_note( $order_cancel_note ) : null;
     366
     367                $order->update_status( 'processing' );
    276368            }
    277369
  • ship-to-ecourier/trunk/includes/functions.php

    r2528332 r2894437  
    4343 * Get eCourier packages for the connected account.
    4444 *
    45  * @return array
     45 * @return array|\WP_Error
    4646 */
    4747function ste_get_ecourier_packages() {
     48
     49    $cache_key = 'ste_packages_list';
     50
     51    $packages = get_transient( $cache_key );
     52
     53    if ( $packages ) {
     54        return $packages;
     55    }
    4856
    4957    // Get eCourier API configs.
     
    6674    );
    6775
     76    if ( is_wp_error( $response ) ) {
     77        return new WP_Error( 'ste_package_fetch_error', 'Error in getting packages', [ 'status' => 500 ] );
     78    }
     79
    6880    $packages = json_decode( $response['body'] );
     81
     82    //keeping data in cache. Expire in 48 hours.
     83    set_transient( $cache_key, $packages, 172800 );
    6984
    7085    return $packages;
  • ship-to-ecourier/trunk/readme.txt

    r2529341 r2894437  
    44Tags: ecourier, ecourier-parcel, ship-to-ecourier, ecourier-booking, ecourier-parcel-booking, ecourier-booking-automation, ecourier-parcel-tracker
    55Requires at least: 4.0
    6 Tested up to: 5.7.1
     6Tested up to: 6.2.0
    77Requires PHP: 5.6
    8 Stable tag: 1.1.0
     8Stable tag: 1.1.1
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7979== Changelog ==
    8080
     81= 1.1.1 =
     82
     83* Fetch City and area from Ecourier API and display in Dropdown
     84* Add caching for storing API data to avoid redundancy
     85* Error handling for HTTP requests.
     86* Add order note when shipped and cancel
     87* added a filter to allow modification in shipping info by 3rd party plugin
     88
    8189= 1.1.0 =
    8290* Added: Label printing feature
  • ship-to-ecourier/trunk/ship-to-ecourier.php

    r2528332 r2894437  
    88 * Text Domain:     ship-to-ecourier
    99 * Domain Path:     /languages
    10  * Version:         1.1.0
     10 * Version:         1.1.1
    1111 * License:         GPLv3
    1212 * License URI:     https://www.gnu.org/licenses/gpl-3.0.html
     
    6868
    6969        /**
     70         * Holds various class instances.
     71         *
     72         * @var array
     73         */
     74        private $container = [];
     75
     76        /**
    7077         * Ship_To_Ecourier constructor.
    7178         *
     
    7885
    7986            add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
     87
     88            add_action( 'init', [ $this, 'init_classes' ] );
    8089        }
    8190
     
    8695         */
    8796        public static function init() {
    88             $instance = false;
     97            static $instance = false;
    8998
    9099            if ( ! $instance ) {
     
    93102
    94103            return $instance;
     104        }
     105
     106        /**
     107         * Magic getter to bypass referencing plugin.
     108         *
     109         * @param mixed $prop Properties to find.
     110         *
     111         * @return mixed
     112         */
     113        public function __get( $prop ) {
     114            if ( array_key_exists( $prop, $this->container ) ) {
     115                return $this->container[ $prop ];
     116            }
     117
     118            return $this->{$prop};
     119        }
     120
     121        /**
     122         * Magic isset to bypass referencing plugin.
     123         *
     124         * @param mixed $prop Properties to find.
     125         *
     126         * @return mixed
     127         */
     128        public function __isset( $prop ) {
     129            return isset( $this->{$prop} ) || isset( $this->container[ $prop ] );
    95130        }
    96131
     
    138173
    139174        /**
     175         * Initialize classes
     176         *
     177         * @return void
     178         */
     179        public function init_classes() {
     180            $this->container['ecourier'] = new ShipToEcourier\Ecourier_Handler();
     181        }
     182
     183        /**
    140184         * Necessary setup on plugin activation.
    141185         *
  • ship-to-ecourier/trunk/vendor/autoload.php

    r2525816 r2894437  
    33// autoload.php @generated by Composer
    44
     5if (PHP_VERSION_ID < 50600) {
     6    if (!headers_sent()) {
     7        header('HTTP/1.1 500 Internal Server Error');
     8    }
     9    $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
     10    if (!ini_get('display_errors')) {
     11        if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
     12            fwrite(STDERR, $err);
     13        } elseif (!headers_sent()) {
     14            echo $err;
     15        }
     16    }
     17    trigger_error(
     18        $err,
     19        E_USER_ERROR
     20    );
     21}
     22
    523require_once __DIR__ . '/composer/autoload_real.php';
    624
    7 return ComposerAutoloaderInit623e2aa6265ae73da9cc7e7f68ee232a::getLoader();
     25return ComposerAutoloaderInit55922fb54980b576755edaecda902c54::getLoader();
  • ship-to-ecourier/trunk/vendor/composer/ClassLoader.php

    r2525816 r2894437  
    4343class ClassLoader
    4444{
     45    /** @var \Closure(string):void */
     46    private static $includeFile;
     47
     48    /** @var ?string */
     49    private $vendorDir;
     50
    4551    // PSR-4
     52    /**
     53     * @var array[]
     54     * @psalm-var array<string, array<string, int>>
     55     */
    4656    private $prefixLengthsPsr4 = array();
     57    /**
     58     * @var array[]
     59     * @psalm-var array<string, array<int, string>>
     60     */
    4761    private $prefixDirsPsr4 = array();
     62    /**
     63     * @var array[]
     64     * @psalm-var array<string, string>
     65     */
    4866    private $fallbackDirsPsr4 = array();
    4967
    5068    // PSR-0
     69    /**
     70     * @var array[]
     71     * @psalm-var array<string, array<string, string[]>>
     72     */
    5173    private $prefixesPsr0 = array();
     74    /**
     75     * @var array[]
     76     * @psalm-var array<string, string>
     77     */
    5278    private $fallbackDirsPsr0 = array();
    5379
     80    /** @var bool */
    5481    private $useIncludePath = false;
     82
     83    /**
     84     * @var string[]
     85     * @psalm-var array<string, string>
     86     */
    5587    private $classMap = array();
     88
     89    /** @var bool */
    5690    private $classMapAuthoritative = false;
     91
     92    /**
     93     * @var bool[]
     94     * @psalm-var array<string, bool>
     95     */
    5796    private $missingClasses = array();
     97
     98    /** @var ?string */
    5899    private $apcuPrefix;
    59100
     101    /**
     102     * @var self[]
     103     */
     104    private static $registeredLoaders = array();
     105
     106    /**
     107     * @param ?string $vendorDir
     108     */
     109    public function __construct($vendorDir = null)
     110    {
     111        $this->vendorDir = $vendorDir;
     112        self::initializeIncludeClosure();
     113    }
     114
     115    /**
     116     * @return string[]
     117     */
    60118    public function getPrefixes()
    61119    {
     
    67125    }
    68126
     127    /**
     128     * @return array[]
     129     * @psalm-return array<string, array<int, string>>
     130     */
    69131    public function getPrefixesPsr4()
    70132    {
     
    72134    }
    73135
     136    /**
     137     * @return array[]
     138     * @psalm-return array<string, string>
     139     */
    74140    public function getFallbackDirs()
    75141    {
     
    77143    }
    78144
     145    /**
     146     * @return array[]
     147     * @psalm-return array<string, string>
     148     */
    79149    public function getFallbackDirsPsr4()
    80150    {
     
    82152    }
    83153
     154    /**
     155     * @return string[] Array of classname => path
     156     * @psalm-return array<string, string>
     157     */
    84158    public function getClassMap()
    85159    {
     
    88162
    89163    /**
    90      * @param array $classMap Class to filename map
     164     * @param string[] $classMap Class to filename map
     165     * @psalm-param array<string, string> $classMap
     166     *
     167     * @return void
    91168     */
    92169    public function addClassMap(array $classMap)
     
    103180     * appending or prepending to the ones previously set for this prefix.
    104181     *
    105      * @param string       $prefix  The prefix
    106      * @param array|string $paths   The PSR-0 root directories
    107      * @param bool         $prepend Whether to prepend the directories
     182     * @param string          $prefix  The prefix
     183     * @param string[]|string $paths   The PSR-0 root directories
     184     * @param bool            $prepend Whether to prepend the directories
     185     *
     186     * @return void
    108187     */
    109188    public function add($prefix, $paths, $prepend = false)
     
    148227     * appending or prepending to the ones previously set for this namespace.
    149228     *
    150      * @param string       $prefix  The prefix/namespace, with trailing '\\'
    151      * @param array|string $paths   The PSR-4 base directories
    152      * @param bool         $prepend Whether to prepend the directories
     229     * @param string          $prefix  The prefix/namespace, with trailing '\\'
     230     * @param string[]|string $paths   The PSR-4 base directories
     231     * @param bool            $prepend Whether to prepend the directories
    153232     *
    154233     * @throws \InvalidArgumentException
     234     *
     235     * @return void
    155236     */
    156237    public function addPsr4($prefix, $paths, $prepend = false)
     
    196277     * replacing any others previously set for this prefix.
    197278     *
    198      * @param string       $prefix The prefix
    199      * @param array|string $paths  The PSR-0 base directories
     279     * @param string          $prefix The prefix
     280     * @param string[]|string $paths  The PSR-0 base directories
     281     *
     282     * @return void
    200283     */
    201284    public function set($prefix, $paths)
     
    212295     * replacing any others previously set for this namespace.
    213296     *
    214      * @param string       $prefix The prefix/namespace, with trailing '\\'
    215      * @param array|string $paths  The PSR-4 base directories
     297     * @param string          $prefix The prefix/namespace, with trailing '\\'
     298     * @param string[]|string $paths  The PSR-4 base directories
    216299     *
    217300     * @throws \InvalidArgumentException
     301     *
     302     * @return void
    218303     */
    219304    public function setPsr4($prefix, $paths)
     
    235320     *
    236321     * @param bool $useIncludePath
     322     *
     323     * @return void
    237324     */
    238325    public function setUseIncludePath($useIncludePath)
     
    257344     *
    258345     * @param bool $classMapAuthoritative
     346     *
     347     * @return void
    259348     */
    260349    public function setClassMapAuthoritative($classMapAuthoritative)
     
    277366     *
    278367     * @param string|null $apcuPrefix
     368     *
     369     * @return void
    279370     */
    280371    public function setApcuPrefix($apcuPrefix)
     
    297388     *
    298389     * @param bool $prepend Whether to prepend the autoloader or not
     390     *
     391     * @return void
    299392     */
    300393    public function register($prepend = false)
    301394    {
    302395        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
     396
     397        if (null === $this->vendorDir) {
     398            return;
     399        }
     400
     401        if ($prepend) {
     402            self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
     403        } else {
     404            unset(self::$registeredLoaders[$this->vendorDir]);
     405            self::$registeredLoaders[$this->vendorDir] = $this;
     406        }
    303407    }
    304408
    305409    /**
    306410     * Unregisters this instance as an autoloader.
     411     *
     412     * @return void
    307413     */
    308414    public function unregister()
    309415    {
    310416        spl_autoload_unregister(array($this, 'loadClass'));
     417
     418        if (null !== $this->vendorDir) {
     419            unset(self::$registeredLoaders[$this->vendorDir]);
     420        }
    311421    }
    312422
     
    315425     *
    316426     * @param  string    $class The name of the class
    317      * @return bool|null True if loaded, null otherwise
     427     * @return true|null True if loaded, null otherwise
    318428     */
    319429    public function loadClass($class)
    320430    {
    321431        if ($file = $this->findFile($class)) {
    322             includeFile($file);
     432            $includeFile = self::$includeFile;
     433            $includeFile($file);
    323434
    324435            return true;
    325436        }
     437
     438        return null;
    326439    }
    327440
     
    368481    }
    369482
     483    /**
     484     * Returns the currently registered loaders indexed by their corresponding vendor directories.
     485     *
     486     * @return self[]
     487     */
     488    public static function getRegisteredLoaders()
     489    {
     490        return self::$registeredLoaders;
     491    }
     492
     493    /**
     494     * @param  string       $class
     495     * @param  string       $ext
     496     * @return string|false
     497     */
    370498    private function findFileWithExtension($class, $ext)
    371499    {
     
    433561        return false;
    434562    }
     563
     564    /**
     565     * @return void
     566     */
     567    private static function initializeIncludeClosure()
     568    {
     569        if (self::$includeFile !== null) {
     570            return;
     571        }
     572
     573        /**
     574         * Scope isolated include.
     575         *
     576         * Prevents access to $this/self from included files.
     577         *
     578         * @param  string $file
     579         * @return void
     580         */
     581        self::$includeFile = \Closure::bind(static function($file) {
     582            include $file;
     583        }, null, null);
     584    }
    435585}
    436 
    437 /**
    438  * Scope isolated include.
    439  *
    440  * Prevents access to $this/self from included files.
    441  */
    442 function includeFile($file)
    443 {
    444     include $file;
    445 }
  • ship-to-ecourier/trunk/vendor/composer/InstalledVersions.php

    r2527180 r2894437  
    11<?php
    22
    3 
    4 
    5 
    6 
    7 
    8 
    9 
    10 
    11 
     3/*
     4 * This file is part of Composer.
     5 *
     6 * (c) Nils Adermann <naderman@naderman.de>
     7 *     Jordi Boggiano <j.boggiano@seld.be>
     8 *
     9 * For the full copyright and license information, please view the LICENSE
     10 * file that was distributed with this source code.
     11 */
    1212
    1313namespace Composer;
    1414
     15use Composer\Autoload\ClassLoader;
    1516use Composer\Semver\VersionParser;
    1617
    17 
    18 
    19 
    20 
    21 
     18/**
     19 * This class is copied in every Composer installed project and available to all
     20 *
     21 * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
     22 *
     23 * To require its presence, you can require `composer-runtime-api ^2.0`
     24 *
     25 * @final
     26 */
    2227class InstalledVersions
    2328{
    24 private static $installed = array (
    25   'root' =>
    26   array (
    27     'pretty_version' => 'dev-master',
    28     'version' => 'dev-master',
    29     'aliases' =>
    30     array (
    31     ),
    32     'reference' => '1ef747b756c8fbab66af71841f05497b44b3f959',
    33     'name' => 'simongomes/ship-to-ecourier',
    34   ),
    35   'versions' =>
    36   array (
    37     'appsero/client' =>
    38     array (
    39       'pretty_version' => 'dev-develop',
    40       'version' => 'dev-develop',
    41       'aliases' =>
    42       array (
    43         0 => '9999999-dev',
    44       ),
    45       'reference' => 'd631da21bccbd0a4ea752cd3b827889883f378af',
    46     ),
    47     'simongomes/ship-to-ecourier' =>
    48     array (
    49       'pretty_version' => 'dev-master',
    50       'version' => 'dev-master',
    51       'aliases' =>
    52       array (
    53       ),
    54       'reference' => '1ef747b756c8fbab66af71841f05497b44b3f959',
    55     ),
    56   ),
    57 );
    58 
    59 
    60 
    61 
    62 
    63 
    64 
    65 public static function getInstalledPackages()
    66 {
    67 return array_keys(self::$installed['versions']);
     29    /**
     30     * @var mixed[]|null
     31     * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
     32     */
     33    private static $installed;
     34
     35    /**
     36     * @var bool|null
     37     */
     38    private static $canGetVendors;
     39
     40    /**
     41     * @var array[]
     42     * @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
     43     */
     44    private static $installedByVendor = array();
     45
     46    /**
     47     * Returns a list of all package names which are present, either by being installed, replaced or provided
     48     *
     49     * @return string[]
     50     * @psalm-return list<string>
     51     */
     52    public static function getInstalledPackages()
     53    {
     54        $packages = array();
     55        foreach (self::getInstalled() as $installed) {
     56            $packages[] = array_keys($installed['versions']);
     57        }
     58
     59        if (1 === \count($packages)) {
     60            return $packages[0];
     61        }
     62
     63        return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
     64    }
     65
     66    /**
     67     * Returns a list of all package names with a specific type e.g. 'library'
     68     *
     69     * @param  string   $type
     70     * @return string[]
     71     * @psalm-return list<string>
     72     */
     73    public static function getInstalledPackagesByType($type)
     74    {
     75        $packagesByType = array();
     76
     77        foreach (self::getInstalled() as $installed) {
     78            foreach ($installed['versions'] as $name => $package) {
     79                if (isset($package['type']) && $package['type'] === $type) {
     80                    $packagesByType[] = $name;
     81                }
     82            }
     83        }
     84
     85        return $packagesByType;
     86    }
     87
     88    /**
     89     * Checks whether the given package is installed
     90     *
     91     * This also returns true if the package name is provided or replaced by another package
     92     *
     93     * @param  string $packageName
     94     * @param  bool   $includeDevRequirements
     95     * @return bool
     96     */
     97    public static function isInstalled($packageName, $includeDevRequirements = true)
     98    {
     99        foreach (self::getInstalled() as $installed) {
     100            if (isset($installed['versions'][$packageName])) {
     101                return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
     102            }
     103        }
     104
     105        return false;
     106    }
     107
     108    /**
     109     * Checks whether the given package satisfies a version constraint
     110     *
     111     * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
     112     *
     113     *   Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
     114     *
     115     * @param  VersionParser $parser      Install composer/semver to have access to this class and functionality
     116     * @param  string        $packageName
     117     * @param  string|null   $constraint  A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
     118     * @return bool
     119     */
     120    public static function satisfies(VersionParser $parser, $packageName, $constraint)
     121    {
     122        $constraint = $parser->parseConstraints((string) $constraint);
     123        $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
     124
     125        return $provided->matches($constraint);
     126    }
     127
     128    /**
     129     * Returns a version constraint representing all the range(s) which are installed for a given package
     130     *
     131     * It is easier to use this via isInstalled() with the $constraint argument if you need to check
     132     * whether a given version of a package is installed, and not just whether it exists
     133     *
     134     * @param  string $packageName
     135     * @return string Version constraint usable with composer/semver
     136     */
     137    public static function getVersionRanges($packageName)
     138    {
     139        foreach (self::getInstalled() as $installed) {
     140            if (!isset($installed['versions'][$packageName])) {
     141                continue;
     142            }
     143
     144            $ranges = array();
     145            if (isset($installed['versions'][$packageName]['pretty_version'])) {
     146                $ranges[] = $installed['versions'][$packageName]['pretty_version'];
     147            }
     148            if (array_key_exists('aliases', $installed['versions'][$packageName])) {
     149                $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
     150            }
     151            if (array_key_exists('replaced', $installed['versions'][$packageName])) {
     152                $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
     153            }
     154            if (array_key_exists('provided', $installed['versions'][$packageName])) {
     155                $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
     156            }
     157
     158            return implode(' || ', $ranges);
     159        }
     160
     161        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
     162    }
     163
     164    /**
     165     * @param  string      $packageName
     166     * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
     167     */
     168    public static function getVersion($packageName)
     169    {
     170        foreach (self::getInstalled() as $installed) {
     171            if (!isset($installed['versions'][$packageName])) {
     172                continue;
     173            }
     174
     175            if (!isset($installed['versions'][$packageName]['version'])) {
     176                return null;
     177            }
     178
     179            return $installed['versions'][$packageName]['version'];
     180        }
     181
     182        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
     183    }
     184
     185    /**
     186     * @param  string      $packageName
     187     * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
     188     */
     189    public static function getPrettyVersion($packageName)
     190    {
     191        foreach (self::getInstalled() as $installed) {
     192            if (!isset($installed['versions'][$packageName])) {
     193                continue;
     194            }
     195
     196            if (!isset($installed['versions'][$packageName]['pretty_version'])) {
     197                return null;
     198            }
     199
     200            return $installed['versions'][$packageName]['pretty_version'];
     201        }
     202
     203        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
     204    }
     205
     206    /**
     207     * @param  string      $packageName
     208     * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
     209     */
     210    public static function getReference($packageName)
     211    {
     212        foreach (self::getInstalled() as $installed) {
     213            if (!isset($installed['versions'][$packageName])) {
     214                continue;
     215            }
     216
     217            if (!isset($installed['versions'][$packageName]['reference'])) {
     218                return null;
     219            }
     220
     221            return $installed['versions'][$packageName]['reference'];
     222        }
     223
     224        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
     225    }
     226
     227    /**
     228     * @param  string      $packageName
     229     * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
     230     */
     231    public static function getInstallPath($packageName)
     232    {
     233        foreach (self::getInstalled() as $installed) {
     234            if (!isset($installed['versions'][$packageName])) {
     235                continue;
     236            }
     237
     238            return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
     239        }
     240
     241        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
     242    }
     243
     244    /**
     245     * @return array
     246     * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
     247     */
     248    public static function getRootPackage()
     249    {
     250        $installed = self::getInstalled();
     251
     252        return $installed[0]['root'];
     253    }
     254
     255    /**
     256     * Returns the raw installed.php data for custom implementations
     257     *
     258     * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
     259     * @return array[]
     260     * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
     261     */
     262    public static function getRawData()
     263    {
     264        @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
     265
     266        if (null === self::$installed) {
     267            // only require the installed.php file if this file is loaded from its dumped location,
     268            // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
     269            if (substr(__DIR__, -8, 1) !== 'C') {
     270                self::$installed = include __DIR__ . '/installed.php';
     271            } else {
     272                self::$installed = array();
     273            }
     274        }
     275
     276        return self::$installed;
     277    }
     278
     279    /**
     280     * Returns the raw data of all installed.php which are currently loaded for custom implementations
     281     *
     282     * @return array[]
     283     * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
     284     */
     285    public static function getAllRawData()
     286    {
     287        return self::getInstalled();
     288    }
     289
     290    /**
     291     * Lets you reload the static array from another file
     292     *
     293     * This is only useful for complex integrations in which a project needs to use
     294     * this class but then also needs to execute another project's autoloader in process,
     295     * and wants to ensure both projects have access to their version of installed.php.
     296     *
     297     * A typical case would be PHPUnit, where it would need to make sure it reads all
     298     * the data it needs from this class, then call reload() with
     299     * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
     300     * the project in which it runs can then also use this class safely, without
     301     * interference between PHPUnit's dependencies and the project's dependencies.
     302     *
     303     * @param  array[] $data A vendor/composer/installed.php data set
     304     * @return void
     305     *
     306     * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
     307     */
     308    public static function reload($data)
     309    {
     310        self::$installed = $data;
     311        self::$installedByVendor = array();
     312    }
     313
     314    /**
     315     * @return array[]
     316     * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
     317     */
     318    private static function getInstalled()
     319    {
     320        if (null === self::$canGetVendors) {
     321            self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
     322        }
     323
     324        $installed = array();
     325
     326        if (self::$canGetVendors) {
     327            foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
     328                if (isset(self::$installedByVendor[$vendorDir])) {
     329                    $installed[] = self::$installedByVendor[$vendorDir];
     330                } elseif (is_file($vendorDir.'/composer/installed.php')) {
     331                    /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
     332                    $required = require $vendorDir.'/composer/installed.php';
     333                    $installed[] = self::$installedByVendor[$vendorDir] = $required;
     334                    if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
     335                        self::$installed = $installed[count($installed) - 1];
     336                    }
     337                }
     338            }
     339        }
     340
     341        if (null === self::$installed) {
     342            // only require the installed.php file if this file is loaded from its dumped location,
     343            // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
     344            if (substr(__DIR__, -8, 1) !== 'C') {
     345                /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
     346                $required = require __DIR__ . '/installed.php';
     347                self::$installed = $required;
     348            } else {
     349                self::$installed = array();
     350            }
     351        }
     352
     353        if (self::$installed !== array()) {
     354            $installed[] = self::$installed;
     355        }
     356
     357        return $installed;
     358    }
    68359}
    69 
    70 
    71 
    72 
    73 
    74 
    75 
    76 
    77 
    78 public static function isInstalled($packageName)
    79 {
    80 return isset(self::$installed['versions'][$packageName]);
    81 }
    82 
    83 
    84 
    85 
    86 
    87 
    88 
    89 
    90 
    91 
    92 
    93 
    94 
    95 
    96 public static function satisfies(VersionParser $parser, $packageName, $constraint)
    97 {
    98 $constraint = $parser->parseConstraints($constraint);
    99 $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
    100 
    101 return $provided->matches($constraint);
    102 }
    103 
    104 
    105 
    106 
    107 
    108 
    109 
    110 
    111 
    112 
    113 public static function getVersionRanges($packageName)
    114 {
    115 if (!isset(self::$installed['versions'][$packageName])) {
    116 throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
    117 }
    118 
    119 $ranges = array();
    120 if (isset(self::$installed['versions'][$packageName]['pretty_version'])) {
    121 $ranges[] = self::$installed['versions'][$packageName]['pretty_version'];
    122 }
    123 if (array_key_exists('aliases', self::$installed['versions'][$packageName])) {
    124 $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']);
    125 }
    126 if (array_key_exists('replaced', self::$installed['versions'][$packageName])) {
    127 $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']);
    128 }
    129 if (array_key_exists('provided', self::$installed['versions'][$packageName])) {
    130 $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']);
    131 }
    132 
    133 return implode(' || ', $ranges);
    134 }
    135 
    136 
    137 
    138 
    139 
    140 public static function getVersion($packageName)
    141 {
    142 if (!isset(self::$installed['versions'][$packageName])) {
    143 throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
    144 }
    145 
    146 if (!isset(self::$installed['versions'][$packageName]['version'])) {
    147 return null;
    148 }
    149 
    150 return self::$installed['versions'][$packageName]['version'];
    151 }
    152 
    153 
    154 
    155 
    156 
    157 public static function getPrettyVersion($packageName)
    158 {
    159 if (!isset(self::$installed['versions'][$packageName])) {
    160 throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
    161 }
    162 
    163 if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) {
    164 return null;
    165 }
    166 
    167 return self::$installed['versions'][$packageName]['pretty_version'];
    168 }
    169 
    170 
    171 
    172 
    173 
    174 public static function getReference($packageName)
    175 {
    176 if (!isset(self::$installed['versions'][$packageName])) {
    177 throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
    178 }
    179 
    180 if (!isset(self::$installed['versions'][$packageName]['reference'])) {
    181 return null;
    182 }
    183 
    184 return self::$installed['versions'][$packageName]['reference'];
    185 }
    186 
    187 
    188 
    189 
    190 
    191 public static function getRootPackage()
    192 {
    193 return self::$installed['root'];
    194 }
    195 
    196 
    197 
    198 
    199 
    200 
    201 
    202 public static function getRawData()
    203 {
    204 return self::$installed;
    205 }
    206 
    207 
    208 
    209 
    210 
    211 
    212 
    213 
    214 
    215 
    216 
    217 
    218 
    219 
    220 
    221 
    222 
    223 
    224 
    225 public static function reload($data)
    226 {
    227 self::$installed = $data;
    228 }
    229 }
  • ship-to-ecourier/trunk/vendor/composer/autoload_classmap.php

    r2525816 r2894437  
    33// autoload_classmap.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • ship-to-ecourier/trunk/vendor/composer/autoload_files.php

    r2525816 r2894437  
    33// autoload_files.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • ship-to-ecourier/trunk/vendor/composer/autoload_namespaces.php

    r2525816 r2894437  
    33// autoload_namespaces.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • ship-to-ecourier/trunk/vendor/composer/autoload_psr4.php

    r2527180 r2894437  
    33// autoload_psr4.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • ship-to-ecourier/trunk/vendor/composer/autoload_real.php

    r2527180 r2894437  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit623e2aa6265ae73da9cc7e7f68ee232a
     5class ComposerAutoloaderInit55922fb54980b576755edaecda902c54
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit623e2aa6265ae73da9cc7e7f68ee232a', 'loadClassLoader'), true, true);
    28         self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    29         spl_autoload_unregister(array('ComposerAutoloaderInit623e2aa6265ae73da9cc7e7f68ee232a', 'loadClassLoader'));
     27        spl_autoload_register(array('ComposerAutoloaderInit55922fb54980b576755edaecda902c54', 'loadClassLoader'), true, true);
     28        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit55922fb54980b576755edaecda902c54', 'loadClassLoader'));
    3030
    31         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
    32         if ($useStaticLoader) {
    33             require __DIR__ . '/autoload_static.php';
    34 
    35             call_user_func(\Composer\Autoload\ComposerStaticInit623e2aa6265ae73da9cc7e7f68ee232a::getInitializer($loader));
    36         } else {
    37             $map = require __DIR__ . '/autoload_namespaces.php';
    38             foreach ($map as $namespace => $path) {
    39                 $loader->set($namespace, $path);
    40             }
    41 
    42             $map = require __DIR__ . '/autoload_psr4.php';
    43             foreach ($map as $namespace => $path) {
    44                 $loader->setPsr4($namespace, $path);
    45             }
    46 
    47             $classMap = require __DIR__ . '/autoload_classmap.php';
    48             if ($classMap) {
    49                 $loader->addClassMap($classMap);
    50             }
    51         }
     31        require __DIR__ . '/autoload_static.php';
     32        call_user_func(\Composer\Autoload\ComposerStaticInit55922fb54980b576755edaecda902c54::getInitializer($loader));
    5233
    5334        $loader->register(true);
    5435
    55         if ($useStaticLoader) {
    56             $includeFiles = Composer\Autoload\ComposerStaticInit623e2aa6265ae73da9cc7e7f68ee232a::$files;
    57         } else {
    58             $includeFiles = require __DIR__ . '/autoload_files.php';
    59         }
    60         foreach ($includeFiles as $fileIdentifier => $file) {
    61             composerRequire623e2aa6265ae73da9cc7e7f68ee232a($fileIdentifier, $file);
     36        $filesToLoad = \Composer\Autoload\ComposerStaticInit55922fb54980b576755edaecda902c54::$files;
     37        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
     38            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
     39                $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
     40
     41                require $file;
     42            }
     43        }, null, null);
     44        foreach ($filesToLoad as $fileIdentifier => $file) {
     45            $requireFile($fileIdentifier, $file);
    6246        }
    6347
     
    6549    }
    6650}
    67 
    68 function composerRequire623e2aa6265ae73da9cc7e7f68ee232a($fileIdentifier, $file)
    69 {
    70     if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
    71         require $file;
    72 
    73         $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
    74     }
    75 }
  • ship-to-ecourier/trunk/vendor/composer/autoload_static.php

    r2527180 r2894437  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit623e2aa6265ae73da9cc7e7f68ee232a
     7class ComposerStaticInit55922fb54980b576755edaecda902c54
    88{
    99    public static $files = array (
     
    4040    {
    4141        return \Closure::bind(function () use ($loader) {
    42             $loader->prefixLengthsPsr4 = ComposerStaticInit623e2aa6265ae73da9cc7e7f68ee232a::$prefixLengthsPsr4;
    43             $loader->prefixDirsPsr4 = ComposerStaticInit623e2aa6265ae73da9cc7e7f68ee232a::$prefixDirsPsr4;
    44             $loader->classMap = ComposerStaticInit623e2aa6265ae73da9cc7e7f68ee232a::$classMap;
     42            $loader->prefixLengthsPsr4 = ComposerStaticInit55922fb54980b576755edaecda902c54::$prefixLengthsPsr4;
     43            $loader->prefixDirsPsr4 = ComposerStaticInit55922fb54980b576755edaecda902c54::$prefixDirsPsr4;
     44            $loader->classMap = ComposerStaticInit55922fb54980b576755edaecda902c54::$classMap;
    4545
    4646        }, null, ClassLoader::class);
  • ship-to-ecourier/trunk/vendor/composer/installed.json

    r2527180 r2894437  
    2222            "default-branch": true,
    2323            "type": "library",
    24             "installation-source": "source",
     24            "installation-source": "dist",
    2525            "autoload": {
    2626                "psr-4": {
  • ship-to-ecourier/trunk/vendor/composer/installed.php

    r2527180 r2894437  
    1 <?php return array (
    2   'root' =>
    3   array (
    4     'pretty_version' => 'dev-master',
    5     'version' => 'dev-master',
    6     'aliases' =>
    7     array (
     1<?php return array(
     2    'root' => array(
     3        'name' => 'simongomes/ship-to-ecourier',
     4        'pretty_version' => 'dev-master',
     5        'version' => 'dev-master',
     6        'reference' => '7b6fc0329290a128434d1e42f1790857dccee2e9',
     7        'type' => 'wordpress-plugin',
     8        'install_path' => __DIR__ . '/../../',
     9        'aliases' => array(),
     10        'dev' => true,
    811    ),
    9     'reference' => '1ef747b756c8fbab66af71841f05497b44b3f959',
    10     'name' => 'simongomes/ship-to-ecourier',
    11   ),
    12   'versions' =>
    13   array (
    14     'appsero/client' =>
    15     array (
    16       'pretty_version' => 'dev-develop',
    17       'version' => 'dev-develop',
    18       'aliases' =>
    19       array (
    20         0 => '9999999-dev',
    21       ),
    22       'reference' => 'd631da21bccbd0a4ea752cd3b827889883f378af',
     12    'versions' => array(
     13        'appsero/client' => array(
     14            'pretty_version' => 'dev-develop',
     15            'version' => 'dev-develop',
     16            'reference' => 'd631da21bccbd0a4ea752cd3b827889883f378af',
     17            'type' => 'library',
     18            'install_path' => __DIR__ . '/../appsero/client',
     19            'aliases' => array(
     20                0 => '9999999-dev',
     21            ),
     22            'dev_requirement' => false,
     23        ),
     24        'simongomes/ship-to-ecourier' => array(
     25            'pretty_version' => 'dev-master',
     26            'version' => 'dev-master',
     27            'reference' => '7b6fc0329290a128434d1e42f1790857dccee2e9',
     28            'type' => 'wordpress-plugin',
     29            'install_path' => __DIR__ . '/../../',
     30            'aliases' => array(),
     31            'dev_requirement' => false,
     32        ),
    2333    ),
    24     'simongomes/ship-to-ecourier' =>
    25     array (
    26       'pretty_version' => 'dev-master',
    27       'version' => 'dev-master',
    28       'aliases' =>
    29       array (
    30       ),
    31       'reference' => '1ef747b756c8fbab66af71841f05497b44b3f959',
    32     ),
    33   ),
    3434);
Note: See TracChangeset for help on using the changeset viewer.