Plugin Directory

Changeset 3428340


Ignore:
Timestamp:
12/27/2025 05:46:51 PM (3 months ago)
Author:
withflex
Message:

Add 3.2.1

Location:
pay-with-flex/trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • pay-with-flex/trunk/composer.json

    r3427514 r3428340  
    22    "type": "wordpress-plugin",
    33    "require": {
     4        "php": ">=8.1",
    45        "symfony/polyfill-php84": ">=1.31",
    56        "sentry/sentry": ">=4.11"
     
    1415            "Flex\\": "src"
    1516        },
    16         "files": ["includes/functions.php"]
     17        "files": [
     18            "includes/functions.php"
     19        ]
    1720    },
    1821    "autoload-dev": {
     
    2528    },
    2629    "config": {
    27         "optimize-autoloader": true
     30        "optimize-autoloader": true,
     31        "platform": {
     32            "php": "8.1.34"
     33        }
    2834    }
    2935}
  • pay-with-flex/trunk/composer.lock

    r3427514 r3428340  
    55        "This file is @generated automatically"
    66    ],
    7     "content-hash": "400fe045e9fce44650d89f3d72a1981a",
     7    "content-hash": "f720d3c2e1d29922303b6c6cd82eb01a",
    88    "packages": [
    99        {
     
    542542        {
    543543            "name": "symfony/options-resolver",
    544             "version": "v8.0.0",
     544            "version": "v6.4.30",
    545545            "source": {
    546546                "type": "git",
    547547                "url": "https://github.com/symfony/options-resolver.git",
    548                 "reference": "d2b592535ffa6600c265a3893a7f7fd2bad82dd7"
    549             },
    550             "dist": {
    551                 "type": "zip",
    552                 "url": "https://api.github.com/repos/symfony/options-resolver/zipball/d2b592535ffa6600c265a3893a7f7fd2bad82dd7",
    553                 "reference": "d2b592535ffa6600c265a3893a7f7fd2bad82dd7",
    554                 "shasum": ""
    555             },
    556             "require": {
    557                 "php": ">=8.4",
     548                "reference": "eeaa8cabe54c7b3516938c72a4a161c0cc80a34f"
     549            },
     550            "dist": {
     551                "type": "zip",
     552                "url": "https://api.github.com/repos/symfony/options-resolver/zipball/eeaa8cabe54c7b3516938c72a4a161c0cc80a34f",
     553                "reference": "eeaa8cabe54c7b3516938c72a4a161c0cc80a34f",
     554                "shasum": ""
     555            },
     556            "require": {
     557                "php": ">=8.1",
    558558                "symfony/deprecation-contracts": "^2.5|^3"
    559559            },
     
    589589            ],
    590590            "support": {
    591                 "source": "https://github.com/symfony/options-resolver/tree/v8.0.0"
     591                "source": "https://github.com/symfony/options-resolver/tree/v6.4.30"
    592592            },
    593593            "funding": [
     
    609609                }
    610610            ],
    611             "time": "2025-11-12T15:55:31+00:00"
     611            "time": "2025-11-12T13:06:53+00:00"
    612612        },
    613613        {
     
    26072607    "prefer-stable": false,
    26082608    "prefer-lowest": false,
    2609     "platform": {},
     2609    "platform": {
     2610        "php": ">=8.1"
     2611    },
    26102612    "platform-dev": {},
     2613    "platform-overrides": {
     2614        "php": "8.1.34"
     2615    },
    26112616    "plugin-api-version": "2.6.0"
    26122617}
  • pay-with-flex/trunk/pay-with-flex.php

    r3427514 r3428340  
    44 * Plugin Name:      Flex HSA/FSA Payments
    55 * Description:      Accept HSA/FSA payments directly in the checkout flow.
    6  * Version:          3.2.0
     6 * Version:          3.2.1
    77 * Plugin URI:       https://wordpress.org/plugins/pay-with-flex/
    88 * Author:           Flex
  • pay-with-flex/trunk/readme.txt

    r3427514 r3428340  
    44Requires at least: 6.7
    55Tested up to: 6.9
    6 Stable tag: 3.1.18
     6Stable tag: 3.2.1
    77Requires PHP: 8.1
    88License: GPLv3 or later
     
    5555
    5656== Changelog ==
     57
     58= 3.2.1 =
     59* Fixed a memory leak when a checkout session is created multiple times.
    5760
    5861= 3.2.0 =
  • pay-with-flex/trunk/src/Resource/CheckoutSession/LineItem.php

    r3427514 r3428340  
    99namespace Flex\Resource\CheckoutSession;
    1010
     11use Automattic\WooCommerce\Enums\OrderStatus;
    1112use Flex\Resource\Price;
    1213use Flex\Resource\Resource;
     
    7677     */
    7778    public static function from_wc( \WC_Order_Item_Product $item ): self {
    78         // If the order has a transaction id, the checkout session was completed
    79         // and the price id is fixed.
    80         if ( $item->get_order()->get_transaction_id() && $item->meta_exists( self::META_PREFIX . self::KEY_PRICE ) ) {
    81             $price = new Price( id: $item->get_meta( self::META_PREFIX . self::KEY_PRICE ) );
    82         } else {
    83             $price = Price::from_wc_item( $item );
     79        // For non-pending orders with stored metadata, pass the stored price ID.
     80        // This ensures refunds reference the correct price.
     81        $stored_id = null;
     82        $meta_key  = self::META_PREFIX . self::KEY_PRICE;
     83        if ( OrderStatus::PENDING !== $item->get_order()->get_status() && $item->meta_exists( $meta_key ) ) {
     84            $stored_id = $item->get_meta( $meta_key );
    8485        }
    85         $line_item     = new self( price: $price, quantity: $item->get_quantity() );
     86        $line_item     = new self( price: Price::from_wc_item( $item, $stored_id ), quantity: $item->get_quantity() );
    8687        $line_item->wc = $item;
    8788        return $line_item;
  • pay-with-flex/trunk/src/Resource/Price.php

    r3427514 r3428340  
    100100     *
    101101     * @param \WC_Order_Item_Product $item The WooCommerce Order Item.
    102      */
    103     public static function from_wc_item( \WC_Order_Item_Product $item ): self {
     102     * @param ?string                $id   Optional price ID from stored metadata.
     103     */
     104    public static function from_wc_item( \WC_Order_Item_Product $item, ?string $id = null ): self {
    104105        $product  = $item->get_product();
    105106        $quantity = $item->get_quantity();
     
    108109        $actual_total   = self::currency_to_unit_amount( $item->get_subtotal() );
    109110        $price          = self::from_wc( $product );
     111        // Use the provided ID if present (from stored metadata).
     112        if ( null !== $id ) {
     113            $price->id = $id;
     114        }
    110115        // If prices match, use the standard product-based price.
    111116        if ( $expected_total === $actual_total ) {
    112117            return $price;
    113118        }
    114         return new self( product: $price->product, description: $item->get_name(), unit_amount: $actual_total / $quantity, hsa_fsa_eligibility: $price->hsa_fsa_eligibility );
     119        return new self(
     120            product: $price->product,
     121            id: $price->id,
     122            // Preserve stored ID if present.
     123            description: $item->get_name(),
     124            unit_amount: $actual_total / $quantity,
     125            hsa_fsa_eligibility: $price->hsa_fsa_eligibility
     126        );
    115127    }
    116128    /**
  • pay-with-flex/trunk/vendor/autoload.php

    r3427514 r3428340  
    2020require_once __DIR__ . '/composer/autoload_real.php';
    2121
    22 return ComposerAutoloaderInit400fe045e9fce44650d89f3d72a1981a::getLoader();
     22return ComposerAutoloaderInitf720d3c2e1d29922303b6c6cd82eb01a::getLoader();
  • pay-with-flex/trunk/vendor/composer/autoload_real.php

    r3427514 r3428340  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit400fe045e9fce44650d89f3d72a1981a
     5class ComposerAutoloaderInitf720d3c2e1d29922303b6c6cd82eb01a
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit400fe045e9fce44650d89f3d72a1981a', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitf720d3c2e1d29922303b6c6cd82eb01a', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit400fe045e9fce44650d89f3d72a1981a', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitf720d3c2e1d29922303b6c6cd82eb01a', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInit400fe045e9fce44650d89f3d72a1981a::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInitf720d3c2e1d29922303b6c6cd82eb01a::getInitializer($loader));
    3333
    3434        $loader->register(true);
    3535
    36         $filesToLoad = \Composer\Autoload\ComposerStaticInit400fe045e9fce44650d89f3d72a1981a::$files;
     36        $filesToLoad = \Composer\Autoload\ComposerStaticInitf720d3c2e1d29922303b6c6cd82eb01a::$files;
    3737        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3838            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • pay-with-flex/trunk/vendor/composer/autoload_static.php

    r3427514 r3428340  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit400fe045e9fce44650d89f3d72a1981a
     7class ComposerStaticInitf720d3c2e1d29922303b6c6cd82eb01a
    88{
    99    public static $files = array (
     
    302302    {
    303303        return \Closure::bind(function () use ($loader) {
    304             $loader->prefixLengthsPsr4 = ComposerStaticInit400fe045e9fce44650d89f3d72a1981a::$prefixLengthsPsr4;
    305             $loader->prefixDirsPsr4 = ComposerStaticInit400fe045e9fce44650d89f3d72a1981a::$prefixDirsPsr4;
    306             $loader->classMap = ComposerStaticInit400fe045e9fce44650d89f3d72a1981a::$classMap;
     304            $loader->prefixLengthsPsr4 = ComposerStaticInitf720d3c2e1d29922303b6c6cd82eb01a::$prefixLengthsPsr4;
     305            $loader->prefixDirsPsr4 = ComposerStaticInitf720d3c2e1d29922303b6c6cd82eb01a::$prefixDirsPsr4;
     306            $loader->classMap = ComposerStaticInitf720d3c2e1d29922303b6c6cd82eb01a::$classMap;
    307307
    308308        }, null, ClassLoader::class);
  • pay-with-flex/trunk/vendor/composer/installed.json

    r3427514 r3428340  
    560560        {
    561561            "name": "symfony\/options-resolver",
    562             "version": "v8.0.0",
    563             "version_normalized": "8.0.0.0",
     562            "version": "v6.4.30",
     563            "version_normalized": "6.4.30.0",
    564564            "source": {
    565565                "type": "git",
    566566                "url": "https:\/\/github.com\/symfony\/options-resolver.git",
    567                 "reference": "d2b592535ffa6600c265a3893a7f7fd2bad82dd7"
    568             },
    569             "dist": {
    570                 "type": "zip",
    571                 "url": "https:\/\/api.github.com\/repos\/symfony\/options-resolver\/zipball\/d2b592535ffa6600c265a3893a7f7fd2bad82dd7",
    572                 "reference": "d2b592535ffa6600c265a3893a7f7fd2bad82dd7",
    573                 "shasum": ""
    574             },
    575             "require": {
    576                 "php": ">=8.4",
     567                "reference": "eeaa8cabe54c7b3516938c72a4a161c0cc80a34f"
     568            },
     569            "dist": {
     570                "type": "zip",
     571                "url": "https:\/\/api.github.com\/repos\/symfony\/options-resolver\/zipball\/eeaa8cabe54c7b3516938c72a4a161c0cc80a34f",
     572                "reference": "eeaa8cabe54c7b3516938c72a4a161c0cc80a34f",
     573                "shasum": ""
     574            },
     575            "require": {
     576                "php": ">=8.1",
    577577                "symfony\/deprecation-contracts": "^2.5|^3"
    578578            },
    579             "time": "2025-11-12T15:55:31+00:00",
     579            "time": "2025-11-12T13:06:53+00:00",
    580580            "type": "library",
    581581            "installation-source": "dist",
     
    610610            ],
    611611            "support": {
    612                 "source": "https:\/\/github.com\/symfony\/options-resolver\/tree\/v8.0.0"
     612                "source": "https:\/\/github.com\/symfony\/options-resolver\/tree\/v6.4.30"
    613613            },
    614614            "funding": [
  • pay-with-flex/trunk/vendor/composer/installed.php

    r3427514 r3428340  
    33namespace Flex;
    44
    5 return array('root' => array('name' => '__root__', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '64e52af59652cf3a0461591681440deb601bb9ef', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \false), 'versions' => array('__root__' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '64e52af59652cf3a0461591681440deb601bb9ef', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/psr7' => array('pretty_version' => '2.8.0', 'version' => '2.8.0.0', 'reference' => '21dc724a0583619cd1652f673303492272778051', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), 'dev_requirement' => \false), 'jean85/pretty-package-versions' => array('pretty_version' => '2.1.1', 'version' => '2.1.1.0', 'reference' => '4d7aa5dab42e2a76d99559706022885de0e18e1a', 'type' => 'library', 'install_path' => __DIR__ . '/../jean85/pretty-package-versions', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-factory' => array('pretty_version' => '1.1.0', 'version' => '1.1.0.0', 'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-factory', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-factory-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-message' => array('pretty_version' => '2.0', 'version' => '2.0.0.0', 'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-message', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-message-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/log' => array('pretty_version' => '3.0.2', 'version' => '3.0.2.0', 'reference' => 'f16e1d5863e37f8d8c2a01719f5b34baa2b714d3', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'ralouphie/getallheaders' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => '120b605dfeb996808c31b6477290a714d356e822', 'type' => 'library', 'install_path' => __DIR__ . '/../ralouphie/getallheaders', 'aliases' => array(), 'dev_requirement' => \false), 'sentry/sentry' => array('pretty_version' => '4.19.1', 'version' => '4.19.1.0', 'reference' => '1c21d60bebe67c0122335bd3fe977990435af0a3', 'type' => 'library', 'install_path' => __DIR__ . '/../sentry/sentry', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('pretty_version' => 'v3.6.0', 'version' => '3.6.0.0', 'reference' => '63afe740e99a13ba87ec199bb07bbdee937a5b62', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/options-resolver' => array('pretty_version' => 'v8.0.0', 'version' => '8.0.0.0', 'reference' => 'd2b592535ffa6600c265a3893a7f7fd2bad82dd7', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/options-resolver', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/polyfill-php84' => array('pretty_version' => 'v1.33.0', 'version' => '1.33.0.0', 'reference' => 'd8ced4d875142b6a7426000426b8abc631d6b191', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-php84', 'aliases' => array(), 'dev_requirement' => \false)));
     5return array('root' => array('name' => '__root__', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '2a34d9973d22cbe56647992d29c557397af3a745', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \false), 'versions' => array('__root__' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '2a34d9973d22cbe56647992d29c557397af3a745', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/psr7' => array('pretty_version' => '2.8.0', 'version' => '2.8.0.0', 'reference' => '21dc724a0583619cd1652f673303492272778051', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), 'dev_requirement' => \false), 'jean85/pretty-package-versions' => array('pretty_version' => '2.1.1', 'version' => '2.1.1.0', 'reference' => '4d7aa5dab42e2a76d99559706022885de0e18e1a', 'type' => 'library', 'install_path' => __DIR__ . '/../jean85/pretty-package-versions', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-factory' => array('pretty_version' => '1.1.0', 'version' => '1.1.0.0', 'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-factory', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-factory-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-message' => array('pretty_version' => '2.0', 'version' => '2.0.0.0', 'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-message', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-message-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/log' => array('pretty_version' => '3.0.2', 'version' => '3.0.2.0', 'reference' => 'f16e1d5863e37f8d8c2a01719f5b34baa2b714d3', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'ralouphie/getallheaders' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => '120b605dfeb996808c31b6477290a714d356e822', 'type' => 'library', 'install_path' => __DIR__ . '/../ralouphie/getallheaders', 'aliases' => array(), 'dev_requirement' => \false), 'sentry/sentry' => array('pretty_version' => '4.19.1', 'version' => '4.19.1.0', 'reference' => '1c21d60bebe67c0122335bd3fe977990435af0a3', 'type' => 'library', 'install_path' => __DIR__ . '/../sentry/sentry', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('pretty_version' => 'v3.6.0', 'version' => '3.6.0.0', 'reference' => '63afe740e99a13ba87ec199bb07bbdee937a5b62', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/options-resolver' => array('pretty_version' => 'v6.4.30', 'version' => '6.4.30.0', 'reference' => 'eeaa8cabe54c7b3516938c72a4a161c0cc80a34f', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/options-resolver', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/polyfill-php84' => array('pretty_version' => 'v1.33.0', 'version' => '1.33.0.0', 'reference' => 'd8ced4d875142b6a7426000426b8abc631d6b191', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-php84', 'aliases' => array(), 'dev_requirement' => \false)));
  • pay-with-flex/trunk/vendor/composer/platform_check.php

    r3427514 r3428340  
    55$issues = array();
    66
    7 if (!(PHP_VERSION_ID >= 80400)) {
    8     $issues[] = 'Your Composer dependencies require a PHP version ">= 8.4.0". You are running ' . PHP_VERSION . '.';
     7if (!(PHP_VERSION_ID >= 80100)) {
     8    $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
    99}
    1010
  • pay-with-flex/trunk/vendor/scoper-autoload.php

    r3427514 r3428340  
    3030    }
    3131}
    32 humbug_phpscoper_expose_class('ComposerAutoloaderInit400fe045e9fce44650d89f3d72a1981a', 'Flex\ComposerAutoloaderInit400fe045e9fce44650d89f3d72a1981a');
     32humbug_phpscoper_expose_class('ComposerAutoloaderInitf720d3c2e1d29922303b6c6cd82eb01a', 'Flex\ComposerAutoloaderInitf720d3c2e1d29922303b6c6cd82eb01a');
    3333humbug_phpscoper_expose_class('Deprecated', 'Flex\Deprecated');
    3434humbug_phpscoper_expose_class('ReflectionConstant', 'Flex\ReflectionConstant');
  • pay-with-flex/trunk/vendor/symfony/options-resolver/CHANGELOG.md

    r3427514 r3428340  
    11CHANGELOG
    22=========
    3 
    4 8.0
    5 ---
    6 
    7 * Remove support for nested options definition via `setDefault()`, use `setOptions()` instead
    8 
    9 7.3
    10 ---
    11 
    12  * Support union type in `OptionResolver::setAllowedTypes()` method
    13  * Add `OptionsResolver::setOptions()` and `OptionConfigurator::options()` methods
    14  * Deprecate defining nested options via `setDefault()`, use `setOptions()` instead
    153
    1646.4
    175---
    186
    19  * Improve message with full path on invalid type in nested option
     7* Improve message with full path on invalid type in nested option
    208
    2196.3
  • pay-with-flex/trunk/vendor/symfony/options-resolver/Debug/OptionsResolverIntrospector.php

    r3352167 r3428340  
    9090        return ($this->get)('deprecated', $option, \sprintf('No deprecation was set for the "%s" option.', $option));
    9191    }
    92     /**
    93      * @return \Closure[]
    94      *
    95      * @throws NoConfigurationException when no nested option is configured
    96      */
    97     public function getNestedOptions(string $option): array
    98     {
    99         return ($this->get)('nested', $option, \sprintf('No nested option was set for the "%s" option.', $option));
    100     }
    10192}
  • pay-with-flex/trunk/vendor/symfony/options-resolver/OptionConfigurator.php

    r3352167 r3428340  
    1414final class OptionConfigurator
    1515{
    16     public function __construct(private string $name, private OptionsResolver $resolver)
     16    private string $name;
     17    private OptionsResolver $resolver;
     18    public function __construct(string $name, OptionsResolver $resolver)
    1719    {
     20        $this->name = $name;
     21        $this->resolver = $resolver;
    1822        $this->resolver->setDefined($name);
    1923    }
     
    123127        return $this;
    124128    }
    125     /**
    126      * Defines nested options.
    127      *
    128      * @param \Closure(OptionsResolver $resolver, Options $parent): void $nested
    129      *
    130      * @return $this
    131      */
    132     public function options(\Closure $nested): static
    133     {
    134         $this->resolver->setOptions($this->name, $nested);
    135         return $this;
    136     }
    137129}
  • pay-with-flex/trunk/vendor/symfony/options-resolver/OptionsResolver.php

    r3427514 r3428340  
    140140     * sub-classes.
    141141     *
     142     * If you want to define nested options, you can pass a closure with the
     143     * following signature:
     144     *
     145     *     $options->setDefault('database', function (OptionsResolver $resolver) {
     146     *         $resolver->setDefined(['dbname', 'host', 'port', 'user', 'pass']);
     147     *     }
     148     *
     149     * To get access to the parent options, add a second argument to the closure's
     150     * signature:
     151     *
     152     *     function (OptionsResolver $resolver, Options $parent) {
     153     *         // 'default' === $parent['connection']
     154     *     }
     155     *
    142156     * @return $this
    143157     *
     
    169183                $this->lazy[$option][] = $value;
    170184                $this->defined[$option] = \true;
    171                 // Make sure the option is processed
    172                 unset($this->resolved[$option]);
     185                // Make sure the option is processed and is not nested anymore
     186                unset($this->resolved[$option], $this->nested[$option]);
    173187                return $this;
    174188            }
    175         }
    176         // This option is not lazy anymore
    177         unset($this->lazy[$option]);
     189            if (isset($params[0]) && ($type = $params[0]->getType()) instanceof \ReflectionNamedType && self::class === $type->getName() && (!isset($params[1]) || ($type = $params[1]->getType()) instanceof \ReflectionNamedType && Options::class === $type->getName())) {
     190                // Store closure for later evaluation
     191                $this->nested[$option][] = $value;
     192                $this->defaults[$option] = [];
     193                $this->defined[$option] = \true;
     194                // Make sure the option is processed and is not lazy anymore
     195                unset($this->resolved[$option], $this->lazy[$option]);
     196                return $this;
     197            }
     198        }
     199        // This option is not lazy nor nested anymore
     200        unset($this->lazy[$option], $this->nested[$option]);
    178201        // Yet undefined options can be marked as resolved, because we only need
    179202        // to resolve options with lazy closures, normalizers or validation
     
    313336        return array_keys($this->defined);
    314337    }
    315     /**
    316      * Defines nested options.
    317      *
    318      * @param \Closure(self $resolver, Options $parent): void $nested
    319      *
    320      * @return $this
    321      */
    322     public function setOptions(string $option, \Closure $nested): static
    323     {
    324         if ($this->locked) {
    325             throw new AccessException('Nested options cannot be defined from a lazy option or normalizer.');
    326         }
    327         // Store closure for later evaluation
    328         $this->nested[$option][] = $nested;
    329         $this->defaults[$option] = [];
    330         $this->defined[$option] = \true;
    331         // Make sure the option is processed
    332         unset($this->resolved[$option]);
    333         return $this;
    334     }
    335338    public function isNested(string $option): bool
    336339    {
     
    407410     * @throws AccessException           If called from a lazy option or normalizer
    408411     */
    409     public function setNormalizer(string $option, \Closure $normalizer): static
     412    public function setNormalizer(string $option, \Closure $normalizer)
    410413    {
    411414        if ($this->locked) {
     
    481484     * @throws AccessException           If called from a lazy option or normalizer
    482485     */
    483     public function setAllowedValues(string $option, mixed $allowedValues): static
     486    public function setAllowedValues(string $option, mixed $allowedValues)
    484487    {
    485488        if ($this->locked) {
     
    516519     * @throws AccessException           If called from a lazy option or normalizer
    517520     */
    518     public function addAllowedValues(string $option, mixed $allowedValues): static
     521    public function addAllowedValues(string $option, mixed $allowedValues)
    519522    {
    520523        if ($this->locked) {
     
    550553     * @throws AccessException           If called from a lazy option or normalizer
    551554     */
    552     public function setAllowedTypes(string $option, string|array $allowedTypes): static
     555    public function setAllowedTypes(string $option, string|array $allowedTypes)
    553556    {
    554557        if ($this->locked) {
     
    579582     * @throws AccessException           If called from a lazy option or normalizer
    580583     */
    581     public function addAllowedTypes(string $option, string|array $allowedTypes): static
     584    public function addAllowedTypes(string $option, string|array $allowedTypes)
    582585    {
    583586        if ($this->locked) {
     
    795798        }
    796799        $value = $this->defaults[$option];
    797         // Resolve the option if the default value is lazily evaluated
    798         if (isset($this->lazy[$option])) {
    799             // If the closure is already being called, we have a cyclic dependency
    800             if (isset($this->calling[$option])) {
    801                 throw new OptionDefinitionException(\sprintf('The options "%s" have a cyclic dependency.', $this->formatOptions(array_keys($this->calling))));
    802             }
    803             $this->calling[$option] = \true;
    804             try {
    805                 foreach ($this->lazy[$option] as $closure) {
    806                     $value = $closure($this, $value);
    807                 }
    808             } finally {
    809                 unset($this->calling[$option]);
    810             }
    811         }
    812800        // Resolve the option if it is a nested definition
    813801        if (isset($this->nested[$option])) {
     
    819807                throw new InvalidOptionsException(\sprintf('The nested option "%s" with value %s is expected to be of type array, but is of type "%s".', $this->formatOptions([$option]), $this->formatValue($value), get_debug_type($value)));
    820808            }
     809            // The following section must be protected from cyclic calls.
    821810            $this->calling[$option] = \true;
    822811            try {
     
    849838            }
    850839        }
     840        // Resolve the option if the default value is lazily evaluated
     841        if (isset($this->lazy[$option])) {
     842            // If the closure is already being called, we have a cyclic
     843            // dependency
     844            if (isset($this->calling[$option])) {
     845                throw new OptionDefinitionException(\sprintf('The options "%s" have a cyclic dependency.', $this->formatOptions(array_keys($this->calling))));
     846            }
     847            // The following section must be protected from cyclic
     848            // calls. Set $calling for the current $option to detect a cyclic
     849            // dependency
     850            // BEGIN
     851            $this->calling[$option] = \true;
     852            try {
     853                foreach ($this->lazy[$option] as $closure) {
     854                    $value = $closure($this, $value);
     855                }
     856            } finally {
     857                unset($this->calling[$option]);
     858            }
     859            // END
     860        }
    851861        // Validate the type of the resolved option
    852862        if (isset($this->allowedTypes[$option])) {
     
    947957        return $value;
    948958    }
    949     private function verifyTypes(string $type, mixed $value, ?array &$invalidTypes = null, int $level = 0): bool
    950     {
    951         $type = trim($type);
    952         $allowedTypes = $this->splitOutsideParenthesis($type);
    953         if (\count($allowedTypes) > 1) {
    954             foreach ($allowedTypes as $allowedType) {
    955                 if ($this->verifyTypes($allowedType, $value)) {
    956                     return \true;
    957                 }
    958             }
    959             if (\is_array($invalidTypes) && (!$invalidTypes || $level > 0)) {
    960                 $invalidTypes[get_debug_type($value)] = \true;
    961             }
    962             return \false;
    963         }
    964         $type = $allowedTypes[0];
    965         if (str_starts_with($type, '(') && str_ends_with($type, ')')) {
    966             return $this->verifyTypes(substr($type, 1, -1), $value, $invalidTypes, $level);
    967         }
     959    private function verifyTypes(string $type, mixed $value, array &$invalidTypes, int $level = 0): bool
     960    {
    968961        if (\is_array($value) && str_ends_with($type, '[]')) {
    969962            $type = substr($type, 0, -2);
     
    979972            return \true;
    980973        }
    981         if (\is_array($invalidTypes) && (!$invalidTypes || $level > 0)) {
     974        if (!$invalidTypes || $level > 0) {
    982975            $invalidTypes[get_debug_type($value)] = \true;
    983976        }
    984977        return \false;
    985     }
    986     /**
    987      * @return list<string>
    988      */
    989     private function splitOutsideParenthesis(string $type): array
    990     {
    991         return preg_split(<<<'EOF'
    992                 /
    993                 # Define a recursive subroutine for matching balanced parentheses
    994                 (?(DEFINE)
    995                     (?<balanced>
    996                         \(                          # Match an opening parenthesis
    997                         (?:                         # Start a non-capturing group for the contents
    998                             [^()]                   # Match any character that is not a parenthesis
    999                             |                       # OR
    1000                             (?&balanced)            # Recursively match a nested balanced group
    1001                         )*                          # Repeat the group for all contents
    1002                         \)                          # Match the final closing parenthesis
    1003                     )
    1004                 )
    1005        
    1006                 # Match any balanced parenthetical group, then skip it
    1007                 (?&balanced)(*SKIP)(*FAIL)          # Use the defined subroutine and discard the match
    1008        
    1009                 | # OR
    1010        
    1011                 \|                                  # Match the pipe delimiter (only if not inside a skipped group)
    1012                 /x
    1013         EOF, $type);
    1014978    }
    1015979    /**
  • pay-with-flex/trunk/vendor/symfony/options-resolver/composer.json

    r3427514 r3428340  
    2121    ],
    2222    "require": {
    23         "php": ">=8.4",
     23        "php": ">=8.1",
    2424        "symfony\/deprecation-contracts": "^2.5|^3"
    2525    },
Note: See TracChangeset for help on using the changeset viewer.