• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aimeos / aimeos-core / 4f8b7e8d-5595-43b2-ba5c-df9921830178

17 May 2026 07:32AM UTC coverage: 92.581%. Remained the same
4f8b7e8d-5595-43b2-ba5c-df9921830178

push

circleci

aimeos
Fixed PHPStan issues

896 of 980 new or added lines in 165 files covered. (91.43%)

35 existing lines in 29 files now uncovered.

9734 of 10514 relevant lines covered (92.58%)

80.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/MShop/Order/Manager/Session.php
1
<?php
2

3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2023
6
 * @package MShop
7
 * @subpackage Order
8
 */
9

10

11
namespace Aimeos\MShop\Order\Manager;
12

13

14
/**
15
 * Session trait for order managers
16
 *
17
 * @package MShop
18
 * @subpackage Order
19
 */
20
trait Session
21
{
22
        /**
23
         * Returns the outmost decorator of the decorator stack
24
         *
25
         * @return \Aimeos\MShop\Common\Manager\Iface Outmost decorator object
26
         */
27
        abstract protected function object() : \Aimeos\MShop\Common\Manager\Iface;
28

29

30
        /**
31
         * Returns the context item object.
32
         *
33
         * @return \Aimeos\MShop\ContextIface Context item object
34
         */
35
        abstract protected function context() : \Aimeos\MShop\ContextIface;
36

37

38
        /**
39
         * Returns the current basket of the customer.
40
         *
41
         * @param string $type Basket type if a customer can have more than one basket
42
         * @return \Aimeos\MShop\Order\Item\Iface Shopping basket
43
         */
44
        public function getSession( string $type = 'default' ) : \Aimeos\MShop\Order\Item\Iface
45
        {
46
                $context = $this->context();
1✔
47
                $token = $context->token();
1✔
48
                $locale = $context->locale();
1✔
49
                $currency = $locale->getCurrencyId();
1✔
50
                $language = $locale->getLanguageId();
1✔
51
                $sitecode = $locale->getSiteItem()->getCode();
1✔
52

53
                $key = $token . '-' . $sitecode . '-' . $language . '-' . $currency . '-' . $type;
1✔
54

55
                try
56
                {
57
                        if( ( $order = \Aimeos\MShop::create( $context, 'basket' )->get( $key )->getItem() ) === null ) {
1✔
NEW
58
                                return $this->object()->create(); // @phpstan-ignore return.type
×
59
                        }
60

61
                        \Aimeos\MShop::create( $context, 'plugin' )->register( $order, 'order' );
1✔
62
                }
63
                catch( \Exception $e )
×
64
                {
NEW
65
                        return $this->object()->create(); // @phpstan-ignore return.type
×
66
                }
67

68
                // @phpstan-ignore return.type
69
                return $order;
1✔
70
        }
71

72

73
        /**
74
         * Saves the current shopping basket of the customer.
75
         *
76
         * @param \Aimeos\MShop\Order\Item\Iface $order Shopping basket
77
         * @param string $type Order type if a customer can have more than one order at once
78
         * @return static Manager object for chaining method calls
79
         */
80
        public function setSession( \Aimeos\MShop\Order\Item\Iface $order, string $type = 'default' ) : static
81
        {
82
                $context = $this->context();
1✔
83
                $token = $context->token();
1✔
84
                $locale = $context->locale();
1✔
85
                $currency = $locale->getCurrencyId();
1✔
86
                $language = $locale->getLanguageId();
1✔
87
                $sitecode = $locale->getSiteItem()->getCode();
1✔
88

89
                $key = $token . '-' . $sitecode . '-' . $language . '-' . $currency . '-' . strval( $type );
1✔
90

91
                $session = $context->session();
1✔
92

93
                $list = $session->get( 'aimeos/basket/list', [] );
1✔
94
                $list[$key] = $key;
1✔
95

96
                $session->set( 'aimeos/basket/list', $list );
1✔
97

98
                $manager = \Aimeos\MShop::create( $context, 'basket' );
1✔
99
                // @phpstan-ignore argument.type
100
                $manager->save( $manager->create()->setId( $key )->setCustomerId( $context->user() )->setItem( clone $order ) );
1✔
101

102
                return $this;
1✔
103
        }
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc