Closed weleoka closed 9 years ago
Shall I fork amend, and make pull request? Also many wasted end-of-line whitespace characters in CForm code. Clean?
Hmm, haven't seen that become an error before. Do you have a small testprogram or any of the available testprogram that produces that error?
About end-of-line whitepspace, hold that thought, just a minute. Lets check above first.
Feel free to add a small testprogram that shows the error, if needed, and make a pull request.
This issue is in version 2 of CForm ( i.e. v1.9.x. Latest release: v1.9.1 on 2014-05-05 )
composer.json: require "mos/cform": "2.*@dev"
checksum: 6e58aa0c0f128af725bccd50c6a806a5d6953683
/src/HTMLForm/CFormElement.php -> _construct() is where the error is. I don't think a test case is needed? It's a piece of obsolete code?
Probably one small nothing in all the other things that need doing in V2 of CForm. =)
Hmm, I'll check it.
I fixed the trailing spaces, makes it easier to receive pull requests when it passes phpcs.
I also added a pre-commit-hook that runs phpcs (and phpunit).
However, I can not reproduce the error. There is a testcase in: https://github.com/mosbth/cform/blob/v2/test/HTMLForm/CFormElementTest.php#L20
which should produce the error.
Can you run phpunit
whithout errors? I can. You should get the error when you try it, or?
The code is obsolete, so it should be removed - or rewritten, however, I would really like to reproduce it to get the same error as you have.
I pass all the tests with phpunit I did this (which I understand is the wrong way to do it!) :
$el = new \Mos\HTMLForm\CForm();
$form = $el->create([], [
'test' => ['type' => 'select'],
]);
And that throws:
Fatal error: Uncaught exception 'Exception' with message 'Classfile 'CLydia' does not exists.'
Yes, its missing an array of options. Buts its still another Exception. Perhaps, the exception you get now is from your autoloader, saying it can not find the classfile for CLydia. Ah, I see, its rather obvious in your first post. The exception is from your autoloader.
I guess its an issue with your autoloader. If you try doing this in your code:
var_dump(class_exists("NoSuchClass"));
You should get false
, but you probably will get an exception, right? Your autoloader behavior disturbs the functions that tries to check if a class, or function, exists. So its an issue with your autoloader.
Nevertheless, I added both CFormException
and testcases for <select>
and <select multiple>
to general improve CForm.
Eventually will I remove the connection to CLydia
, it should not be there anymore. But the code should work with it in there.
Absolutely true, it was my autoloader which was throwing the exception - it should have been obvious to me, but I missed that. Thanks.
Error is: Classfile 'CLydia' does not exists.
0 [internal function]: myAutoloader('CLydia')
1 [internal function]: spl_autoload_call('CLydia')
2 /apache2/htdocs/dataDB/vendor/mos/cform/src/HTMLForm/CFormElement.php(37): is_callable('CLydia::Instanc...')
Line 37 in CFormElement and the _construct()