Skip to content

Conversation

@nicolaichuk
Copy link

@tgalopin, hi.
Please review and merge to upstream.

Copy link
Owner

@tgalopin tgalopin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @nicolaichuk,

Thanks for your PR!

I'm not sure what you want to fix in 128 bits version and why you need all the modifications you did. Unfortunately, I can't accept such a PR without some explanations about your work and fixes on the coding style and BC breaks.

* @param Fingerprint $fp1
* @param Fingerprint $fp2
* @return int
*/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this method is slower than the current one, why do you need this?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks :) .

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't use scalar type hint, we support php 5.3+

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove scalar type hint

$this->deviation = $deviation;
}

/**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Count differences between fingerprints

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

* @var float
*/
protected $decimalValue;
protected $value;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a BC break without any added value, could you revert this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"decimalValue" save value as number.
"value" save value as string.

These are two different variables, so they are called differently.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this property private as well? I don't think it should be exposed anyway.

public function tokenize($element)
{
return str_pad(base_convert(md5($element), 16, 2), 128, '0', STR_PAD_LEFT);
$hash = md5($element);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to split this in parts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For more comfort debugging

class String128Tokenizer implements TokenizerInterface
{

protected static $search = array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't add protected variables like this without a specific need as they will need to be handled by BC promise.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

{
return $size === 256;
}
} No newline at end of file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an ending line to this file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

{
return $size === 512;
}
} No newline at end of file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an ending line to this file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

* add an ending line to this file
@nicolaichuk
Copy link
Author

nicolaichuk commented Sep 19, 2017

@tgalopin

I'm not sure what you want to fix in 128 bits version and why you need all the modifications you did.

first:
"base_convert" in 128 bits version always return string content only zero symbols.
(environment: php 7.1, windows 7).

second:
php "bindec" dont corect work with 128-bit value
how do you try to save 128-bit value in 32-bit float?

Copy link
Owner

@tgalopin tgalopin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work, I understand it now :) . A few comments and we should be okay :) !

* @param Fingerprint $fp1
* @param Fingerprint $fp2
* @return int
*/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks :) .

* @var float
*/
protected $decimalValue;
protected $value;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this property private as well? I don't think it should be exposed anyway.

*/
class String128Tokenizer implements TokenizerInterface
{

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this extra line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

*/
class String256Tokenizer implements TokenizerInterface
{

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this extra line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

*/
class String512Tokenizer implements TokenizerInterface
{

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this extra line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

@nicolaichuk
Copy link
Author

nicolaichuk commented Sep 28, 2017

@tgalopin
ping...

Copy link
Owner

@tgalopin tgalopin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis is failing due to scalar type hints.

return str_pad(base_convert(md5($element), 16, 2), 128, '0', STR_PAD_LEFT);
$hash = md5($element);
$hash = str_replace(self::$search, self::$replace, $hash);
$hash = str_pad($hash, 512, '0', STR_PAD_LEFT);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a typo here. Shouldn't you write:

$hash = str_pad($hash, 128, '0', STR_PAD_LEFT);

Copy link
Author

@nicolaichuk nicolaichuk Aug 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbalet, fixed.

@bbalet
Copy link

bbalet commented Aug 20, 2018

Hi guys,

I know what is to maintain an OSS project, but this PR looks good to me except a typo and the scalar type hint (except if you want to stop to maintain compatibility with older projects).

It is a good lib that helped me in the past, but now I am stuck with the error in 128 hashes.

How can I help?

@tgalopin
Copy link
Owner

Hello @bbalet !

The issue is that as @nicolaichuk didn't gave me access to code modification in this PR, I can't update his code, and using it without crediting him does not feel right in open-source :) . If you want to open a new PR based on his code, fixing the issues and adding a note in your commit message about @nicolaichuk, please don't hesitate to do so and I will review it happily :) !

@nicolaichuk
Copy link
Author

nicolaichuk commented Aug 21, 2018

@tgalopin

he issue is that as @nicolaichuk didn't gave me access to code modification in this PR

Option "Allow edits from maintainers" is selected in this PR.

@nicolaichuk nicolaichuk requested a review from tgalopin November 17, 2021 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants