original_string: public function remove($key = null)
      {
          if ($key instanceof PageInterface) {
              $key = $key->path();
          } elseif (null === $key) {
              $key = (string)key($this->items);
          }
          if (!\is_string($key)) {
              throw new \InvalidArgumentException('Invalid argument $key.');
          }
  
          parent::remove($key);
  
          return $this;
      }
code: public function remove($key = null)
      {
          if ($key instanceof PageInterface) {
              $key = $key->path();
          } elseif (null === $key) {
              $key = (string)key($this->items);
          }
          if (!\is_string($key)) {
              throw new \InvalidArgumentException('Invalid argument $key.');
          }
  
          parent::remove($key);
  
          return $this;
      }
code_tokens: public function remove ( $ key = null ) { if ( $ key instanceof PageInterface ) { $ key = $ key -> path ( ) ; } elseif ( null === $ key ) { $ key = ( string ) key ( $ this -> items ) ; } if ( ! \ is_string ( $ key ) ) { throw new \ InvalidArgumentException ( 'Invalid argument $key.' ) ; } parent :: remove ( $ key ) ; return $ this ; }
docstring: Remove item from the list.
  
  @param PageInterface|string|null $key
  
  @return $this
  @throws \InvalidArgumentException
docstring_tokens: Remove item from the list .