Fix PhanTypeMismatchDeclaredParam
[lhc/web/wiklou.git] / includes / session / Session.php
index 8fa212e..3dc8299 100644 (file)
@@ -129,6 +129,11 @@ final class Session implements \Countable, \Iterator, \ArrayAccess {
 
        /**
         * Make this session not be persisted across requests
+        *
+        * This will remove persistence information (e.g. delete cookies)
+        * from the associated WebRequest(s), and delete session data in the
+        * backend. The session data will still be available via get() until
+        * the end of the request.
         */
        public function unpersist() {
                $this->backend->unpersist();
@@ -286,7 +291,7 @@ final class Session implements \Countable, \Iterator, \ArrayAccess {
        /**
         * Fetch a value from the session
         * @param string|int $key
-        * @param mixed $default Returned if $this->exists( $key ) would be false
+        * @param mixed|null $default Returned if $this->exists( $key ) would be false
         * @return mixed
         */
        public function get( $key, $default = null ) {
@@ -476,7 +481,7 @@ final class Session implements \Countable, \Iterator, \ArrayAccess {
 
                // Encrypt
                // @todo: import a pure-PHP library for AES instead of doing $wgSessionInsecureSecrets
-               $iv = \MWCryptRand::generate( 16, true );
+               $iv = random_bytes( 16 );
                $algorithm = self::getEncryptionAlgorithm();
                switch ( $algorithm[0] ) {
                        case 'openssl':
@@ -517,7 +522,7 @@ final class Session implements \Countable, \Iterator, \ArrayAccess {
        /**
         * Fetch a value from the session that was set with self::setSecret()
         * @param string|int $key
-        * @param mixed $default Returned if $this->exists( $key ) would be false or decryption fails
+        * @param mixed|null $default Returned if $this->exists( $key ) would be false or decryption fails
         * @return mixed
         */
        public function getSecret( $key, $default = null ) {
@@ -595,7 +600,7 @@ final class Session implements \Countable, \Iterator, \ArrayAccess {
         *
         * Calls to save() or clear() will not be delayed.
         *
-        * @return \ScopedCallback When this goes out of scope, a save will be triggered
+        * @return \Wikimedia\ScopedCallback When this goes out of scope, a save will be triggered
         */
        public function delaySave() {
                return $this->backend->delaySave();
@@ -603,6 +608,9 @@ final class Session implements \Countable, \Iterator, \ArrayAccess {
 
        /**
         * Save the session
+        *
+        * This will update the backend data and might re-persist the session
+        * if needed.
         */
        public function save() {
                $this->backend->save();
@@ -613,31 +621,37 @@ final class Session implements \Countable, \Iterator, \ArrayAccess {
         * @{
         */
 
+       /** @inheritDoc */
        public function count() {
                $data = &$this->backend->getData();
                return count( $data );
        }
 
+       /** @inheritDoc */
        public function current() {
                $data = &$this->backend->getData();
                return current( $data );
        }
 
+       /** @inheritDoc */
        public function key() {
                $data = &$this->backend->getData();
                return key( $data );
        }
 
+       /** @inheritDoc */
        public function next() {
                $data = &$this->backend->getData();
                next( $data );
        }
 
+       /** @inheritDoc */
        public function rewind() {
                $data = &$this->backend->getData();
                reset( $data );
        }
 
+       /** @inheritDoc */
        public function valid() {
                $data = &$this->backend->getData();
                return key( $data ) !== null;
@@ -646,6 +660,7 @@ final class Session implements \Countable, \Iterator, \ArrayAccess {
        /**
         * @note Despite the name, this seems to be intended to implement isset()
         *  rather than array_key_exists(). So do that.
+        * @inheritDoc
         */
        public function offsetExists( $offset ) {
                $data = &$this->backend->getData();
@@ -658,6 +673,7 @@ final class Session implements \Countable, \Iterator, \ArrayAccess {
         *  data to detect such changes.
         * @note Accessing a nonexistent key via this mechanism causes that key to
         *  be created with a null value, and does not raise a PHP warning.
+        * @inheritDoc
         */
        public function &offsetGet( $offset ) {
                $data = &$this->backend->getData();
@@ -668,10 +684,12 @@ final class Session implements \Countable, \Iterator, \ArrayAccess {
                return $data[$offset];
        }
 
+       /** @inheritDoc */
        public function offsetSet( $offset, $value ) {
                $this->set( $offset, $value );
        }
 
+       /** @inheritDoc */
        public function offsetUnset( $offset ) {
                $this->remove( $offset );
        }