E
E
Evgeny Hakobyan2018-10-07 11:39:43
PHP
Evgeny Hakobyan, 2018-10-07 11:39:43

PHPStorm highlight error?

Guys, sorry for the noob question, I'm just studying php, tell me what the error is, phpStorm underlines the error
Maybe I have the wrong path
When you hover over the mouse, the editor shows that the object was not found, include the expression is not allowed
5bb9c598c960d526768566.png
code from all
User.php files

<?php

namespace Models\Users;

class User {
     private $name;

     public function __construct($name)
     {
          $this->name = $name;
     }
     public function getName():string
     {
          return $this->name;
     }
}

Article.php
<?php
namespace Models\Articles;

use Models\Users\User;

class Article {
     private $title;
     private $text;
     private $author;

     public function __construct(string $text, string $title, User $author)
     {
          $this->title = $title;
          $this->text = $text;
          $this->author = $author;
     }
     public function getTitle(): string
     {
          return $this->title;
     }
     public function getText(): string
     {
          return $this->text;
     }
     public function getAuthor(): User
     {
          return $this->author;
     }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
index0h, 2018-10-07
@sven_tesla

storm does not replace your variable with all your classes. That highlights the error about the path not found.
I recommend looking at composer at your leisure, it makes sense to write your own autoloaders only for some very specific tasks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question