Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Type of resource replace by class #1269

Open
jansor opened this issue Jun 11, 2021 · 4 comments
Open

Return Type of resource replace by class #1269

jansor opened this issue Jun 11, 2021 · 4 comments

Comments

@jansor
Copy link

jansor commented Jun 11, 2021

Hi,

I was wondering, as I understand the type of resource is something in the future version they going to deprecate/replace.
Now when i was just playing around with CURL under PHP8.0 and saw following items in documentation.

image

The documentation is based for PHP Storm, but is their a similar implementation possible?

As an example that's direct from PHP: https://www.php.net/manual/en/class.curlhandle.php

As a future implementation towards 8.1 or next version, can we apply the same logic under the SQL system?

Just a suggestion

Thanks for all the hard work!!

@yitam
Copy link
Contributor

yitam commented Jun 11, 2021

Thanks @jansor , and yes we are aware of the resource type going to be deprecated in the near future, but I'm not sure I understand your question.

Are you asking if we are going to define our own class(es) for sqlsrv/pdo_sqlsrv to communicate with SQL Server?

@jansor
Copy link
Author

jansor commented Jun 12, 2021

Hi @yitam , i assume yes,

I don't know how to implement this but for future releases of the driver, add opaque class? Similar to CurlHandle?

final SqlSrvHandle{ }

Under the documentation part its then possible to add:
image

This gives the advantage that we can define return types on methods and properties.

@yitam
Copy link
Contributor

yitam commented Jun 14, 2021

Thanks @jansor for the suggestion. Currently there is no immediate plan for this, but I'll mark this as a feature request.

@codemasher
Copy link

codemasher commented Aug 25, 2024

I was just looking for this - it would be great to see in a future release! The PostgreSQL drivers also return an instance of a class rather than a resource as of PHP 8.1 (https://www.php.net/manual/en/class.pgsql-connection.php).
It allows for more type safety as one could check with an instanceof instead of the weird gettype() and looking for a resource type name.

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

No branches or pull requests

3 participants