Maikuolan / Common

Common Classes Package.
GNU General Public License v2.0
7 stars 3 forks source link

To do: "How to use" information. #2

Closed Maikuolan closed 5 years ago

Maikuolan commented 5 years ago

Need to add information to the readme to describe how to properly use the package and its classes.

peter279k commented 5 years ago

@Maikuolan, I think it's important.

This should be done firstly so that we can do unit tests easily.

Maikuolan commented 5 years ago

100% agree. :-)

Working on this now.

Maikuolan commented 5 years ago

I haven't started the documentation for the Cache class yet, and the "What rules to use for what language?" list in the documentation for the L10N class needs more work; I'll get both those two things sorted out soon. Everything else has been documented now though. :-)

If there are any suggestions, or if you find any possible errors, or anything missing, let me know.

peter279k commented 5 years ago

Hi @Maikuolan, thank you for your contribution about writing doc.

And I can enhance the unit tests now :).

peter279k commented 5 years ago

Hi @Maikuolan, when I write the unit test, I found some errors about the YAML::reconstruct method.

I found the following sample code is problematic in usage doc:

<?php
$YAML = 'foo: "bar"
1: "abc"
2: "def"
3: "ghi"
jkl: 4
mno: 5
pqr: 6
7: 8
9: 0
boolVal: false
boolVal2: true
multidimensional array: 
 hello: "world"
 hello2: "world2"
hello3: "world3"

';

$Object = new \Maikuolan\Common\YAML($YAML);

echo 'The YAML data, processed into an array:' . PHP_EOL;
var_dump($Object->Data);

echo PHP_EOL . PHP_EOL;

$Reconstructed = $Object->reconstruct($Object->Data);

echo 'Is the reconstructed YAML data, and the original YAML data, the same? ';

echo $YAML === $Reconstructed ? 'Yes.' : 'No.';

The last expected output will be false and it looks like the original is not same as reconstructed YAML data.

Have you checked that before? And it looks like the multidimensional array: will be missed in reconstructed YAML data.

peter279k commented 5 years ago

It looks like the line of 247 has been the problem in YAML class.

Please check that.

peter279k commented 5 years ago

It's weird. When I use the sample code that I mention in the previous comment, it will output the expected result correctly.

When I use PHPUnit to try asserting the expected and result string are equal, it's failed.

Maikuolan commented 5 years ago

Cheers. Looking into this now. :+1:

Maikuolan commented 5 years ago

I think I've fixed the problem now, as of the latest commit. Let me know how it goes. :-)

peter279k commented 5 years ago

@Maikuolan, thank you for your help.

I will try to do the unit tests again :).

Maikuolan commented 5 years ago

Cache documentation still pending. I've also recently added a new class, "Demojibakefier". I'll need to document that, too. Anyway, I'll continue working on this soon.

Maikuolan commented 5 years ago

The Cache class and the Demojibakefier class have both now been documented. The only remaining things to do now for the documentation are to finish populating the languages table in the documentation for the L10N class (it's a little short at the moment and doesn't cover many languages), and to get some people to proofread everything, to make sure that there's not any typos or mistakes that I might've missed, and to make sure that it actually makes sense (to people other than myself). :-P

Maikuolan commented 5 years ago

Done. Closing.