« first day (1641 days earlier)      last day (3297 days later) » 

user895378
8:00 PM
Probably not.
 
@salathe can you (int) an object?
 
@salathe (just do (MyEnum::low)->ordinal())
 
user895378
MyEnum::low->ordinal() ^
 
@marcio totally
Don't make me call ->ordinal()
 
At least presently you have to surround it with parens.
 
8:00 PM
Urgh even worse
 
user895378
Devil's advocate: are we sure that because the enum functionality here overlaps with generics we shouldn't try for a unified solution to the generics question?
 
@salathe but you always get 1 and a notice 3v4l.org/ClAms
 
@marcio And your point is? :)
 
@rdlowrey where's the overlap?
 
@salathe if I got it right, you said you want (int) $enum to do a implicit call to $enum->ordinal(), right?
 
8:03 PM
@marcio Yup
 
that doesn't fit with what (int) does for the other objects
 
it's a good job it's an enum, rather than an object then. :)
 
but if we want (int), we better have (array) (obj) (string) (null) etc - oh god, (null) is back xD
 
@salathe What do you want for (string) $enum?
 
@LeviMorrison Initial choice: (string) (int) $enum
 
8:04 PM
I'm going to suggest that you suggest that I should do $enum->name().
lol
 
If I can't do something_that_persists_to_database(MyEnum::isAwesome) and have it do sensible things...
(where database stores as int, just to be clear)
 
json_encode($enum) // xD
 
@salathe Just call ->ordinal()
 
@LeviMorrison No
 
Why can't you call ->ordinal()?
 
user895378
8:06 PM
@ircmaxell to me the inability to specify custom values in the enum (i.e. being limited to ordinal 0,1,2,..., n) means the main functionality for this implementation is testing for membership in a set. At least from the typing perspective. But after talking through that explanation I think there are actually other benefits (readability). So I've essentially talked myself out of it.
 
I never said I can't
 
Enums are objects, by the way.
You can't expected the database to know how to get a meaningful value out of an object automatically.
 
I'll stick with MyObject::SOME_CONST, they still win against this iteration of enums.
 
@rdlowrey ah yeah
 
@LeviMorrison isn't that just how they are implemented? Should I need to care for that while using them as random developer?
 
8:07 PM
@salathe There's a reason this not allowed in any modern enum implementation. C/C++ had too many issues.
 
If I can't auto-cast to int, nor use them as bitmasks... I'll totally stick with constants.
that's basically 99% of my use for "enums" in PHP anyway
 
user895378
Devil's advocate: but you can't typehint against constants :)
 
@rdlowrey I don't care :)
 
user895378
Devil's advocate to devil's advocate: but you can implement this style of enums right now in userland yourself
 
user895378
lol
 
8:08 PM
@salathe then you don't need enum at all, just keep using constants
 
@marcio exactly
 
that's not my case though :)
 
@rdlowrey I've done that :-)
 
user895378
@LeviMorrison I think it might be worth discussing why this is useful in the language when we can do the same thing in userland today
 
@marcio great, you enjoy your case and I'll wait for the vote
 
8:10 PM
@rdlowrey Well, you can't.
 
user895378
@LeviMorrison (I'm not saying it's not ... I just think mentioning why streamlining the process is a benefit to the language is a good thing).
 
You can't use objects in constants.
We also don't have static constructors.
 
user895378
@LeviMorrison Right but you can create your own object heirarchy is what I mean
 
If we had that you could implement this completely in user-land with plenty of boilerplate.
 
@marcio Probably :)
 
8:11 PM
:P
 
I hate being reminded why we need tests :-(
 
user895378
@LeviMorrison that's the kind of thing I'm suggesting putting in the RFC ... just a brief discussion of why a similar approach in userland would be clunky and suboptimal
 
What would you guys think about casting an enum to int using the ordinal and casting to string using the name? @bwoebi @marcio @rdlowrey @NikiC
 
I'm okay with it, it won't bastardize the feature and won't kill anyone I guess.
 
user895378
Kinda depends on whether or not you want to stay consistent with existing objects
 
8:12 PM
;)
 
