« first day (1643 days earlier)      last day (3302 days later) » 

5:00 PM
I could reuse num_traits or something to put the type information hahaha
Maybe I could hide it in the upper bits of ce_flags.
 
no...
 
Could use any of the zend_function entries since none of them are used ;)
 
@LeviMorrison why not? Why does it need to be on the CE? Oh. wait, nevermind.
 
@ircmaxell Yes, it must be on the CE.
 
yeah, figured that out :-/
 
5:02 PM
There are plenty of unused fields for enums; it's a matter if deciding where is the most acceptable.
 
@LeviMorrison @ircmaxell Honestly, this looks like a really bad use case for enums to me
 
@NikiC Regardless I expect I have to store it for reflection anyway.
 
Given how the actual value will not end up matching any of the enum values
@LeviMorrison This response is more to the question of whether this should be supported at all
 
Assuming I didn't need that info at runtime at all for implementation reasons, I'd still need it for reflection.
@NikiC "this" meaning what, exactly? constant expressions or user-defined values?
 
User-defined values.
 
5:04 PM
@LeviMorrison The using an enum for bitflags is wrong
That it's a bad example for this feature
The only reasonable example I've seen is the HTTP status codes one
 
HTTP status codes aren't enums.
Not all values in the range 100-599 have names or meanings.
 
@tereško I can try, but it will have to wait to tomorrow. I'm busy finishing up some work myself atm
 
@LeviMorrison so that one is a bad example as well ^^
So ... what are good examples?
food
 
json_encode …?
 
@PeeHaa emm . context ?
 
5:06 PM
@LeviMorrison ???
 
@NikiC Using them as array keys.
(possibly)
 
@LeviMorrison Makes sense. But at that point I'd rather allow objects as array keys.
 
I think there are a handful of uses.
 
Objects as array keys would have much more uses.
 
enum CRYPT_TYPES {
    bcrypt = "$2y$",
    /(...*/
    md5 = "$1$",
}
 
5:08 PM
Eh, the types of hashes that are available will change over time. I don't think that's an enum.
 
@LeviMorrison not for a specific build.
 
I disagree with this kind of use, honestly. I can basically guarantee that values will be added in the future, and I can foresee removing them as well.
 
so your use-case for an ENUM is a set that will never change over all time? Not just will never change in a single run/build/distribution?
 
@ircmaxell This gives you one part of the information, but not all. E.g. what is the equivalent password_hash() constant then? you need some lookup there then. Enums with explicit values only remove one level of indirection there for one single case.
 
@ircmaxell I wouldn't say "never" change; rather that I don't expect it to change.
 
5:11 PM
:22732706 enum PASSWORD_HASH_TYPE : int {
    bcrypt = 1,
    default = 1
}
 
an enum with two same values? god no.
 
That's not allowed. I don't allow that.
 
well then
 
(or rather I won't allow that)
 
when using make test TESTS="some/path" is it possible to add multiple paths? something like: make test TESTS="Zend/tests/some_group/,Zend/tests/other_group/" or maybe do we have some glob brace support?
 
5:13 PM
enum PASSWORD_HASH_TYPE: int {
    bcrypt = PASSWORD_BCRYPT
}
 
@marcio If it works it will be a path separator. On Unix/Linux/BSD like systems that's a : and on Windows it's a ;
 
// and … what about…

enum PasswordHashType {
    BCRYPT,
    SCRYPT,
}

function get_password_hash_const(PasswordHashType $type = null) {
    switch ($type) {
        case PasswordHashType::BCRYPT:
            return PASSWORD_BCRYPT;
        case PasswordHashType::SCRYPT:
            return PASSWORD_SCRYPT;
        default:
            return PASSWORD_BCRYPT;
}

// similar for e.g. get_crypt_prefix() etc. Then you can cover everything with the same scheme.
 
@LeviMorrison you mean make test TESTS="Zend/tests/some_group/:Zend/tests/other_group/"?
 
@marcio Yeah, if it works at all.
 
@ircmaxell ^ That way also information is all available the same way. no special cases.
 
5:19 PM
Build complete.
Don't forget to run 'make test'.
bogus test name ...
 
eih
 
I think storing the enum type as a static class property and controlling write access might work. Not my favorite solution.
 
I always wondered why does PHP lower than 5.4 in Parse error: syntax error, unexpected $end name the EOF as $end.
 
suddenly I start to desire the iota feature again
 
@ircmaxell An enum value is an abstract representation of something specific and unique. To get a specific representation of something, you need helper functions. You may have multiple possible representations for a same thing… But there's nothing like the one true representation for an enum value. [which you force on it by assigning the enum object a value]
 
5:23 PM
not sure I agree. An enum is a fixed set. That's it. The meaning implied by its members depends on the domain...
 
@ThatBrazilianGuy It depends on what exactly you mean by 'extract' and 'database' but probably something like MySQLDump
 
What database and what server? Assuming linux/mysql mix?
 
@ircmaxell I can't think of any reason why you ever only need one single specific value for enum objects. Apart from bitflags. But if you need bitflags enum is definitely the wrong tool for that.
 
> it's useful for when you've get a set of enums that need to match the values in an external API. (and yes, technically a separate mapping of enums to values would be the correct way to do it I guess, but, PHP).
 
@Danack Yeah, I had only used phpmyadmin before. The CLI is confusing me a bit.
But thanks :)
 
5:28 PM
Well maybe I'll propose without it and see how much pushback I get for not having user-defined values.
I'll need to write something about it in the RFC, of course.
 
@Danack sure… but who says that it will be only that one API ever. Maybe there's another API which has other integer values for the different things.
 
What I'd really like to support is something like this:
 
Which would be a different enum type.
 
@Danack not if the things have the same meanings, just another mapping.
 
enum Barcode {
    UPCA(int $system, int $manufacturer, int $product, int $check),
    QRCode(string $code)
}
 
5:33 PM
uhhh
that should be OO then
interface Barcode {}
class UPCA implements Barcode {}
class QRCode implements Barcode {}
 
yep. Or abstract class.
 
sure, depending on behavior encapsulation
 
@Danack It worked! Thanks! :D
 
The only thing I'd eventually consider would be adding userdefined methods to enums. (To get the different representations)
 
\o/
 
5:36 PM
And make enums non-final so that one can add methods.
 
@bwoebi example?
honestly, I think the fact that enums are objects should be seen as a implementation detail and nothing else
 
...
 
has anyone noticed that within the last year or so facebook will open up a new page after authenticating the user?
now linkedin is doing the same thing
I wonder if that is to keep people from hitting the back button...or if it is to ensure page state after logout
 
@ircmaxell The key is that there is intentionally a finite number of them.
 
@LeviMorrison Will it be possible for enums to be declared in extensions/internals code? Either way, probably ought to be mentioned in the RFC.
 
5:39 PM
This is a very common thing in data structures.
 
@LeviMorrison why is it worth limiting it in this case?
 
Eh, maybe barcode isn't a great example.
However, implementing a BinarySearchTree is definitely limited.
enum Node {
    Empty,
    Value(Node $left, Node $right, $value)
}
 
I'm not following
 
enum Direction {
    NORTH,
    WEST,
    EST,
    SOUTH,

    public function getDegrees(self $dir) {
        switch ($dir) {
            case self::NORTH:
                return 0;
            case self::WEST:
                return -90;
            case self::EST:
                return 90;
            case self::SOUTH:
                return 180;
        }
    }

    public function getRad(self $dir) {
        switch ($dir) {
            case self::NORTH:
                return 0;
            case self::WEST:
@ircmaxell ^ like that…
 
@ircmaxell Have you ever used algebraic data types in any other language?
 
5:41 PM
I don't consider that an enum, I consider that an Algebraic Data type
 
@ircmaxell In rust and ceylon algebraic data types use the enum keyword.
 
@bwoebi eih... I don't care for that. Not at all.
 
It's because there's a finite number of them, presumably.
 
@LeviMorrison to me an enum is an enumeration of possible values. An algebraic data type is an eumeration of possible types
 
@ircmaxell Types are values. Values can be types. Have you not accepted Haskell into your heart?
 
5:44 PM
hi there
 
Do we have a demonstration of common things that can be done in case statements?
To have algebraic data types I need a better form of case matching.
If possible I'd rather not use a new construct like match() or something.
 
any one have idea about bcrypt hashing? i have a problem , this bcrypt hashing method generating diff output for same input everytime. how to use this?
 
@LeviMorrison well... Types are purely compile time, where values are compile and runtime...
 
@FerozAkbar are you using bcrypt directly? you probably shouldn't be
 
@FerozAkbar Check the manual and use password_hash
 
5:47 PM
@FerozAkbar If you're using the built-in password functions you should use password_verify to check if the password entered is okay. It hashes to different values because it includes a random salt each time.
 
@FerozAkbar it's supposed to
 
@FerozAkbar yea, use the built-in abstractions
 
enum Node {
    Nothing,
    Something(Node $left, Node $right, $value)
}
function add(Node $n, $value): Node {
    switch ($n) {
        case Node::Nothing:
            return Node::Something($n, $n, $value);

        case Node::Something($left, $right, $v):
            if ($value < $v) {
                return add($left, $value);
            } else if ($value > $v) {
                return add($right, $value);
            } else {
                return $n;
            }
    }
}
 
that'd be hard... it would mean understanding Node at compile time to know it's an algebraic type and hence compile it differently than a static method call...
 
now you're putting trivial uses for classes and interfaces into enums…
 
5:51 PM
@bwoebi no, he's talking about making enum into an algebraic data type, which isn't a trivial use-case at all
 
You guys don't value the "finiteness" of the the enum as much as I do, it seems.
 
@LeviMorrison no, I get it. When looking at it from a type perspective at least
 
@ircmaxell I think it's complete bullcrap that we allow functions and general expressions in case statements.
Except only some expressions.
It's really dumb.
 
@LeviMorrison bullcrap, perhaps. But that's where we are today.
 
For instance, you can't use list() in a case statement.
(A bunch of other things are like that too)
 
5:53 PM
Hey guys I'm not sure this is even allowed on Stackoverflow, but I've been stuck with a piece of php code for a while now and I've gone through all possible related documentation, yet I cannot find the answer. I'm a beginner tho. Would anyone care to take a look?
 
@ircmaxell My point is simply that some way to do better pattern matching is basically a prereq for having algebraic data types.
 
@MichaelCox got a question, ask it, put the code in a paste service of some sort
 
@DaveRandom it is indeed pronounced as pee, because i is pronounced e in french
 
@LeviMorrison I'm not arguing
 
5:58 PM
@MichaelCox before I look at teh code, could you describe the challange you are having =]
what did you expected vs what happend
 
@FlorianMargaine I don't agree with french people often, but when I do it is about how to pronounce pi pee @DaveRandom
 
@LeviMorrison My point is that without said type system, making enums act like algebraic types is rather... messy
 
@RonniSkansing Basically everything before 'else' works. The 'else' statement needs to add one day to the date, because php shows 2015-04-00 as 31 March 2015. I'm receiving two errors right now: 'Warning: DateTime::createFromFormat() expects at least 2 parameters, 1 given' and 'Fatal error: Call to a member function modify() on boolean in'
 
especially since that's not what most people will expect.
 
@MichaelCox okay =]
 
6:01 PM
@MichaelCox read the warning carefully
 
I will never tire of this sublime quote from Douglas Adams, about democracy, and why lizards rule the world. http://t.co/TXEElxw7Sd
 
@FlorianMargaine I did, but as I said I'm a beginner, and as far as my knowledge goes everything is fine. I realize it's not, but that's why I need help :(. I'm learning this on my own and it's quite hard at times. I'm not the smartest person around I guess ^^
 
as you can see in the top
public static DateTime DateTime::createFromFormat ( string $format , string $time [, DateTimeZone $timezone ] )
the method takes two args and one optional
in your code
DateTime::createFromFormat("j m y, .$row[game_release]");
you are giving it 1 argument, a string
maybe you wanted to do something like
DateTime::createFromFormat('j m y', $row['game_release']);
 
^^ quotes for game_release
 
Thanks, fixed
 
6:07 PM
Hey, one error gone :)
 
And I am hoping you understand why the error was there before, else feel free to ask
 
It's mostly the syntax, that I used my quotation marks wrongly? or am I completely mistaken
 
Yes, instead of passing 2 arguments, you only passed one.
a string with all of the content
What is the next error?
 
Fatal error: Call to a member function modify() on boolean
 
Okay, so if you on the line before the ->modify write
var_dump($date); die;
(feel free to look at the php doc at var_dump to learn more about it)
 
6:11 PM
bool(false) is what I get now on top of my page, and none of the results are shown
 
yes, the variable is the type bool (boolean) and false
if you look back at the documentation for the function you are using php.net/manual/en/…
you can read that it either returns a DateTime object OR false on failure
 
yep
 
So now you should be able to conclude that createFromFormat failed
and returned false
which you can not run the modify method on (as it is not a object)
So I guess now you are wondering.. why did it fail? =]
 
That does make a lot of sense. I learned this from a Stackoverflow topic because I needed to add one day, I haven't used it before
Well yes, it's still a big mysterious ^^
 
So on the line before the createFromFormat
var_dump($row['game_release']); die
this should tell us the what the content is before you pass it to the create function
 
6:19 PM
string(10) "2015-04-00"
 
okay, so the first argument you passed to createFromFormat was the format which the second argument time should be in
the format of the string you are showing me is
Y-m-d
(and abit of a weird date)
try changing the format (first argument) to 'Y-m-d'
 
Ye when the var_dump printed that, I changed the first argument but the error didn't change :(
 
could you repaste the code into pastebin and hand me the link with the updated code
 
Anonymous
5 hours ago, by Patrick
@SergeyTelshevsky Be aware that there is no session component included. I keep trying to get people to write one but no one wants to :P
 
Anonymous
6:30 PM
@Patrick lets do it
 
Anonymous
no hurry, no time limits
 
Anonymous
complete freedom whenever to commit :)
 
