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

Selection: moved caching related functionality to separate classes #185

Merged
merged 1 commit into from Oct 11, 2017

Conversation

@foxycode
Copy link
Contributor

commented Oct 9, 2017

  • bug fix? no
  • new feature? yes
  • BC break? no

@dg Cache implementation is a long term problem in NDBT. While this is definitely not perfect, it's a starting point from which I would like to continue making NDBT code more clear, which wil help in future development. I spent two days with this, so I hope you appreciate it. Also, if you agree, I can maintain this repo as we spoken on NettCamp. There is lot for review and merge.

@dg

This comment has been minimized.

Copy link
Member

commented Oct 9, 2017

Thanks for pull request. If I understand it, this is a pure refactoring that separates the code into new classes but does not change the functionality?

@foxycode

This comment has been minimized.

Copy link
Contributor Author

commented Oct 9, 2017

@dg Yes, exactly :)

@foxycode foxycode force-pushed the foxycode:cache branch from d4cbe75 to 7b9d6f7 Oct 9, 2017

}
public function setGeneralCacheKey(?string $key)

This comment has been minimized.

Copy link
@dg

dg Oct 9, 2017

Member

Because it is targeted to 7.1, you can use return type void.

/**
* @param mixed $accessedColumns

This comment has been minimized.

Copy link
@dg

dg Oct 9, 2017

Member

Please don't use property name in @param. I know that PhpStorm appends it automatically, but better is to be consistent with rest of code.

Btw is it really mixed or array?

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 9, 2017

Author Contributor

It is really mixed

/**
* Loads cache of previous accessed columns and returns it.
* @return array|bool

This comment has been minimized.

Copy link
@dg

dg Oct 9, 2017

Member

When it returns bool?

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 9, 2017

Author Contributor

This is just move from original class. I wasn't sure so I reather left it as is.

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 9, 2017

Author Contributor

There are more variables that use null and bool to distinguish some states. I would like to fix this in second run.

This comment has been minimized.

Copy link
@dg

dg Oct 9, 2017

Member

It seems that array_keys() can return only array, or not?

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 9, 2017

Author Contributor

Yes, and it passes tests, fixed.

/**
* @param mixed $observeCache

This comment has been minimized.

Copy link
@dg

dg Oct 9, 2017

Member

mixed or bool?

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 9, 2017

Author Contributor

Here iare stored Selection instances.

@foxycode foxycode force-pushed the foxycode:cache branch 2 times, most recently from 0b2d5f3 to 75b5c5c Oct 9, 2017

@foxycode

This comment has been minimized.

Copy link
Contributor Author

commented Oct 9, 2017

Rest fixed

/**
* @param mixed

This comment has been minimized.

Copy link
@dg

dg Oct 9, 2017

Member

$previousAccessedColumns has typehint array and here is mixed

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 9, 2017

Author Contributor

My bad. I copied properties as they were. Fixed on all properties.

/**
* @param mixed
*/
public function setAccessedColumns($accessedColumns): void

This comment has been minimized.

Copy link
@dg

dg Oct 9, 2017

Member

$accessedColumns has typehint array and here is mixed

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 9, 2017

Author Contributor

Fixed.

/**
* @return mixed

This comment has been minimized.

Copy link
@dg

dg Oct 9, 2017

Member

$accessedColumns has typehint array and here is mixed

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 9, 2017

Author Contributor

Fixed

/**
* @param mixed

This comment has been minimized.

Copy link
@dg

dg Oct 9, 2017

Member

$observeCache has typehint bool and here is mixed

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 9, 2017

Author Contributor

Fixed, allowed only Selection.

@foxycode foxycode force-pushed the foxycode:cache branch 2 times, most recently from 89441c5 to a22f121 Oct 9, 2017

@foxycode

This comment has been minimized.

Copy link
Contributor Author

commented Oct 10, 2017

@dg Anything else I can do so you merge it?

/** @var string */
protected $specificCacheKey;
/** @var mixed of touched columns */

This comment has been minimized.

Copy link
@dg

dg Oct 10, 2017

Member

What means mixed of? Is it array or not?

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 10, 2017

Author Contributor

There was lot of mess arround mixed properties, so I get rid of them and simplify code in separate commit. Let me know what you think.

@foxycode foxycode force-pushed the foxycode:cache branch from b394d2c to b899d0e Oct 10, 2017

/**
* @return mixed

This comment has been minimized.

Copy link
@dg

dg Oct 11, 2017

Member

It seems according to the code that it is array|null, or not? For getReferenced too.

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 11, 2017

Author Contributor

Yes, you are right

public function setAccessedColumn(string $key, bool $value): void
{
if (!$this->cache) {

This comment has been minimized.

Copy link
@dg

dg Oct 11, 2017

Member

Just such a stupid thing, maybe positive condition can be used here and in setAccessedColumns

if ($this->cache) {
     $this->accessedColumns[$key] = $value;
}
```

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 11, 2017

Author Contributor

Fixed on both places.

@dg

This comment has been minimized.

Copy link
Member

commented Oct 11, 2017

Now it look much better, thanks!

@foxycode foxycode force-pushed the foxycode:cache branch from b899d0e to 2ad382e Oct 11, 2017

/**
* @return array|null
*/
public function &getReferencing(string $generalCacheKey)

This comment has been minimized.

Copy link
@dg

dg Oct 11, 2017

Member

Sry, now I realized that it can be written native as &getReferencing(string $generalCacheKey): ?array

This comment has been minimized.

Copy link
@foxycode

foxycode Oct 11, 2017

Author Contributor

Yes, I should realize that too. Fixed

@foxycode foxycode force-pushed the foxycode:cache branch from 2ad382e to 8e6bccd Oct 11, 2017

@dg

This comment has been minimized.

Copy link
Member

commented Oct 11, 2017

Do you want to have two commits, one with mixed and the other without mixed properties?

@foxycode foxycode force-pushed the foxycode:cache branch from 8e6bccd to fad84f8 Oct 11, 2017

@foxycode

This comment has been minimized.

Copy link
Contributor Author

commented Oct 11, 2017

@dg No, it was just for easier code review, squashed.

It would be good to resolve other PR's before I get further. Like this one, which is not needed now: #161 Will you do that or should I take care of that for you?

@dg dg merged commit a561254 into nette:master Oct 11, 2017

2 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.5%) to 87.918%
Details
@dg

This comment has been minimized.

Copy link
Member

commented Oct 11, 2017

Thanks, great!

dg added a commit that referenced this pull request Apr 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.