user895378
It's like a philosophical decision: is an enum an object or a special thing?
 
@LeviMorrison I'm okay with the int cast… but I'd like (string) (int) $enum === (string) $enum
 
@LeviMorrison for the string case, you mean by default and allowing overriding __toString() if wanted?
 
noooooooo
 
(since, enums are objects... right?)
 
user895378
8:13 PM
@LeviMorrison hehe I guess I just didn't translate that in my head to "this is a lot of ugly boilerplate" but I think you're right :)
 
@salathe yes… but they don't allow userdefined methods.
 
@salathe In the future user-defined methods may be allowed. I don't think they are necessary for an initial enums proposal.
 
@bwoebi don't currently allow...
 
user895378
What's a use-case for allowing user-defined methods on an enum?
 
@rdlowrey See practically every enum in Java ever.
 
8:14 PM
@salathe exactly. And that's why we don't care about that for now.
 
@rdlowrey overriding a crappy default __toString() behaviour *raspberry*
 
I would prefer not allowing enum values to cast to other types but I don't feel that strongly against it.
ordinal() is logical for (int) and name() is logical for (string).
 
user895378
@LeviMorrison to me that's an argument for "why I should've used a regular class and not an enum"
 
@rdlowrey Enums have the advantage of having a finite number of children.
 
calling a method on an enum value just seems... totally against my nature
 
user895378
8:16 PM
@salathe I am agree with all
 
user895378
@LeviMorrison So create a class that uses an enum
 
@rdlowrey you want to store the enum on a class property constant?
 
All I want enums to be is a type-hint-able int, really.
 
@rdlowrey I don't understand how that changes anything?
 
user895378
@LeviMorrison I'm arguing that an enum shouldn't be thought of as a class on steroids. It should just be an enum.
 
user895378
8:17 PM
@marcio No, I'm suggesting defining your enum in one place and defining your class in another.
 
user895378
The enum is just a set of values.
 
user895378
It doesn't (shouldn't) have behavior.
 
@salathe I think I'm with you, just haven't thought about it enough to make my position concrete
 
@rdlowrey I don't know how this changes anything
 
@rdlowrey @salathe 100% agreed
 
8:18 PM
I quite like Rust's enums. I like how Haskell does them too.
 
user895378
@LeviMorrison I'm only arguing against allowing userland to specify methods on an enum ...
 
user895378
But I haven't thought through it completely. Things like __toString() could be problematic for my position.
 
How do you have a finite set of children and no other inheritors?
This is actually a very common use-case for data structures.
 
holy crap, agreement... with me... *swoon*
 
user space __toString on enum is not a good idea IMMO, it breaks portability because you never know what crap someone else will implement on another library
 
8:20 PM
In other languages there are packages... which we don't have.
In other languages there are enums with methods... which we don't have.
 
user895378
7 mins ago, by rdlowrey
It's like a philosophical decision: is an enum an object or a special thing?
 
user895378
^ that's just the question I'm trying to answer
 
/me points at html5zombo.com - problem solved
 
In other languages there are enums with definable values... which we don't have. (sorry :P)
 
@rdlowrey I'd say both.
It's a special object.
@salathe They are just inheriting C's mistakes :P
 
8:21 PM
I'd say it's a ValueObject btw
:P
 
The fact that it's an object should be an implementation detail, though, not the focus of it, right?
 
Every modern language I am aware of does not allow values, by the way.
 
@LeviMorrison I don't think that's a good idea. The chance that it will happen implicitly and by accident is too high
 
@NikiC You mean like weak typing for all our scalars currently?
 
@LeviMorrison okay I get it... I use dinosaur languages
 
8:22 PM
@NikiC @LeviMorrison I'm okay with it happening on loose compares and explicitly. But I'm not okay with $enumVal + 2 being interpreted as $enumVal->ordinal() + 2.
 
user895378
old programmer is old
 
@bwoebi Eh, I don't think those can be separate things in PHP.
 
@LeviMorrison Adding implicit casts to int basically means adding enums instead of enum classes, if we talk C++.
 
@bwoebi yuck, I think this was about (int) only
 
@NikiC I agree, which is why I haven't proposed it.
 
8:24 PM
@LeviMorrison you can use the compare zval object handler for that.
 
I'm just trying to get a feel of what everyone else things.
@bwoebi Sure, just make the addition happen in a function and it's now done anyway.
That's my point.
 
@bwoebi but why would compare support comparison with integers? makes no sense imho
 
You cannot prevent it from being used in addition if there is a way to convert it to an int on the language level.
 
if you're using enums, use the damn enum
@LeviMorrison Well technically you can. I think do_operation takes precedence over cast
 
@NikiC to not have to MyEnum::values()[$int] == $myEnum … that looks too boilerplatish
 
8:26 PM
@NikiC Just push the addition to a function that is typed with int and viola.
Or use parens for order of operations.
I guess I'll straw poll it to get a feel for what people are thinking.
 
@LeviMorrison But you do know that this room always votes wrong on straw polls?
 
it's the comic sans like font on that poll platform, it influences me to pick worst options
 
The formatting sucks too badly.
And I typo'd the question.
No more strawpoll.
 
I think I still prefer to have errors on the comparison thing, it's a bug source
 
8:32 PM
Sure, but that's not foolproof.
If you compare the enum to an object with a compare handler and the enum is on the right-hand side the enum's compare handler will not be used.
 
ok, I get it.
 
Actually that's not true either, since all > are swapped around to be <.
 
you mean enum::something > 1 is different than 1 < enum::something?
 
No, those are always the same.
$enum::value < $someObjectWithCompare
$someObjectWithCompare < $enum::value
Those can have drastically different results because of the object handler that is used.
 
compareTo()*RUNS*
 
8:36 PM
When doing equality the handler that is used will be the object on the left-hand side.
It's just all confusing.
 
@LeviMorrison that sucks :(
 
@NikiC I assume the cast handler is used for operators if the do_operation handler doesn't exist?
To convert the object, I mean.
 
@marcio ?
 
@taco cool isn't it?
 
doesn't the "micro" in "microframework" mean "small, lightweight", or are Laravel using a new dictionary
no... they're probably using an artisinal dictionary façade
 
@andrea I tried wiping my screen where you typed the ç .... I am not a smart man
 
9:08 PM
heh
hmm
someone complaining in the reddit thread that all microframeworks look the same
not yolophp
<?php

use function yolo\y;

yolo\yolisp(y('yolo\yolo',
    y('lambda', y('request'),
        y('new', YoLo\resPONsE::clASS, y('quote', "yolo \u{1f640}"))
    )
));
no other microframework looks like this
also, hmm, embedding a useless mini-Lisp dialect in a framework is so 2014
I should troll people by making one with its own PHP interpreter
AND NOT TELL ANYONE
(why am I even here I quit PHP just under 2 months ago)
 
@Andrea PHP never quits you
3
 
@marcio PHP is never gonna give you up.
Never gonna let you down.
PHP's Never gonna turn around, and desert you. (Well, unless you're Zeev.)
4
 
lol
@Andrea you cannot quit. Once you enter you cannot leave. There is only the illusion of leaving
2
 
So what you're saying is that PHP is Hotel California.
4
 
9:15 PM
You can check out any time you like but you can never leave!
 
Hotel Caliphpornia
7
 
is this a world record for most new starreds in <5 minutes
 
lol
 
actually, that's too close to Hotel Calipornia...
 
Chlorophporm - new ORM in town.
 
9:17 PM
writing a source-to-source PHP compiler is sort-of tempting
 
Cphploroform - superb form and widget library
 
@Andrea which source to which source?
 
@ircmaxell PHP to PHP
One that translates PHP 5.6 code to PHP 5.2 would be interesting. WordPress would love it. ;)
 
write one that translates 5.6 to 7 and I'll be happy
 
@hakre Clorophporm?
@ircmaxell what would you need to change?
There aren't that many big BC breaks...
You know what would be useful? Adding typehints automatically from docblocks
 
9:19 PM
@Andrea well, php4 constructors for one, uniform variable syntax, etc
 
I wrote a tool to locate PHP 4 constructors, and someone else wrote one to auto-fix them I think
NikiC has a UVS issue spotter
 
@Andrea puts your data to a rest in the data daze .
 
#experiencedprogrammerproblems: all Qs you asked on StackOverflow in the last 2 years are hard ones nobody can answer stackoverflow.com/users/736162/…
 
4
Q: Calling RNGCrypto From COM's DOTNET Class From PHP

ircmaxellI'm attempting to call RNGCryptoServiceProvider->GetBytes() from PHP via the COM layer. I can get it to connect to the class, but every time I call the method, I get one of two errors (relating to the parameter). I think it has something to due with the fact that GetBytes takes a fixed size byt...

^^ still no answer there
 
Wait, there are people that actually use the dotnet extension?
 
9:29 PM
@Andrea Also have an automated fixer for that
 
@NikiC oh, awesome :)
 
@Charles I tried to...
 
@ircmaxell Thus your mistake :)
 
exactly
 
9:36 PM
@rdlowrey Interestingly enough I created this proof of concept because I tried to create a suitable enum in user-land. After a few hours I convinced myself that no current approach is suitable, but SplEnum comes close.
 
anyone know a trick to convert a PDF containing farsi text into outlines / svg?
 
I'm going to guess no, they don't.
 
31
A: Convert PDF to clean SVG?

Saintt Sheldon PatnettInkscape is used by many people on Wikipedia to convert PDF to SVG. http://inkscape.org/ They even have a handy guide on how to do so! http://en.wikipedia.org/wiki/Wikipedia:Graphic_Lab/Resources/PDF_conversion_to_SVG#Conversion_with_Inkscape

The comments imply that text gets turned into paths, which should be safe.
Might require the fonts be installed though...
 
@ircmaxell Wouldn't you just pass an array of ints?
 
only if the option is offered for PDF import, in my case it is not - tried inkscape first.
 
9:38 PM
@Andrea try it
I tried all sorts of data types
 
also failing with illustrator
 
welp
 
@hakre You might be out of luck on that one then, if not even Illustrator can do it correctly.
 
@Charles it's also late :)
so I take is a bitmap then for the moment.
ah, I think I can try openoffice
only got 50%
 
I need to figure out:
- serialization / unserialization
- opcache
- how to convince more people to vote "yes" for my RFC
Looking okay for now.
 
9:43 PM
...you made an enums RFC?
 
ha inkscape via poppler made it. Inkscape FTW
 
ooh
 
@hakre w00t, good to know
 
in some minute I know if re-importing works.
 
@Andrea Still draft but yeah.
 
9:45 PM
@LeviMorrison Are you making actual constants?
As in, entries in the constants table?
 
Yes.
They are objects.
 
Ah.
See, I was thinking I'd either 1) special-case enums in constant lookup or 2) add something akin to __get for class constants
@LeviMorrison Serialisation would be relatively simple I'd think, enums are just another class basically
Another thought: should enums implement some kind of enum interface, or extend an enum abstract class? (though this makes the most sense if you can have a class parameter, which you can't)
 
@Andrea The handlers are completely undocumented. Logically serialization is not difficult; just have to make sure that the existing instance is returned instead of another instance with same properties.
 
@LeviMorrison Gotcha.
 
@Andrea I've opted not to for now. I am not really sure what it offers at this stage.
If we had generics Enum<EnumType> could work.
 
9:49 PM
@Charles: It worked. Finald PDF from 3 MB down to 1.2 MB and all vector.
 
As in: enum Singleton { Value } implements/extends Enum<Singleton>
 
Also, the ability to set ordinal values can be important
e.g. days of the week
On the other hand, I love the simplicity of your proposal :D
 
@Andrea Eh, I disagree.
In basically all modern enum implementations that is unsupported.
Would rather have algebraic data types that allow you to create custom properties.
 
also, would the current implementation lock out ADTs etc.?
If there can only be one instance of a given enum member
 
@Andrea Potentially.
Not syntactically it won't.
But the way I've seen other stuff work is that if you have no properties they share the same instance and if you define them with properties you make new instances.
We'd need some way to deconstruct them though.
 
9:54 PM
    switch ($action) {
        case RenewalAction::Approve:
            return RenewalAction::Deny;

        case RenewalAction::Deny:
            return RenewalAction::Approve;
    }
this is what bothers me
It's pretty, but breaks down if members can have properties
 
@Andrea It does general comparison like any other value. I haven't done anything special there.
 
I realise that
 
It would probably fail with objects with custom properties.
For algebraic data types to be really useful we need pattern matching or some other way to deconstruct them.
So I'm not sure how big of a deal the current enum case behavior is.
 
the problem is trying to model ADTs as classes
 
@Andrea That's how Rust does it I believe. It's certainly how Ceylon does it.
 
9:57 PM
Because they're sum types
 
I think Scala has them; if so they are almost guaranteed to be classes there as well.
Yep.
 
Hmm
the thing is
each member of the enumeration is its own type, in a sense
 
@Andrea They subclass.
 
But the type of any instance of a member of the enumeration is the enumeration itself
For example, the type of True isn't True, it's Bool
 
enum Bool {
    False,
    True
}
 
10:01 PM
enum Bool {
    True,
    False,
    FileNotFound
}
Get it right, man.
 
final class Bool {
    final const False = new Bool(){},
    final const False = new True(){}
}
^ Essentially that's what is happening.
 
-4
Q: question for PHP , I don't speak good English

BrahimceIs it true that love is erased SQL functions the What is the benefit pdo ? SORY i don't speak english .

 
An anonymous subclass.
 
In a sense.
 
10:02 PM
Love is erased.
 
Love is erased SQL. I dunno, that's kind of right.
It always feels good to delete code.
 
@Andrea Pretty much exactly in Ceylon and Scala :)
 
@Charles filenotfound is error code 13, isn't it?
anyway gn8 @all
 
Hmm
 
Actually Scala doesn't have them. This article I am reading just described how you can do something mostly equivalent in Scala.
 
10:03 PM
@hakre That may be true, but not to those devs. G'night!
 
I would say that, well, that doesn't work out, you want getclass() to give you the enumeratiin
But
 
But Ceylon definitely has them and it runs on JVM, so that's how it will work there.
 
You don't actually do that very much
It would work.
 
Algebraic data types would be more invasive to implement
Since you need something like:
 
function foobar(SomeEnum $foo) {
    switch (true) {
        case $foo instanceof SomeEnum\Member:
        break;
        case $foo instanceof SomeEnum\OtherMember:
        break;
    }
}
 
10:06 PM
new Tree::ValueNode($left, $right, $value);
 
hmm
function foobar(SomeEnum $foo) {
    switch ($foo->type()) {
        case SomeEnum::Member:
        break;
        case SomeEnum::OtherMember:
        break;
    }
}

foobar(SomeEnum::Member());
 
...I just had an outrageous idea.
 
oh?
 
The value stored at SomeMember::OtherMember is an object that implements __invoke.
lol
$node = Tree::ValueNode($left, $right, $value);
 
that... won't work
 
10:12 PM
We just need a match() construct.
 
Swift's enums are sensible
just do whatever those do
:p
anyway, I'll be off
 
match ($maybe) {
    Maybe::Empty => echo "Empty",
    Maybe::Something($value) => echo "Something($value)"
}
 
posted on April 14, 2015 by Seldaek

* Break: The following event classes are deprecated and you should update your script handlers to use the new ones in type hints: - `Composer\Script\CommandEvent` is deprecated, use `Composer\Script\Event` - `Composer\Script\PackageEvent`...

 
@Andrea They extended case syntax to have deconstruction, it looks like.
So more like:
switch ($maybe) {
    case Maybe::Empty:
        echo "Empty";
        break;
    case Maybe::Something($value):
        echo "Something with value: $value";
        break;
}
 
hello guy's ... i have an argue with my teacher.... about (float)
i have input type="number" name="float" value go be : 0.22.3.19.54 (teachers attempt)
The question was that i need to check if the input is_float
So in the post i did (float)$_POST['float'] ..... what would go be the result if i echo (float)$_POST['float']; to you.... (he expect to get back what he putted in)
 