6:44 PM
@ArunPoudel Why?
 
@RonniSkansing Did I mess things up?
 
7:09 PM
@Martin To reset mysql password
 
Hey @MichaelCox, I was just away =]
you forgot the -
 
Y-m-d
 
@RonniSkansing Hey man.
 
7:13 PM
Omg sorry... It works now <3 Is there any way (sorry to ask for more) to have the month as 'Mar' instead of '03'? I read that it's supposed to be 'M', but we used that
 
I got it! Thank you a thousand times @RonniSkansing, I wish I could return the favour in some way.
 
@ArunPoudel Ah okay. Well I was pretty bad in my explanation as it wasn't my MySQL instance that was an issue, it was phpmyadmin. the issue has been resolved though, thanks anyway!
I will keep that in mind for future issues
 
@MichaelCox I know right, Ronni is awesome.
 
@Martin Glad I could be of assistance.
 
http://stackoverflow.com/questions/29684129/having-database-error-ho‌​w-do-i-fix-it
 
@PeeHaa I know. For it to be vulnerable you need to do the silly thing first. OP mentioned it's an array of identifiers and showed numbers - even if they are dynamic but numbers - it still is fine
 
7:37 PM
@ircmaxell don't treat everyone as a dumb and the life will become easier
 
we're not treating everyone as dumb
 
