Answers.Body: <p>The normal way would be to instantiate and call non-statically like this:</p>
  
  <p><code>(new \craft\base\Volume)-&gt;fileExists($path);</code></p>
  
  <p>...However, that won't work here because it's an abstract class, which, by definition, cannot be instantiated. Assuming you're dealing with an <code>Asset</code> element(?), try calling <code>getVolume()</code> and then you should be able to call <code>fileExists()</code> from there. E.g:</p>
  
  <p><code>$asset-&gt;getVolume()-&gt;fileExists();</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-22T18:14:15.593Z
Answers.Text: Yes, I would like to get asset's existence. However, it is from its URL, not $asset. For example, I want to get if the file exist; "assets/doc/RegionA/statement.pdf"
Answers.UserDisplayName: Kota.M
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-22T17:12:56.500Z
Answers.LastActivityDate: 2020-04-22T17:37:20.630Z
Answers.LastEditDate: 2020-04-22T17:37:20.630Z
Answers.UserDisplayName: James Smith
Answers.Body: <p>I found an alternative way to find out if the asset exists or not, with filename, asset query and folder id.
  It is like;</p>
  
  <pre><code>{% set asset_query = craft.assets().filename(filename).folderId(folderID).all() %}
  </code></pre>
  
  <p>And if the query's length is 1 or more, it means the asset file exists.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-23T19:06:23.243Z
Answers.LastActivityDate: 2020-04-23T19:06:23.243Z
Answers.UserDisplayName: Kota.M
Body: <p>I would like to use a method of <code>fileExists</code>. It belongs to <code>VolumeInterface</code>.
  <a href="https://docs.craftcms.com/api/v3/craft-base-volumeinterface.html" rel="nofollow noreferrer">https://docs.craftcms.com/api/v3/craft-base-volumeinterface.html</a></p>
  
  <p>I suppose the code would be like <code>\craft\base\Volume::fileExists($path)</code>.</p>
  
  <p>However, Craft returns an error;</p>
  
  <pre><code>Non-static method craft\base\VolumeInterface::fileExists() cannot be called statically
  </code></pre>
  
  <p>Could I ask how I should modify the code?</p>
  
Tags: <craft3><php><user-interface>
Title: How to call abstract method from interface
ThreadText: # How to call abstract method from interface
  
  (Asked by: username_0 on 2020-04-22)
  
  I would like to use a method of `fileExists`. It belongs to `VolumeInterface`.
  <https://docs.craftcms.com/api/v3/craft-base-volumeinterface.html>
  
  I suppose the code would be like `\craft\base\Volume::fileExists($path)`.
  
  However, Craft returns an error;
  
  ```
  Non-static method craft\base\VolumeInterface::fileExists() cannot be called statically
  
  ```
  
  Could I ask how I should modify the code?
  
  **Tags:** craft3, php, user-interface
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-04-22. Score: 1
  
  The normal way would be to instantiate and call non-statically like this:
  
  `(new \craft\base\Volume)->fileExists($path);`
  
  ...However, that won't work here because it's an abstract class, which, by definition, cannot be instantiated. Assuming you're dealing with an `Asset` element(?), try calling `getVolume()` and then you should be able to call `fileExists()` from there. E.g:
  
  `$asset->getVolume()->fileExists();`
  
  > **Comments:**
  > **username_0**: Yes, I would like to get asset's existence. However, it is from its URL, not $asset. For example, I want to get if the file exist; "assets/doc/RegionA/statement.pdf"  
  
  ---
  
  ### Answer by username_0 on 2020-04-23. Score: 0
  
  I found an alternative way to find out if the asset exists or not, with filename, asset query and folder id.
  It is like;
  
  ```
  {% set asset_query = craft.assets().filename(filename).folderId(folderID).all() %}
  
  ```
  
  And if the query's length is 1 or more, it means the asset file exists.
  
  
  ---
  
  