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

[NFR]: Add method to Mvc/Model/CriteriaInterface #14818

Closed
maxc62 opened this issue Feb 5, 2020 · 6 comments
Closed

[NFR]: Add method to Mvc/Model/CriteriaInterface #14818

maxc62 opened this issue Feb 5, 2020 · 6 comments
Labels
new feature request Planned Feature or New Feature Request

Comments

@maxc62
Copy link

maxc62 commented Feb 5, 2020

Is your feature request related to a problem? Please describe.
When I create a query, the IDE never shows me the "columns" method

Describe the solution you'd like
So I checked the "CriteriaInterface" class, and I don't see this function
So I compared all the functions between "CriteriaInterface" and "Criteria" and found some differences:

public function setDI(<DiInterface> container) -> void
public function getDI() -> <DiInterface>
public function columns(var columns) -> <CriteriaInterface>
public function join(string! model, var conditions = null, var alias = null, var type = null) -> <CriteriaInterface>
public static function fromInput(<DiInterface> container, string! modelName, array! data, string! operator = "AND") -> <CriteriaInterface>
public function createBuilder() -> <BuilderInterface>

So I don't know, if we need to add all this functions. I think we need to add "columns" and "join" (even if we have leftJoin and innerJoin)

@maxc62 maxc62 added the new feature request Planned Feature or New Feature Request label Feb 5, 2020
@TimurFlush
Copy link

TimurFlush commented Feb 6, 2020

Also you can use

/** @var Phalcon\Mvc\Model\Criteria $criteria */
$criteria = 5; // you also can use the 'use' operator before it for shortly hint

/*
 * IDE will think that it's the Criteria object
 */
$criteria->columns();

@maxc62
Copy link
Author

maxc62 commented Feb 6, 2020

Yes, I agree.
But I always use Model::query()->columns();

And method query (Phalcon/Mvc/Model) return CriteriaInterface

query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface

@ruudboon
Copy link
Member

ruudboon commented Feb 6, 2020

What IDE are you using?

@maxc62
Copy link
Author

maxc62 commented Feb 6, 2020

I use Intellij IDEA, with your plugin Phalcon 4 (thanks @ruudboon)
=> https://plugins.jetbrains.com/plugin/12776-phalcon-4-autocomplete
Source Here:
https://github.com/ruudboon/phpstorm-phalcon-4-autocomplete/blob/master/plugin/src/Phalcon/Mvc/Model/CriteriaInterface.php
Based on Phalcon CriteriaInterface

Today I'm overloading method query in IDEA to return Criteria after query()

This code works

Model::query()
->columns('var2, var3')//return CriteriaInterface
->where('var = :var:')//return CriteriaInterface
->bind([
		'var' => Model::VAR_YES
])//return CriteriaInterface

Not this one

Model::query()
->where('var = :var:')//return CriteriaInterface
->bind([
		'var' => Model::VAR_YES
])//return CriteriaInterface
->columns('var2, var3')//Error function not exists on IDE

@wmamrak
Copy link

wmamrak commented Feb 6, 2020

Same on Visual Studio Code.
Also, in ValidationInterface::add first argument's type is string, whereas it can be string or an array.

@niden
Copy link
Sponsor Member

niden commented Apr 10, 2020

Tracked in #14608

@niden niden closed this as completed Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature request Planned Feature or New Feature Request
Projects
None yet
Development

No branches or pull requests

5 participants