|
207 | 207 | * closeSessionOnRecreateApplication: bool,
|
208 | 208 | * applicationClass: class-string<\yii\base\Application>|null
|
209 | 209 | * }
|
210 |
| - * @phpstan-type SessionBackup array{cookie: array<mixed>, session: array<mixed>, headers: array<string, string>, clientContext: array{ cookieJar: CookieJar, history: History }} |
211 | 210 | * @phpstan-type ClientConfig array{
|
212 | 211 | * configFile: string,
|
213 | 212 | * responseCleanMethod: Yii2Connector::CLEAN_CLEAR|Yii2Connector::CLEAN_MANUAL|Yii2Connector::CLEAN_RECREATE,
|
|
218 | 217 | * applicationClass: class-string<\yii\base\Application>|null
|
219 | 218 | * }
|
220 | 219 | */
|
221 |
| -final class Yii2 extends Framework implements ActiveRecord, MultiSession, PartedModule |
| 220 | +final class Yii2 extends Framework implements ActiveRecord, PartedModule |
222 | 221 | {
|
223 | 222 | /**
|
224 | 223 | * @var list<Yii2Connector\FixturesStore>
|
@@ -887,63 +886,5 @@ public function _afterSuite(): void
|
887 | 886 | $_SERVER = $this->server;
|
888 | 887 | }
|
889 | 888 |
|
890 |
| - /** |
891 |
| - * Initialize an empty session. Implements MultiSession. |
892 |
| - */ |
893 |
| - public function _initializeSession(): void |
894 |
| - { |
895 |
| - $this->getClient()->restart(); |
896 |
| - $this->headers = []; |
897 |
| - $_SESSION = []; |
898 |
| - $_COOKIE = []; |
899 |
| - } |
900 |
| - |
901 |
| - /** |
902 |
| - * Return the session content for future restoring. Implements MultiSession. |
903 |
| - * |
904 |
| - * @return SessionBackup |
905 |
| - */ |
906 |
| - public function _backupSession(): array |
907 |
| - { |
908 |
| - if (Yii::$app instanceof WebApplication && Yii::$app->has('session', true) && Yii::$app->session->useCustomStorage) { |
909 |
| - throw new ModuleException($this, "Yii2 MultiSession only supports the default session backend."); |
910 |
| - } |
911 |
| - return [ |
912 |
| - 'clientContext' => $this->getClient()->getContext(), |
913 |
| - 'headers' => $this->headers, |
914 |
| - // @phpstan-ignore nullCoalesce.variable |
915 |
| - 'cookie' => $_COOKIE ?? [], |
916 |
| - 'session' => $_SESSION ?? [], |
917 |
| - ]; |
918 |
| - } |
919 | 889 |
|
920 |
| - /** |
921 |
| - * Restore a session. Implements MultiSession. |
922 |
| - * |
923 |
| - * @param SessionBackup $session output of _backupSession() |
924 |
| - */ |
925 |
| - public function _loadSession($session): void |
926 |
| - { |
927 |
| - $this->getClient()->setContext($session['clientContext']); |
928 |
| - $this->headers = $session['headers']; |
929 |
| - $_SESSION = $session['session']; |
930 |
| - $_COOKIE = $session['cookie']; |
931 |
| - $app = Yii::$app; |
932 |
| - if ($app?->has('user', true)) { |
933 |
| - $definitions = $app->getComponents(); |
934 |
| - $app->set('user', $definitions['user']); |
935 |
| - } |
936 |
| - } |
937 |
| - |
938 |
| - /** |
939 |
| - * Close and dump a session. Implements MultiSession. |
940 |
| - * |
941 |
| - * @param mixed $session |
942 |
| - */ |
943 |
| - public function _closeSession($session = null): void |
944 |
| - { |
945 |
| - if (! $session) { |
946 |
| - $this->_initializeSession(); |
947 |
| - } |
948 |
| - } |
949 | 890 | }
|
0 commit comments