10:20 PM
@HenryW There's not much to expect. If it's part of your grade to get the same value back then it simply isn't a float.
 
exact
that is what i say
 
Consider using is_numeric on it and erroring out instead of casting, if preserving input is part of the task.
 
nono the task explicit say ... put a number and ceck if is_float ... , the initial goal is to put a comma delimited number like 0.22 and get back result after the comma........
but he want to put 0.22.55.6.78.3 and he want back 22.55.6.78.3
however... the task say.... check if is_float (?????????)
 
@HenryW is_float
However... it will return false when it's a string.
 
yes... so i am right
 
10:24 PM
So the only way for is_float to return true on a string float is indeed to cast it.
 
bah,...... that is the 3th i outnumbered....
 
And casting it will create a float.
 
3th teacher
 
The task is flawed or poorly worded.
 
I have installed Phalcon extension successfully (checked on phpinfo), but when I am trying to use its namespaces in PHPStorm, it doesn't find it, anyone ever experienced this?
 
10:25 PM
they ask me in the course how to do stuff lol
 
@Charles Or we are having language translation issues.
 
the other way around....
 
@LeviMorrison That is also a possibility
 
well... thank you for the feedback.... i go send him a mail back.
 
@Andrea You know what? I'm going to try implementing basic object deconstruction lol
(in case statements)
I think the issue will be that we have, erm, really strange things we allow in case statements.
If this worked it could maybe happen easily:
class Obj {
    public $foo;
    public $bar;
    function __construct($foo, $bar) {
        $this->foo = $foo;
        $this->bar = $bar;
    }
}

list($foo, $bar) = new Obj(1, 2);

var_dump($foo);
But it's not allowed.
Object has to implement array access, which is probably not what is desired in the general case.
But maybe I'm wrong; I don't know.
 
10:52 PM
` //$number = '0.22.99.00.55'; //false

//$number = '0,22.99.00.55'; //false

//$number = 0.22.99.00.55; // VERY false

$number = 0.22; //VERY VERY VERY MUCH TRUE

(float)$number; //you can quote this out for testing purposes.
if( is_float($number) ) {

$explode = explode('.', $number);
echo $explode[1];
echo '<br>';
echo $number;

}else{

echo $number . ' is NOT a float';
}`
arggg sorry, failed to make it output as code. (i ned to practice that in an empty chat lol)
 
Go to the sandbox room.
 
11:12 PM
hmm
how do I get a null byte into serialize() output?
 
php > var_dump( serialize(chr(0)) );
string(8) "s:1:"\000";"
Something like that?
 
hmmmyeah
I used 3v4l.org/0KVA7 for now, but I still don't get the bug that I wanna get :D
 
What the hell.
What are you trying to break?
The null byte private property thing?
 
No, just writing a test for github.com/doctrine/cache/pull/62
I can't seem to reproduce it :|
 
echo "woot\x00Yeah"; ?
 
11:21 PM
What's the bug, exactly? SQLite truncating on null bytes?
 
Either that, or on long values
but I can't get it to work even with 1GB strings :X
seems like sqlite "just works"? O_o
 
Might be library version dependent.
 
yup
 
Prolly something ancient like CentOS 5
3.3.6 is the version there...
3.6.20 on CentOS 6
 
function showRawCharacters($result) {
    $resultInHex = unpack('H*', $result);
    $resultInHex = $resultInHex[1];
    $resultSeparated = implode(', ', str_split($resultInHex, 2)); //byte safe
    echo $resultSeparated;
}

$foo = serialize("woot\x00Yeah");

showRawCharacters($foo);
Output is: 73, 3a, 39, 3a, 22, 77, 6f, 6f, 74, 00, 59, 65, 61, 68, 22, 3b
 
11:24 PM
@Charles so.... E_DONT_FUCKING_CARE ?
 
@Ocramius More like E_WELL_DONT_DO_THAT_THEN
 
11:49 PM
evening
 
Could you post the code which causes the error in addition to the debug log? — Marc 15 hours ago
 

« first day (1641 days earlier)      last day (3297 days later) »