Skip to content

Request API vs IRequest interface #147

Open

Description

@xificurk

Request implements a couple of extra methods that are not defined in IRequest interface. Nette 3 deprecated autowiring of Request type, only autowiring via interface is now supported. This means that those extra methods are basically "inaccessible" for any consumer. I think those methods should be either added to the interface, or deprecated and eventually removed.

  • getReferer(): ?Url - the interface already mentions this method in @method annotation, the annotation should be transformed to a proper method definition.
  • isSameSite(): bool - this should be definitely added to the interface.
  • detectLanguage(array $langs): ?string - this can be easily extracted to a separate service and removed from Request.

What are your thoughts? Shall I send a PR(s)?

Related to #137, #90

Activity

  1. xificurk commented on Feb 20, 2019

    @xificurk
    Author

    @dg Any thoughts? I think this needs to be resolved before stable 3.0 version.

  2. dg commented on Feb 28, 2019

    @dg
    Member

    For the next version there are plans to move to middleware and there will be probably a lot of changes. So currently I do not want make a BC break and we'll solve it the next time.

  3. added this to the v4.0 milestone on Feb 28, 2019
  4. xificurk commented on Feb 28, 2019

    @xificurk
    Author

    I really think this needs to be solved now, because of BC break introduced in #90.

    Please, tell me if I'm missing some crucial point. The following code works just fine in Nette 2.4.x:

    class Foo
    {
        /** @var Nette\Http\Request */
        private $request;
     
       public function __construct(Nette\Http\Request $request)
        {
            $this->request = $request;
        }
     
        public function bar(): void
        {
            if ($this->request->isSameSite()) {
                // whatava
            }
        }

    As far as I know, there is no way how to make it work in Nette 3.x. I can't use directly Request type and the IRequest interface does not declare isSameSite() method (and bunch of others).

  5. dg commented on Mar 9, 2019

    @dg
    Member

    I reverted fix for #90.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions