« first day (3627 days earlier)      last day (1304 days later) » 
00:00 - 23:0023:00 - 00:00

cmb
12:02 AM
try libonig-dev
 
Ahso.
 
Added :)
 
In mysqli: public function fetch_all(int $result_type = MYSQLI_NUM) {}

$result_type OK, or just $type?
I'm not sure if it's redundant or not.
 
12:22 AM
eeee dunno
Also good night I'm sleepy :')
 
12:33 AM
Which mysql dev package do I need to compile ext/mysqli?
I keep getting: /usr/bin/ld: ext/mysqli/mysqli_api.o: in function `zif_mysqli_real_escape_string'

I do have --with-mysqli in my configure directive.
 
@Crell Dunno, it feels like unnecessary to write it out … The point of named params is to be used … and not be avoided by annoying devs who have to write these out often
 
@bwoebi So you'd say just $type? (It's used in a bunch of function/method names.)
 
I feel like result_type is conveying crucial information here
otherwise, no idea what sort of type would be meant
 
Ah, so just leave it?
 
I would've called it a $(fetch_)mode
no
bad idea
just leave it :-D
 
12:46 AM
Ha. PDO calls it $fetch_style.
 
Yeah, I prefer putting the fokus on result though
 
Well, I can't change any of them until I get this thing to compile... How do I get mysqli to compile?
The param is already in a fetch_*() method/function.
 
@Crell what's your issue?
 
make: *** [Makefile:300: sapi/phpdbg/phpdbg] Error 1
/usr/bin/ld: ext/mysqli/mysqli_api.o: in function `zif_mysqli_real_escape_string':
/home/crell/Projects/php-src/ext/mysqli/mysqli_api.c:1906: undefined reference to `mysql_real_escape_string_quote'
collect2: error: ld returned 1 exit status
Repeats thrice.
 
did you buildconf and reconfigure already?
 
12:51 AM
Yes.
I can try the whole thing again from scratch, I guess.
make clean && ./buildconf && ./configure --with-mysqli --enable-mbstring && make -j3 TESTS=ext/mysqli/tests

That look right?
 
I think Nikita broke it
 
sigh
 
Checking whether I can fix it…
 
Whoops!
So rebase on master and rebuild from scratch?
 
no need to rebuild from scatch
but yeah rebase it
 
1:01 AM
Yay. Works now.
Filing this PR, then will sort out the result/fetch/type/thing globally across all the extensions another time.
@bwoebi github.com/php/php-src/pull/6172 - In case you have access to add it to the list before @Girgias wakes up. :-)
Thanks for the quick fix!
 
1:26 AM
@Crell added
 
 
1 hour later…
2:39 AM
Hi guys. I am a beginner to web development and I have got a client for a e-commerce website. Can I get some tips from you? My deadline is tomorrow. I have worked on adding the form details through which a user enters the details of the product he wants to sell
 
You're a beginner and you're building e-commerce websites with a deadline of tomorrow? The best tip is... don't bite off more than you can chew
4
Because it sounds like you've dug yourself into a hole =\
 
Now I want to display the product data in buying page. I wanna sort it according to date the product has been posted, according to category, location of the product and price of it. I have multiple tables for category of products! How can I search through those multiple tables and sort out the products?
Yah bro. I tried my best and I am working with collaboration with another dev. We have completed most of the part. Now we have to display the products and sort them out! My last hope is in this community! If possible provide your support mate. Thank u
 
You need to look at SQL joins and sorts
 
K. Thank u mate
 
Wes
\o
 
2:53 AM
o/
 
3:20 AM
I'm in season six of TNG, tried rewatching a season one episode and omg it's so bad, how did I used to watch this
 
LOL
Yeah the acting and stories got better
How are you doing? Has the new job started yet?
 
I start Monday, I'm excited
 
^.^
 
I have my work computer set up on my second desk, I had to move my keyboard and mouse to it since I'm more familiar with using them for programming. Busted out my old steelseries board with cherry reds to use with my main desktop, one of the only keyboards qualified for a zombie apocalypse, second maybe to the Model M
It's durable, but the key caps go flying
I was going to stick it on my work computer, but since it uses a European layout and it takes me a bit to get used to, I figured using the keyboard with the more familiar layout would be better for work.
 
yup
 
Wes
3:35 AM
mark, do you know where the == operator is defined in php?
23 hours ago, by Wes
hi everybody. in what order does == compare fields of objects? does it compare inherited classes first?
 
!!lxr ==
 
Total number of search results: 789. Showing the first 5 results.
• [ /php-src/win32/ioutil.c::72 ] opts->attributes &<b>=</b> ~FILE_FLAG_BACKUP_SEMANTICstatic MyPathCchCanonicalizeEx canonicalize_path_w <b>=</b> NULL;
• [ /php-src/win32/ioutil.c::78 ] opts->attributes <b>=</b> 0;
• [ /php-src/win32/ioutil.c::82 ] current_umask <b>=</b> umask(0);
 
Wes
i tried to search on lxr but it was just a desperate attempt. i tried to search "comparator" but no good result showed up
 
• [ /php-src/win32/ioutil.c::88 ] opts->access <b>=</b> FILE_GENERIC_READ;
• [ /php-src/win32/ioutil.c::90 ] /*opts->attributes |<b>=</b> FILE_FLAG_BACKUP_SEMANTICS;*/
 
😳
 
Wes
3:41 AM
!!lxr zend_get_std_object_handlers
 
Total number of search results: 9. Showing the first 5 results.
• [ /php-src/Zend/zend_object_handlers.h::180 ] `#define <b>zend_get_std_object_handlers</b>() `
• [ /php-src/Zend/zend_interfaces.c::640 ] memcpy(&zend_internal_iterator_handlers, <b>zend_get_std_object_handlers</b>(),
• [ /php-src/ext/ffi/ffi.c::4906 ] memcpy(&zend_ffi_handlers, <b>zend_get_std_object_handlers</b>(), sizeof(zend_object_handlers));
• [ /php-src/ext/ffi/ffi.c::4937 ] memcpy(&zend_ffi_cdata_handlers, <b>zend_get_std_object_handlers</b>(), sizeof(zend_object_handlers));
• [ /php-src/ext/ffi/ffi.c::4961 ] memcpy(&zend_ffi_cdata_value_handlers, <b>zend_get_std_object_handlers</b>(), sizeof(zend_object_handlers));
 
@Wes zend_compare in Zend/zend_operators.c IIRC
Ah sorry I missed the line about comparing objects
 
Wes
#define Z_OBJ(zval) (zval).value.obj
820 #define Z_OBJ_P(zval_p) Z_OBJ(*(zval_p))
821
822 #define Z_OBJ_HT(zval) Z_OBJ(zval)->handlers
823 #define Z_OBJ_HT_P(zval_p) Z_OBJ_HT(*(zval_p))
824
825 #define Z_OBJ_HANDLER(zval, hf) Z_OBJ_HT((zval))->hf
826 #define Z_OBJ_HANDLER_P(zv_p, hf) Z_OBJ_HANDLER(*(zv_p), hf)
827
828 #define Z_OBJ_HANDLE(zval) (Z_OBJ((zval)))->handle
829 #define Z_OBJ_HANDLE_P(zval_p) Z_OBJ_HANDLE(*(zval_p))
830
831 #define Z_OBJCE(zval) (Z_OBJ(zval)->ce)
omfg
 
Is there a way I can flag an object to be GC'd, but not immediately GC'd. I need the free_obj handler to be called just a little later.
 
Wes
3:47 AM
Z_OBJ_HANDLER(zval, hf) Z_OBJ_HT((zval))->hf

the macro is harder to write than the macro'd code
 
As is often said of turtles... PHP is macros all the way down
 
Wes
1500 // TODO: Less crazy.
 
@Wes The properties are compared in the order declared, from parent to child. heap.space/xref/php-src/Zend/…
@Wes The macro allows structures to be changed or reorganized without having to change the accessors everywhere.
 
Wes
shouldn't search & replace do that? or better, IDEs? i used to write code like that, helper functions built on top of other helper functions. my code was 90% helper functions 10% actual code, and maintaining it was much harder
thanks for the link tho, i was close but not really :B
 
@Wes Sounds much harder than redefining one macro :-P
 
3:54 AM
Can I introduce you to our lord and saviour C++? PHP: No!
 
Wes
but how often do you guys rename this sort of stuff?
 
I'm in much the same boat as Wes, I find it much more difficult to deal with PHP-src's nested macro spam (vs a higher level language using OOP)
 
Wes
((zval*)((char*)(obj) + offset))
that i can't understand :B
 
Take object pointer, cast it to char* so you can offset it by individual bytes rather than sizeof(obj), then add the offset to it, cast it back to zval* for the compiler to know.
 
Wes
i suppose, to know the order, you need to know how properties_info is populated, right?
 
3:59 AM
@MarkR It would be nice, IMO, it was C++. But when PHP was started, C was probably still much more widely used.
 
 
3 hours later…
Wes
6:41 AM
took me 1 week to write 40 lines of text at 90 columns wrap
and that's me being fast
 
 
2 hours later…
8:53 AM
morns
 
thinking about the reddit thread, one thing I could imagine is complicating things for potential new contributors. Due to PHP not having a "leader" there is nobody to talk to to get permission and encouragement to work on stuff with the endgoal of getting it merge being at least 50%+ sure. you need to face an unknown set of contributors that can come out of the woodwork and torpedo your initiatives
i can see how this can be discouraging
 
user1804599
9:13 AM
@MarkR In C++ you could use pointers to data member instead of offsets and write obj->*field. 😄
 
9:31 AM
morning
@Wes hola boi
 
10:20 AM
@MarkR how does c++ really make anything easier comparing nested macro spam against nested template spam?
@Wes some of these macros are quite legacy because the access syntax was more complicated before
Nowadays I'd definitely just write Z_OBJ_HT(zv)->prop directly without using the macro, because it does not help anything
 
10:33 AM
github.com/php/php-src/commit/… @NikiC Okay, apparently githubs branches list (contaoning the commit) is not reliable anymore … checked that before committing to master only :-/
 
10:49 AM
Good morning.
 
11:07 AM
 
11:22 AM
@beberlei contributions don't need to be RFC/code though
 
Wes
@NullPoiиteя where do you disappear for months :D
 
12:22 PM
@Crell I'll start rewriting the RFC to Markdown now (just so we don't both do it).
 
12:37 PM
@Crell @IluTov so, enums are for the purpose of semantics and reflection classes and their singleton values are constants, correct? (the RFC makes that appearance, but it's nowhere stated). The RFC should also tell whether it's possible to create a new instance of the object, what happens when doing reflectionclass->newInstanceWithoutConstructor? What about serialization?
 
@bwoebi We've decided to move the RFC to GitHub so we can track open issues there, can you create an issue for any concerns? github.com/Crell/enum-comparison/issues
 
aye
 
"enums are for the purpose of semantics and reflection classes and their singleton values are constants" Hm, in terms of reflection I haven't thought about it. We don't have constant objects at the moment, right?
 
@IluTov no, we don't … but we have some resources being constants (e.g. STDIN)
when we convert these to objects … we are going to have objects in constants anyway
 
@bwoebi I see. In that case yes I guess making them constants would make sense. Not sure how that will work under the hood, I'm not too familiar with how constants are handled.
 
12:45 PM
@IluTov It may well be that some code needs updating for handling them. Esp. opcache.
We may consider, implementation wise, to cache these as constant asts (with a single ast node) to be resolved upon first access
Or just do our own special enums handling
but the constant ast solution should integrate easiest into existing code I think
 
We'll also have to think about jumptable optimizations. I wouldn't want to lose that just because enum cases are objects under the hood. Although I guess that also only works when the constants are in the same file anyway.
 
once we're in the actual runtime, objects should be unproblematic as constants
@IluTov I think you can just save them by their string name
in the jumptable … and then you anyway do a more precise comparison at that point
(because they're interned strings etc. so lookup will be fast)
@IluTov The alternative to constant asts is actually introducing immutable objects, just like we have immutable arrays. (i.e. non-refcounted) But that may well be a major undertaking, a lot of code assuming objects to be always refcountable…
I cannot estimate the scope of that right now…
 
1:12 PM
CallbackFilterIterator is leaking memory ・ Scripting Engine problem ・ #80125
 
 
1 hour later…
2:19 PM
@Tiffany yes they don't need an RFC, but still you can't be sure they get accepted, because there is not really someone responsible for anything to go through
 
@beberlei I meant docs :P
 
@IluTov I think I've added the most important things I could think of as issue :-)
 
@beberlei what I meant to say is that there are more ways to contribute to the project than just changing php-src
 
@bwoebi Thanks Bob, I really appreciate your feedback :)
 
If you're designing enums I would encourage lots of consideration about data boundaries, for something like PHP I imagine 99% of enums would be persisted via a DB and a mass of IF statements or maps would be hellish
 
2:36 PM
@MarkR Still unsure about that part. Even if we don't offer a solution all it takes is creating a rawValue() and fromRawValue() static method. I'd definitely want to avoid dynamic conversion.
I'll create an issue for it though so we can discuss it :)
 
Currently they're handled in almost all modern code as a set of class constants. If it's made significantly harder than some kind of exception if assigning an invalid value to an enum type, I suspect it would have little uptake.
 
2:50 PM
@MarkR Most enum cases can just be handled by their name
 
@MarkR That varies widely by language, I found. Sometimes they have a natural primitive to map to, sometimes not. Since there's no natural primitive backing, a universal "primitive to enum case" operation doesn't seem possible.
However, iff the default __toString() implementation of "just return the name as a string" is kept, then potentially would Suit::$value_from_db "just work"?
 
And in PHP it's trivial to access constant("Foo::$name")
to map back from storage representation to PHP
 
GMTA.
 
@Crell what does that mean?
 
Great Minds Think Alike.
 
2:52 PM
ah haha
 
user1804599
Maybe Suit::$value_from_db should be case-insensitive.
 
why does that matter?
 
Like I said, I think the data boundary has to be considered first and foremost. Any implementation which causes unsubstantiated grief at the boundary will dramatically cut the uptake of the feature
As in a language like PHP where most requests last less than 100ms, there's very little which doesn't depend on some level of persistence. The odd bit here and there, event names etc
 
@MarkR Question: Where does the bare name of the enum value not suffice?
 
@bwoebi I'm not sure what you mean.
 
2:57 PM
@MarkR Given an enum Foo::Bar, __toString() would return Bar. you can save Bar then and later when reading from DB just use constant("Foo::$value_from_db") giving you Foo::Bar again
in what scenarios is that not sufficient?
 
Somehow I suspect people aren't going to be rushing out to replace integers with varchars for their enums
 
It's basically the equivalent of DateTime getting serialized to ISO format, then new DateTime($iso_from_db) on hydration.
 
@MarkR the ideal case would be replacing it with a native SQL ENUM() type
integers are a really bad representation in the db…
 
user1804599
I avoid enums in PostgreSQL because altering them is annoying. Can’t remove cases for example. That’s why I always use integers.
 
Odd, because i'd be surprised if ENUM was used in more than 1% of projects.
 
3:00 PM
Most PHP devs don't know to even think of enums, because they're not used to them.
 
I said ideal… but using varchar will be more realistic
@rightfold may I sell you to mariadb instead? :-P
 
user1804599
I often use char instead of int and then pick a somewhat memorizable single-character representation in the DB.
 
I don't see that happening. If I change the label on my enum I don't want my entire database setting on fire because some magical label changed
 
user1804599
@bwoebi Not a chance.
 
@rightfold but there you can easily alter enums! :-D
 
user1804599
3:02 PM
Lol no transactional DDL.
 
The enum's value should be entirely independent of its label to any external observer.
 
@MarkR that's sort of like saying "if I change my integer value, I don't want everything going haywire"
 
user1804599
People may also want multiple mappings for the same enum. E.g. one for db serialization, one for rest api serialization.
 
@rightfold that's right … thus you have the possibility to create methods on enum values so that you can define multiple ones
 
Tosh. If I have a class constant representing what would be some kind of enum value (and I have them by the thousands) and I change public const STATUS_ERROR = 500 to const STATUS_ERROR_CODE = 500 that should not detonate my storage layer
 
3:05 PM
I see, that's where we disagree. Constant names should also be constant. I just don't alter their names
 
Then override __toString() to return the old value, and leave a comment saying why.
 
user1804599
You could make a library function that defines such a mapper. You’d still need to define mappings, but no list of if statements etc.
 
user1804599
$dbSuit = mapper(Suit::class, [ 1 => Suit::Hearts, 2 => Suit::Spades, … ]);
$jsonSuit = mapper(Suit::class, [ 'hearts' => Suit::Hearts, 'spades' => Suit::Spades, … ]);
echo $dbSuit(Suit::Hearts); // 1
echo $dbSuit(1); // Hearts
echo $jsonSuit(Suit::Hearts); // hearts
echo $jsonSuit('hearts'); // Hearts
 
(To be clear, Mark, since text is bad at that: Considering the serialization boundary is absolutely an important point. I think we just disagree about how far off from ideal the current proposal is.)
 
user1804599
And if you want something 0-effort, just use strval and Suit::$name.
 
3:06 PM
Now you're talking about hacking in things which shouldn't be an issue in the first place =\
 
@rightfold The __toString() method already provides that, or you can easily make your own method in the enum or case definition.
 
user1804599
Yes, it’s already there, hence 0-effort.
 
Eg, you absolutely could write a public function forDB() for each Case and return whatever you feel like.
 
user1804599
You also need to define fromDB. And it’s not very concise. But you can define a library function as presented above.
 
That sounds like a possible argument in favor of allowing static methods on the EnumType itself.
 
user1804599
3:08 PM
I don’t see why not.
 
user1804599
Static methods are convenient with PSR-4 autoloading.
 
enum Suit {
  public function fromDB(string $val) {
    return Suit::$val;
  }
}
 
and when it's not a string?
 
It's your own method, so do what you want with it.
 
user1804599
enum Suit {
  public static function fromDB(int $val) {
    return [Suit::Hearts, Suit::Spades, Suit::Diamonds, Suit::Clubs][$val];
  }
}
 
3:11 PM
I'm just imagining a queen named Valorie
Queen Valorie of Hearts
 
user1804599
You still need to keep the toDB and fromDB methods in sync. It’s error-prone and boring. And when things are error-prone and boring we want to automate them.
 
So to me that screams "Hey, we missed this completely obvious use case that accounts for 99% of enum-like usage and now you have to go bodge your own solutions"
 
@rightfold note that we probably will provide MyEnum::values()
you can then have MyEnum::values()[$val] and array_search(MyEnum::values(), $val)
 
@MarkR Other than providing mechanisms for round-tripping an enum to/from a serialized value (default __toString(), possibly an EnumType::fromString() sister method), what other alternative is available?
 
3:15 PM
@rightfold or obviously, you can still do the same thing, with a statically defined array (e.g. in a constant).
 
(Honest question; I don't know what the alternative is.)
 
@Crell well his alternative would be associating a value with an equals symbol to the singleton values
 
user1804599
@bwoebi Yes, and you can abstract away all this logic into a library, is my point.
 
and then having methods to get that value (or the reverse lookup)
 
@Crell Attaching a native scalar value to each
Which I believe is how most languages handle it
 
user1804599
3:19 PM
Here is an example that I think has a perfectly acceptable amount boilerplate, for when the default-generated string conversion is inadequate: 3v4l.org/o8RYv
 
@MarkR Many do, but far from all. The ones with full ADTs seem to not. Cf: github.com/Crell/enum-comparison
@bwoebi Thank you for the feedback!
I don't know if I like this, but it's the only way I could see it working:
enum Suit {
  case Hearts = 'H';
}
// Desugars to:
enum Suit {
  case Hearts {
    public function __toString() { return "H"; }
  }
}
The "from" side would be harder, though.
 
user1804599
enumval(Suit::class, $str) or (Suit)$str.
 
Aye some kind of cast would probably make most sense
 
But how do we look it up?
 
user1804599
Store the mapping from strings to suits at runtime as part of the enum.
 
3:26 PM
You already know the values of them, reverse map
 
That assumes the mapping is trivially simple.
 
@Crell I wouldn't do use __toString here though but rather something like rawValue(). I'm guessing int values would be more common.
 
The main complexity would come from those which have multiple enums of the same type.
 
user1804599
Only allow the reverse conversion when the mapping is injective.
 
A user-supplied __toString() (or rawValue() or whatever) could be arbitrarily complex, especially with associated values.
 
3:28 PM
@Crell This only works for unit cases, not associated values.
For cases with associated values this doesn't make sense.
 
There's still nothing stopping someone from sticking a random_int() in their toString if they're feeling malevolent. :-)
Hm. Brainstorm: Allow a specially named constant on a case, to force it to be static?
... Or an attribute? :-)
 
user1804599
Generate the conversion methods if the user does not define them themselves. Make the conversion methods follow the underlying value assignments (= 'H').
 
user1804599
If the user defines their own, don’t guarantee anything.
 
enum Suit {

  case #[Primitive('H')] Hearts;
  case #[Primitive('C')] Clubs;
}
And then that gets used for __toString(), and for round-tripping via some from() method.
Which... might also offer a way to support bitmasking cases, iff they both have integer primitive attributes defined.
 
Aye bitmasking would somewhat require that primative mapping, arbitrary example, JSON encode / decode flags
 
3:32 PM
enum Permissions {
  case #[Primitive(1)] Execute;
  case #[Primitive(2)] Write;
  case #[Primitive(4)] Read;
  case ReadWrite: Read | Write;
}
 
user1804599
That would have strange semantics.
 
Give or take some symbols, what about something like that? Opt-in, nothing auto-generated, but that then supports union unit cases, and the primitive gets used for __toString(), and we can then support a Permissions::fromValue() method that takes one of the primitives and gives you back an enum unit.
 
user1804599
Could you combine any enum values by oring them? Doesn’t seem like a good idea. Would break the coolest feature of ADTs: static analysis exhaustiveness check for match expressions.
 
I would think no. Only in their definition as above.
 
Well C like usually just do, I don't see the huge need to complicate with attributes

enum {
   FOO = 1,
   BAR = 2
}
 
user1804599
3:35 PM
That would be ok, but the syntax is funky. Attribute syntax, except for the ReadWrite case?
 
Because primitive-backed enums and ADTs are far enough apart that making both fully supported is really really hard, conceptually, and if we have to choose I'd choose ADTs.
 
user1804599
For flags I’d rather use Set<Permission> anyway. Bitmasks are hard to use and remind of the 80s.
 
user1804599
Or struct { bool Execute; bool Write; bool Read; }.
 
@rightfold My thinking is the union is only viable on integer enums, so the primitive can be derived.
 
@Crell Primitive backed are a lot closer to what they would be used for in the real world with applications in PHP.
ADT might be more appealing as an intellectual exercise.
 
3:37 PM
Monads, baby. :-)
 
user1804599
You can choose to support the conversions only for ADTs that have no cases with associated values.
 
user1804599
Like deriving (Enum) in Haskell, generates those conversion operators, but you can’t use it with associated values.
 
user1804599
#[Derive(__toString, fromString)]
enum { Hearts, Clubs, Diamonds, Spades }
 
That is both highly cool to think about and probably multiple RFCs all on its own to support. :-)
 
user1804599
You could define different traits with different conversion behaviors, then use them in the enum. Make a whole library of them.
 
user1804599
3:46 PM
enum Suit {
    use EnumString, EnumInt; // these traits use the AsString and AsInt attributes
    #[AsString('H'), AsInt(1)] case Hearts;
    #[AsString('C'), AsInt(2)] case Clubs;
    #[AsString('D'), AsInt(3)] case Diamonds;
    #[AsString('S'), AsInt(4)] case Spades;
}
 
user1804599
Traits are nice. I like it when languages provide simple copy–paste behavior.
 
user1804599
Though your RFC will probably be rejected on sight of the word “trait”.
 
4:11 PM
Heading out for lunch and errands, back in a few hours.
 
Welp just posed my wall of text onto that Reddit thread
 
oo walls of text, to the reddits \o/
 
hot take tm
 
Not bad :-)
 
4:26 PM
@rightfold I like that usage of attributes
@Crell that would be rather an use case for const RW = self::Read | self::Write;
@rightfold why? traits are not bad, just often enough misused
but that's a real good usage of them
@MarkR a lot of real world usages do not have only a single representation and I'm over and over bitten by that in java…
 
@bwoebi Can you give an example to think about?
 
@MarkR usually having a string for the database and another string for the json output
because … requirements :-D
 
user1804599
4:44 PM
What’s cool with traits is you can rename the methods.
 
user1804599
But I’m not sure how you’d use the same one multiple times as you can’t parameterize traits.
 
I usually have my primary + internal representation as a native type, 99% of the time an integer, then have another class constant to act as a map using the constant keys for use in displaying them.

class Foo {
const STATUS_X = 100;
const STATUS_Y = 200;

const StatusMap = [
self::STATUS_X => 'X',
self::STATUS_Y => 'Y'
];
}
 
@SammyK would you be bothered if I linked to your "how to contribute to the PHP docs" blog post on the r/PHP subreddit?
Or anyone else, for that matter
 
4:59 PM
@MarkR yes, you can do that… the mistake is just that I happen to forget to convert sometimes and nothing catches that
If you have two methods to explicitly chose from… then you don't make such mistakes
 
5:42 PM
 
@Tiffany Doesn't that preclude just saying hello to announce your arrival?
 
@MarkR it depends on your intent to converse
 
@Tiffany seems dumb
in one on one sure, but not in a group chat like this
 
6:34 PM
Sep 15 at 16:48, by Derick
@JustinHarris https://nohello.com
there are situations in here where it's useful ;)
 
7:07 PM
@bwoebi Right. I think enum unions and enum "backing primitives" are coupled. I don't know how we would do the first without the second, and doing the second but not allowing the first seems short-sighted. Unless we went really all the way to Haskell. :-)
 
7:19 PM
@Crell well, if you want to get the value from the enum set/union, you can basically just iterate over the enum set and do whatever you want with them
like getting the bit it is responsible for
or merging it into a comma separated list of names
or whatever the representation of your union for the current use case is
there is no real need to couple it to actual backing values
when you use the permissions example, you can write it as "rwx", but also just as "7"
 
But then what does stringification look like?
 
you need to add a static method for that, taking the enumset
I don't think we need to directly use a stringification method, or maybe a simple "A|B|C" as value
 
7:40 PM
@Tiffany yeah, makes sense that way
 
A static method? That seems... unnatural in context.
 
user1804599
7:55 PM
Bitwise ORing enum values corresponds to bitset data type. Which is essentially a record with Boolean fields, one field for each enum case.
 
user1804599
And indeed, given a record with fields (a, b, c, …), and an enum with cases (a, b, c, …), you can use the enum to select a field from the record (to read or modify it).
 
user1804599
Given a guarantee that the set of fields F(R) of homogeneous record R is equal to the set of cases C(E) of enum E, you can construct a function E -> Lens R T (where T is the type of the fields of R).
 
user1804599
If you are into reflection and generics, you could make a generic class Flags<E : enum>. This would then efficiently store a set of enum values as a bitset, with set, unset, and has methods.
 
user1804599
Or, perhaps the compiler could generate such a class for every defined enum, if people really want flag sets (I don’t care for them, options are evil).
 
Some languages have, essentially, marker interfaces for enums that enable certain functionality. I think it's Swift(?) that requires that for getting an enumerable list of enum cases. (I may be wrong, it's one of the ones I surveyed.)
 
user1804599
8:04 PM
enum Permission { Read, Write, Execute }
// generated: class PermissionFlags { public bool $Read; public bool $Write; public bool $Execute; public function has(Permission $p): bool; public function set(Permission $p, bool $v): void; }
 
I don't know that's a good solution, though...
 
user1804599
It would probably be too early to decide, given people are considering adding some form of generics to the language, which could make for a nicer implementation of this than generating a class with an arbitrary name.
 
user1804599
Regardless I don’t think baking ORability into every enum by default is a good idea.
 
user1804599
At least you could already use SplObjectStorage. Just no pretty syntax and not as efficient.
 
@rightfold My idea was using EnumSet<E : enum> … so we're on the same page :-D
 
8:10 PM
I am not familiar with EnumSet, so I don't really follow there.
 
@Crell It's just a name for something representing an union of enum values
I didn't copy that (knowingly) from anything I know of
 
Ah, ok.
 
user1804599
final class EnumSet<E : enum>
{
    public static function empty(): self;
    public function has(E $e): bool;
    public function set(E $e): self;
    public function unset(E $e): self;
}
 
@rightfold yeah, that, or just allowing native binary ops
if ($enumSet & Permission::Read) ...
 
user1804599
That’d be neat, with ~ too. :)
 
8:12 PM
It looks like Java does something similar. docs.oracle.com/javase/7/docs/api/java/util/EnumSet.html
 
yeah
 
(I've only skimmed it)
 
user1804599
Cool!
 
Honestly, I'd prefer just using methods. The less magic the better.
If we allow custom operators at some point it's a different story.
But that RFC was rejected recently so...
 
user1804599
@bwoebi Although you’d need a way to constrain the type parameter to only enums with no cases with associated values.
 
8:14 PM
@rightfold yes, that's why I think a native solution would be good, which has inherent knowledge of these rules
 
@rightfold If we had proper generics this could be possible by automatically adding an interface to enums with only unit cases and then restricting the generic parameter of EnumSet to that interface.
 
user1804599
Although, if you are using enums for sets, you’re probably not using them for anything else.
 
user1804599
So why not just use a class that has a bunch of bool fields on it?
 
@rightfold because it's a lot of boilerplate to support operations, e.g. if you have two enum sets
like merging permissions for the current user with permissions available for everyone
 
user1804599
Right.
 
user1804599
8:19 PM
There could some form of generating that boilerplate.
 
user1804599
But EnumSet<E : enum> is a less weird way of doing it.
 
@IluTov I consider enum values as a type category on their own right, even if they end up being implemented as singleton object instances and as such may have their own operators … It's not like you can do 1 | $enum … but you can do MyEnum::Foo | $enum when $enum instanceof MyEnum
@rightfold yeah
 
user1804599
You can implement EnumSet without generics. Java does it (the JVM doesn’t know generics).
 
@rightfold yes, but the compiler does :-)
Hence you can do it type safe in Java
 
@rightfold The compiler will enforce the types at compile time. We'll need the enum type at runtime to check that the passed values are part of the same enum.
 
user1804599
8:22 PM
Yeah but the compiler doesn’t do anything with the implementation of EnumSet that is dependent on what E is instantiated to.
 
user1804599
The definition of EnumSet is type-checked exactly once; when it is defined. If you then instantiate EnumSet<Permission> and EnumSet<Suit>, it is not going to type-check the definition again.
 
@rightfold We just want to make sure you can't do nonesensical stuff like checking if a unrelated enum case is part of an enum set of a different enum type.
 
user1804599
You could store the name of the enum type in the set, along with the bits.
 
@rightfold how do you ensure at a function boundary that the EnumSet you receive only contains enums of a specific enum
 
user1804599
With an assertion.
 
8:24 PM
yeah well
 
@rightfold Yes, but how do we tell the enum set which type we want? We could pass the class name as a string but yeah...
 
@IluTov Ain't necessarily a fan of the feature, but my main issue with it was the error handling behaviour u.u
 
@rightfold that's the point of generics that you do not have to assert such things at all places :-D
 
user1804599
I’m not sure how generics in PHP would work. Will they be like C#, where get_class(new EnumSet<Suit>()) returns EnumSet<Suit>?
 
I mean, we can also just remove all type checking and assert everything… it's just maximally much boilerplate :-D
@rightfold generics in PHP pretty much would need to be runtime generics, yes
 
user1804599
8:26 PM
Ok then that makes sense.
 
user1804599
If you allow for generic traits and allow value parameters then you could treat them as macros. :D
 
@rightfold Did I hear template hell?
 
user1804599
enum Suit
{
    use AsString<'Db'>, AsString<'Json'>;
    #[AsString('Db', 'H'), AsString('Json', 'hearts')] case Hearts;
    #[AsString('Db', 'D'), AsString('Json', 'diamonds')] case Diamonds;
    #[AsString('Db', 'S'), AsString('Json', 'spades')] case Spades;
    #[AsString('Db', 'C'), AsString('Json', 'clubs')] case Clubs;
}
 
but yeah, generic traits would be awesome
but at that point you can also just introduce full-fledged rust like macros
 
user1804599
This seems like a type-safe, statically analyzable, extensible, orthogonal, compositional solution to the primitive value mapping problem.
 
user1804599
8:30 PM
All you need is a simple feature called generics.
 
Generics are totally simple, yeah :-P
 
user1804599
echo Suit::Hearts->toStringDb(); // H
echo Suit::Hearts->toStringJson(); // hearts
 
user1804599
8:50 PM
I really like that classes are not objects in PHP and that static methods aren’t just normal methods on metaclasses and all that stuff.
 
user1804599
It is so much simpler, and easier to work with.
 
user1804599
One of my favorite PHP features.
 
cmb
9:46 PM
@mega6382, just seen your php.net account request again. Would you mind to provide doc contributions as [github.com/php/doc-en/pulls]PRs[/url] for now?
 
@cmb I contributed through edit.php.net and this is the only one I could find, github.com/php/doc-en/commit/…
I am sure there were others but I can't find them, but I will be sure to make some new ones and bee more active in docs, so that I can qualify. :)
 
cmb
10:16 PM
@mega6382 great, thank you! IMO PRs are potentially a very good way to get accustomed to editing the docs (GH comments can be very useful) – and you are not limited by SVN. :)
 
@cmb Thanks, maybe I will do that from now on and it will be easier to track since it will be from my one account, rather than anonymous on the doc editor, which is how I think I lost my contributions.
 
GH > SVN, no question.
 
obviously, almost no one uses SVN anymore, and it was way before my time anyway, I have heard that it requires a central remote unlike git too.
 
Yes. SVN was "a better CVS." Which it was, and not much more.
 
The first version control that I used was "code-bkp1", "code-bkp2", "code-old", "code-june-2013", "code-latest", "code-live" etc :D
 
10:28 PM
20200920222859UTC__name_of_whatever

Still using per need for everything. This naming convention doesn't allow you make mistake whether it's comment, filename or something else.
 
10:39 PM
filename.extension_backup - used when I'm backing up a file in Linux that I need to modify and I'm unsure about the change in making
e.g. index.php_backup
 
github.com/php/php-src/pull/6172 - Anyone want to weigh in on the still outstanding questions here?
 
Funny thing was, an Oracle compiler I used for PL/SQL files could recognize SQL file extensions even if I added _backup or _whatever, since on that environment, I didn't have git or any version control :<
 
@Crell Link -> Connection
At least that's what I call it in every abstraction of my own
 
my work computer has putty on it but not git or git bash :<
I don't even have putty on my desktop
@cmb would you be opposed if I reordered contents on this page? php.net/manual/en/ref.pdo-mysql.connection.php
it bothered me that there's "Example #1" then "Examples" underneath... I realize that Example #1 is specific to charset, but the page feels out of order...
granted I don't know if it justifies having to re-translate it :/
 
@Tiffany index.php.bak should be standard™.
 
00:00 - 23:0023:00 - 00:00

« first day (3627 days earlier)      last day (1304 days later) »