you are, with that warning
 
we're realizing the truth, that SO is a knowledge base where people come to get answers to questions they don't fully understand
 
That question is about array of numerical id's
if anyone dumb with a dynamic array of numerical id's come and copy-paste it - they are still fine
if anyone with something other copy-paste it - it's their problem that they take answer for the non-matching question
 
@zerkms "fine"
 
7:41 PM
@zerkms Except that the answers are more general.
We have at least 5 other questions closed as dups of that one.
 
Well, don't close as a dup if it does not match
or don't blame whose answer is not general enough
 
They aren't exactly the same question; but that's the point. They are all asking how you do an IN statement in PHP.
They are in-essence the same, and we treat them as dups.
 
the difference is trivial
 
And in the general case you should protect against SQL injection.
 
Well, if you have an array of numbers
and you guarantee that
 
7:42 PM
especially since one is a general case of the other
 
you DON'T NEED to escape it
 
and if you don't know enough to realize that, the warning is needed
 
the warning must be softer
 
@zerkms you also don't need to dynamically bind it
@zerkms very much disagree
 
now it states what is not correct
it states the code is currently have a vulnerability
while it's not
(see my offer/bet)
 
7:43 PM
 
Except the answers apply to more general questions.
This is what you aren't understanding.
 
haven't seen anyone applied for it, it is easy for you to exploit isn't it?
 
your pedantry is literally going to cause people to put vulnerabilities in their code
 
@zerkms Simple, if I have an array of "numbers" that come from a form.
If I have a literal array of numbers, then sure -- I agree with you. But if you have a literal array of numbers why don't you just write a literal query?
 
@zerkms you want to make it better? write a new answer that goes into the details of hard-coded vs input and explains it all and the different techniques for different cases.
and you know what'll happen? It'll sit at the bottom while that bad answer sits at the top and keep getting more upvotes
 
7:45 PM
I don't want it better - I just don't like the incorrect WARNING being put to someone's answer
 
that is why that warning is needed
it's not incorrect
 
@zerkms It's a bad answer anyway, by definition of what SO considers to be bad answers.
 
it is incorrect for the given context
 
it's only incorrect if you are overly pedantic (far more than the average person reading the answer)
 
It's 2 lines of code -- no explanation.
 
7:45 PM
and the warning does not reveal a context when it is correct
@LeviMorrison that's right - a particular answer for a particular question
 
@zerkms "given context" do you even SO?
 
when someone asks how to apply md5() function you just show that, but don't teach people cryptography from the scratch
 
@zerkms Stack Overflow considers code only answers to be bad.
 
no, you first question why they are using it in the first place. You asking to hash passwords? In which case you shouldn't do that
 
with this I agree
 
7:47 PM
Give me a minute and I can find a link for it. I was in the review queue when I found this question in the first place.
 
there are 3 kinds of answers:
 
@ircmaxell "I need to generate a password for postgresql"
 
1. Answer the literal question
2. Answer the implied question
3. Solve the user's problem
 
"and it uses md5"
 
@zerkms the correct answer is then "no it doesn't"
 
7:48 PM
It does
"there are 3 kinds of answers:" --- that's what happens when you try to generalize
 
you're wrong, yet you just want to pedant it away
 
okay
 
Go ahead, remove the warning and contribute to this world being even more of an insecure piece of shit than it already is
 
well, I don't feel I can modify other people's answers that much (even if they are incorrect or were modified incorrectly)
 
nobody fucking cares about security. "Secure first teaching" is something that people like you just pedant away
 
7:52 PM
@ircmaxell If he removes it I'll just revert it. Keep in mind I found this question and these answers in the Low Quality Review queue. That's the whole reason I got started on this question and why we are talking about it.
 
"in this edge case it's not important" is only useful if you fucking understand it's an edge-case
which the vast majority of people learning from a question like that don't understand
hence why it's a fucking bad answer
yet you want to come in here and argue the pedantry of it. Normally I'm all for arguing pedantry. But in this case, the pedantry will literally make people less secure. Hell, they don't even know enough to not upvote the answer anyway.
 
"Secure first teaching" --- Levi's answer does not teach as well
 
and making people less secure is the worst of all evils
 
I only have an answer because it's obviously a common question and all of the answers were low-quality except for maybe the community wiki by Common Sense.
 
@zerkms no, but it's fucking secure
 
7:53 PM
so it's not teaching
 
they don't need to know about why, they can just do and be secure
then as they learn more, then they can figure out the nuance of it
 
@zerkms Uhm...
 
:-D
 
> The PHP code below uses prepared statements for MySQLi or PDO to help mitigate SQL injection attacks.
How is that not teaching?
 
teaching isn't always about explaining everything
sometimes it's about giving useful tools and hand-waving over the why until the student is ready for it
 
7:54 PM
@LeviMorrison well, it's too broad subject for this phrase to teach something
they would think "If I use prepared statements I'm always safe - a guy from SO told that"
 
@LeviMorrison I know, if it didn't become clear with the rest of the rant
 
@zerkms Better than code-only that leaves you vulnerable to SQL injection.
 
@zerkms which is true, at least if you use them properly
 
If you don't use prepared statements you can be safe as well - which is also true
 
yes it is
however the "how" becomes a lot more complicated
it's like birth control
sure, condoms and the counting method are both equally as effective when used perfectly
 
7:56 PM
both require understanding the issue
you cannot solve it properly unless you understand it, irregardless of what you use
 
but if you don't use it perfectly, condoms drop a few % points whereas the counting method goes nearly to 0% effectiveness
@zerkms PS require you to understand a SHIT LOAD less than trying to not use them
 
I bet the bestest solution for now is to contact the author twitter.com/FlaviusStef
 
@marcio He didn't respond to any of the comments.
:/
I don't think he cares.
He also can't delete it because it is an accepted answer.
 

« first day (1643 days earlier)      last day (3302 days later) »